Merge "roles: bifrost-create-vm-nodes: Randomize VM XML file"

This commit is contained in:
Jenkins 2017-02-03 22:32:06 +00:00 committed by Gerrit Code Review
commit 2cdbb437df

View File

@ -218,17 +218,23 @@ function create_node {
</domain> </domain>
" "
echo ${vm_xml} > /tmp/vm.xml local vm_tmpfile=$(mktemp -p /tmp vm.XXXX.xml)
# This is very unlikely to happen but still better safe than sorry
if [ $? != 0 ]; then
echo "Failed to create the temporary VM XML file"
exit 1
fi
echo ${vm_xml} > ${vm_tmpfile}
# NOTE(TheJulia): the create command powers on a VM that has been defined, # NOTE(TheJulia): the create command powers on a VM that has been defined,
# where as define creates the VM, but does not change the power state. # where as define creates the VM, but does not change the power state.
virsh define /tmp/vm.xml 2>&1 >/dev/null virsh define ${vm_tmpfile} &>/dev/null
if [ $? != 0 ] if [ $? != 0 ]
then then
echo "failed to create VM $NAME" >&2 echo "failed to create VM $NAME" >&2
rm -f /tmp/vm.xml rm -f ${vm_tmpfile}
exit 1 exit 1
fi fi
rm -f /tmp/vm.xml rm -f ${vm_tmpfile}
fi fi