2 # Deploy in deployFuel has the "configure host-network,
3 # install fuel, configure vm and start it" meaning
10 echo "Usage: $0 <iso-file> <interface>"
16 readonly vm_name="fuel_opnfv"
17 readonly ssh_fuel_vm="sshpass -p r00tme
18 ssh -o UserKnownHostsFile=/dev/null
19 -o StrictHostKeyChecking=no
22 readonly RUN_INSTALL="${RUN_INSTALL:-false}"
23 readonly DEV="${DEV:-false}"
25 # poll is not real timeout, commands can take some undefined time to execute
26 # it is a count of how many times to try while sleeping shortly
28 readonly poll_virtinstall=1800
29 readonly poll_fuel_startup=1200
30 readonly poll_deployment=2150
31 readonly fuel_logfile="/var/log/puppet/bootstrap_admin_node.log"
33 cat >$interface.xml <<EOF
35 <name>$interface</name>
36 <forward dev='$interface' mode='bridge'>
37 <interface dev='$interface'/>
42 cleanup_previous_run() {
43 echo "Cleaning up previous run"
45 virsh net-destroy $interface > /dev/null 2>&1
46 virsh net-undefine $interface > /dev/null 2>&1
47 virsh destroy $vm_name > /dev/null 2>&1
48 virsh undefine $vm_name > /dev/null 2>&1
52 create_disk_and_install() {
54 qemu-img create -f qcow2 -o preallocation=metadata $vm_name.qcow2 60G
55 virt-install --connect=qemu:///system \
57 --network=network:$interface \
58 --ram 2048 --vcpus=4,cores=2 --check-cpu --hvm \
59 --disk path=$vm_name.qcow2,format=qcow2,device=disk,bus=virtio \
60 --noautoconsole --vnc \
64 wait_for_virtinstall() {
65 # Workaround for virt-install --wait which restarts vm
66 # too fast too attach disk
67 echo "Waiting for virt-install to finish..."
70 for i in $(seq 0 $poll_virtinstall); do
71 virsh_out=`virsh list | grep "$vm_name"`
72 if [ -z "$virsh_out" ]; then
81 wait_for_fuel_startup() {
82 echo "Wait for fuel to start up..."
83 for i in $(seq 0 $poll_fuel_startup); do
84 sleep 2 && echo -n "$i "
85 $ssh_fuel_vm grep complete $fuel_logfile &&
86 echo "Fuel bootstrap is done, deployment should have started now" &&
94 virsh net-define $interface.xml
95 virsh net-start $interface
96 create_disk_and_install
99 echo "Starting $vm_name after installation in 6s..." && sleep 6s
103 if ! wait_for_fuel_startup; then
104 echo "Fuel failed to start up"