+ #truncate the last line to remove the comma behind the bracket
+ tail -n 1 $CONFIG/instackenv-virt.json | wc -c | xargs -I {} truncate $CONFIG/instackenv-virt.json -s -{}
+
+ #finally reclose the bracket and close the instackenv.json file
+ cat >> $CONFIG/instackenv-virt.json << EOF
+ }
+ ],
+ "arch": "x86_64",
+ "host-ip": "192.168.122.1",
+ "power_manager": "nova.virt.baremetal.virtual_power_driver.VirtualPowerManager",
+ "seed-ip": "",
+ "ssh-key": "INSERT_STACK_USER_PRIV_KEY",
+ "ssh-user": "root"
+}
+EOF
+}
+
+##Create virtual nodes in virsh
+##params: name - String: libvirt name for VM
+## bootdev - String: boot device for the VM
+## disksize - Number: size of the disk in Gig
+## ovs_bridges: - List: list of ovs bridges
+function define_vm () {
+ # Create the libvirt storage volume
+ if virsh vol-list default | grep ${1}.qcow2 2>&1> /dev/null; then
+ volume_path=$(virsh vol-path --pool default ${1}.qcow2 || echo "/var/lib/libvirt/images/${1}.qcow2")
+ echo "Volume ${1} exists. Deleting Existing Volume $volume_path"
+ virsh vol-dumpxml ${1}.qcow2 --pool default
+ touch $volume_path
+ virsh vol-delete ${1}.qcow2 --pool default
+ fi
+ virsh vol-create-as default ${1}.qcow2 ${3}G --format qcow2
+ volume_path=$(virsh vol-path --pool default ${1}.qcow2)
+ if [ ! -f $volume_path ]; then
+ echo "$volume_path Not created successfully... Aborting"
+ exit 1
+ fi
+
+ # create the VM
+ /usr/libexec/openstack-tripleo/configure-vm --name $1 \
+ --bootdev $2 \
+ --image "$volume_path" \
+ --diskbus sata \
+ --arch x86_64 \
+ --cpus 2 \
+ --memory 8388608 \
+ --libvirt-nic-driver virtio \
+ --baremetal-interface $4