1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-18 02:50:09 +03:00

F #814: skip VM snapshots xml if metadata are missing

This commit is contained in:
Jan Orel 2019-02-05 15:26:15 +01:00 committed by Ruben S. Montero
parent 5c711d8ba7
commit c419db5664
2 changed files with 8 additions and 7 deletions

View File

@ -46,13 +46,14 @@ SNAP_NAME="snap-${SNAP_ID}"
data=`virsh --connect $LIBVIRT_URI snapshot-create-as $DOMAIN --name "$SNAP_NAME"`
if [ "$?" = "0" ]; then
SNAP_XML_PATH="${DATASTORE_PATH}/${SNAP_NAME}.xml"
# dump snapshot metadata xml to the VM location
virsh --connect $LIBVIRT_URI snapshot-dumpxml $DOMAIN $SNAP_NAME > $SNAP_XML_PATH || true
echo "$data" | awk '{print $3}'
if [ -n "$DATASTORE_PATH" ]; then
SNAP_XML_PATH="${DATASTORE_PATH}/${SNAP_NAME}.xml"
# dump snapshot metadata xml to the VM location
virsh --connect $LIBVIRT_URI snapshot-dumpxml $DOMAIN $SNAP_NAME > $SNAP_XML_PATH || true
fi
else
error_message "Could not create snapshot $NAME for domain $DOMAIN."
exit -1

View File

@ -42,7 +42,7 @@ DATASTORE_PATH="${XPATH_ELEMENTS[i++]}"
# ------ Delete snapshot metadata and the snapshot itself ----------
rm ${DATASTORE_PATH}/${NAME}.xml 2>/dev/null || true
[ -n "$DATASTORE_PATH" ] && rm ${DATASTORE_PATH}/${NAME}.xml 2>/dev/null || true
exec_and_log \
"virsh --connect $LIBVIRT_URI snapshot-delete $DOMAIN $NAME" \