Projet

Général

Profil

Openstack Setup VM pas dans openstack » Historique » Version 3

Version 2 (Mehdi Abaakouk, 16/10/2014 12:32) → Version 3/9 (Mehdi Abaakouk, 16/10/2014 12:33)

{{>toc}}

h1. Openstack Setup VM pas dans openstack



h2. Use case maposmatic

Preparation du fichier hook pour "build-openstack-debian-image"

<pre>
# cat maposmatic-hook.sh
set -xv

echo "maposmatic" > $BODI_CHROOT_PATH/etc/hostname

cat > $BODI_CHROOT_PATH/etc/resolv.conf <<EOF
domain tetaneutral.net
search tetaneutral.net
nameserver 91.224.149.254
nameserver 91.224.148.10
EOF

cat > $BODI_CHROOT_PATH/etc/network/interfaces <<EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet manual
pre-up /sbin/sysctl -w net.ipv6.conf.eth0.accept_ra=0
pre-up /sbin/sysctl -w net.ipv6.conf.eth0.autoconf=0
up ip link set eth0 up
up ip addr add 89.234.156.232/32 dev eth0
up ip route add 91.224.149.0/24 dev eth0
up ip route add default via 91.224.149.254

iface eth0 inet6 static
pre-up /sbin/sysctl -w net.ipv6.conf.eth0.accept_ra=0
pre-up /sbin/sysctl -w net.ipv6.conf.eth0.autoconf=0
address 2a01:6600:8083:e800::1
netmask 56
gateway fe80::31
EOF

mkdir -p $BODI_CHROOT_PATH/root/.ssh
chmod 600 $BODI_CHROOT_PATH/root/.ssh
cat >> $BODI_CHROOT_PATH/root/.ssh/authorized_keys <<EOF
ssh-dss AAAAB3NzaC1kc3MAAACBAJtnGLvuz4uVD6fnERDxDi/C0UyzwCiKmgNtEessopREYasAX4Gu6Fg10jAyIL5Nuc7YDnqj//pOfxNjD7hp99a2ZmkRQgh/ltClxYML9fqhBHgsUCpVse9nOYDHDnDgvXIPRSDUHat2UFpdchHVrFURNLIlZnBztsr+GCDURTV/AAAAFQD9SrBcH49ltaKOm6V5ssCPmgs1SwAAAIAbAvkQ3/tMzzdACO5B9s5Yb3ZuM7XImm0iqufivVf2Xy39g8HOBulUsN7eKEGPhVriqNolgIO7q7tVgYAff4/NE4yDP0Kp0SPg4tjt2yFJuL31Y3wzwHjnKrjgNlDSLl3uZnRXSipwUMwGKbdHB6NZSqlq192VKbHilQ00pbiMlAAAAIB5dfB1lVHkJ0o5CcaVQRPbca9DvbbRwnoTSmKHc5DUcqsPqDhS07CkM9ZcJuY1Nh4wGl4Q9kArj7Tnsvvygf/HReSUcIk4+nbDytJ8/pca/Qx4fzQQyppa94TylN62LSFT6MIJKLoMwYa0dQURT7Mv5+9Qj2vk5pZ38w2iQ9zVCg== root@h1
ssh-dss AAAAB3NzaC1kc3MAAACBALnkOhUs6zyiHfllmziS+wmxTs+rpV3Up3N7R9Sha/X5mxwy0YHPT1B0/xi9dcxxYVty6C0sUHsncXQ1o8MRYFnILswVv5fwn8bpwYVDnFyjc7quOZa4XBbriyJ9+EuTMt1ereEV3wMPkBLfX6mhqxtCaNrN/9oeuxGG53ej+dCjAAAAFQDt7TB5ka3UTaOZnjjtl1B60SNmQwAAAIBbBStlNvCRyTUElesZzMDrnAhYYYMju0lQvptEaiaXZA3/nBbvYg1kMkGyUnpovj7KkljVn2YBSyywqCsiUDtT2y0rshUHxa8mn3nlD2+5jADUFK/SAki4fNlMcPBbcFhqJ7Yr5mv1TNtgW4lNhuZFEv40nqbP6RdZXPPvicHvXwAAAIBQEqvH0oMYcrbSgo2/10sFqmspY00HcKWNW5bJCERQr85UwAFtmGXz3CclIcINyPngNHmrexkQWQ5cb2xcFgR8gb2RinyjvPnSAU6ZyfMKjjqYVrMDzkcDYJu9q+NHYL6WZuXltS0RiZa0v83pI8WjywZkOPgaVexvVr+0RtkW9g== maxime@petazzoni
EOF

sed -i -e 's/^.*Port.*$/Port 2222/' -e 's/^[# ]*PasswordAuthentication.*$/PasswordAuthentication no/' $BODI_CHROOT_PATH/etc/ssh/sshd_config
chroot $BODI_CHROOT_PATH dpkg-reconfigure openssh-server
chroot $BODI_CHROOT_PATH apt-get purge -y cloud-init*
chroot $BODI_CHROOT_PATH passwd -d root
</pre>

Preparation de l'image disk

<pre>
/root/tools/images/build-openstack-debian-image --image-size 20 --release jessie -u http://apt.tetaneutral.net/debian/ -s http://apt.tetaneutral.net/debian/ --no-dhcp -e acpi-support --output maposmatic --hook maposmatic-hook.sh
mv maposmatic.raw /maposmatic.raw
</pre>

Setup de la VM

<pre>
virt-install --name maposmatic --vcpus=4,maxvcpus=8 --memory 8192,maxmemory=16384 --network bridge=br-eth0,model=virtio --nographics --serial pty --wait -1 --noreboot --autostart --disk /maposmatic.raw,bus=virtio,cache=none,io=native --disk /dev/sdb,bus=virtio,cache=none,io=native --disk /dev/sdc,bus=virtio,cache=none,io=native --import
</pre> <pre>

Modification du xml pour les trucs non pris en charge par virt-install:

<pre>
virsh edit maposmatic

# Pour chaque bridge ajouter, le vlan et openvswitch comme ceci:
<vlan><tag id='3132'/></vlan><virtualport type='openvswitch'/>

# Pour ceph, remplacer:

<disk type='file' device='disk'>
<driver name='qemu' type='raw' cache='none' io='native'/>
<source file='/maposmatic.raw'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>

# Par:


<disk type='network' device='disk'>
<driver name='qemu' type='raw'/>
<source protocol='rbd' name='ssds/maposmatic-disk'>
<host name='192.168.99.101' port='6789'/>
<host name='192.168.99.102' port='6789'/>
<host name='192.168.99.103' port='6789'/>
</source>
<auth username='openstack-service'>
<secret type='ceph' uuid='1fe74663-8dfa-486c-bb80-3bd94c90c967'/>
</auth>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
</pre>

puis import du disque dans ceph

<pre>
rbd -p ssds import /maposmatic.raw maposmatic-disk
</pre>

Boot de la VM

<pre>
virsh start openstack
</pre>