roles: bifrost-create-vm-nodes: Randomize VM XML file
/tmp/vm.xml is not that uncommon to exist outside of bifrost and to hold user's temporary VM definitions so make sure we don't wipe it and use a random file instead. Change-Id: I70088df744011b391a66ab2f98b67583c43dd0b2
This commit is contained in:
parent
307a5e6776
commit
d10abd26f1
@ -218,17 +218,23 @@ function create_node {
|
||||
</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,
|
||||
# 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 ]
|
||||
then
|
||||
echo "failed to create VM $NAME" >&2
|
||||
rm -f /tmp/vm.xml
|
||||
rm -f ${vm_tmpfile}
|
||||
exit 1
|
||||
fi
|
||||
rm -f /tmp/vm.xml
|
||||
rm -f ${vm_tmpfile}
|
||||
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user