1 host_vm_dir=$WORK_DIR/vm
2 function tear_down_machines() {
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
11 function reboot_hosts() {
12 log_warn "reboot_hosts do nothing"
15 function launch_host_vms() {
18 mac_array=`echo $machines|sed 's/,/ /g'`
19 log_info "bringing up pxe boot vms"
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
25 sudo qemu-img create -f raw $vm_dir/disk.img ${VIRT_DISK}
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\
39 sudo virsh define $vm_dir/libvirt.xml
40 sudo virsh start host$i
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
50 chmod +x $mac_generator
51 mac_array=`$mac_generator $VIRT_NUMBER`
52 machines=`echo $mac_array|sed 's/ /,/g'`
54 echo "test: true" >> $config_file
55 echo "pxe_boot_macs: [${machines}]" >> $config_file