Removed fuel from Genesis master since fuel has moved to repo fuel.
[genesis.git] / compass / deploy / host_vm.sh
1 host_vm_dir=$WORK_DIR/vm
2 function tear_down_machines() {
3     for i in host{0..4}
4     do
5         sudo virsh destroy $i 1>/dev/null 2>/dev/null
6         sudo virsh undefine $i 1>/dev/null 2>/dev/null
7         rm -rf $host_vm_dir/host$i
8     done
9 }
10
11 function reboot_hosts() {
12     log_warn "reboot_hosts do nothing"
13 }
14
15 function launch_host_vms() {
16     tear_down_machines
17     #function_bod
18     mac_array=`echo $machines|sed 's/,/ /g'`
19     log_info "bringing up pxe boot vms"
20     i=0
21     for mac in $mac_array; do
22         log_info "creating vm disk for instance host${i}"
23         vm_dir=$host_vm_dir/host$i
24         mkdir -p $vm_dir
25         sudo qemu-img create -f raw $vm_dir/disk.img ${VIRT_DISK}
26         # create vm xml
27         sed -e "s/REPLACE_MEM/$VIRT_MEM/g" \
28            -e "s/REPLACE_CPU/$VIRT_CPUS/g" \
29            -e "s/REPLACE_NAME/host$i/g" \
30            -e "s#REPLACE_IMAGE#$vm_dir/disk.img#g" \
31            -e "s/REPLACE_BOOT_MAC/$mac/g" \
32            -e "s/REPLACE_BRIDGE_MGMT/br_install/g" \
33            -e "s/REPLACE_BRIDGE_TENANT/br_install/g" \
34            -e "s/REPLACE_BRIDGE_PUBLIC/br_install/g" \
35            -e "s/REPLACE_BRIDGE_STORAGE/br_install/g" \
36            $COMPASS_DIR/deploy/template/vm/host.xml\
37            > $vm_dir/libvirt.xml
38         
39         sudo virsh define $vm_dir/libvirt.xml
40         sudo virsh start host$i
41         let i=i+1
42     done
43 }
44
45 function get_host_macs() {
46     local config_file=$WORK_DIR/installer/compass-install/install/group_vars/all
47     local mac_generator=${COMPASS_DIR}/deploy/mac_generator.sh
48     local machines=
49
50     chmod +x $mac_generator
51     mac_array=`$mac_generator $VIRT_NUMBER`
52     machines=`echo $mac_array|sed 's/ /,/g'`
53
54     echo "test: true" >> $config_file
55     echo "pxe_boot_macs: [${machines}]" >> $config_file
56     
57     echo $machines
58 }
59