Vars refactor: Replace snapshot_tag with TAG

This commit is contained in:
Martin Wimpress 2020-03-21 10:39:09 +00:00
parent ce523fecdf
commit 21ff829078
No known key found for this signature in database
GPG Key ID: 61DF940515E06DA3

View File

@ -11,18 +11,18 @@ function disk_delete() {
} }
function snapshot_apply() { function snapshot_apply() {
local snapshot_tag="${1}" local TAG="${1}"
if [ -z "${snapshot_tag}" ]; then if [ -z "${TAG}" ]; then
echo "ERROR! No snapshot tag provided." echo "ERROR! No snapshot tag provided."
exit exit
fi fi
if [ -e "${disk_img}" ]; then if [ -e "${disk_img}" ]; then
${QEMU_IMG} snapshot -q -a "${snapshot_tag}" "${disk_img}" ${QEMU_IMG} snapshot -q -a "${TAG}" "${disk_img}"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "SUCCESS! Applied snapshot ${snapshot_tag} to ${disk_img}" echo "SUCCESS! Applied snapshot ${TAG} to ${disk_img}"
else else
echo "ERROR! Failed to apply snapshot ${snapshot_id} to ${disk_img}" echo "ERROR! Failed to apply snapshot ${TAG} to ${disk_img}"
fi fi
else else
echo "NOTE! ${disk_img} not found. Doing nothing." echo "NOTE! ${disk_img} not found. Doing nothing."
@ -30,18 +30,18 @@ function snapshot_apply() {
} }
function snapshot_create() { function snapshot_create() {
local snapshot_tag="${1}" local TAG="${1}"
if [ -z "${snapshot_tag}" ]; then if [ -z "${TAG}" ]; then
echo "ERROR! No snapshot tag provided." echo "ERROR! No snapshot tag provided."
exit exit
fi fi
if [ -e "${disk_img}" ]; then if [ -e "${disk_img}" ]; then
${QEMU_IMG} snapshot -q -c "${snapshot_tag}" "${disk_img}" ${QEMU_IMG} snapshot -q -c "${TAG}" "${disk_img}"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "SUCCESS! Created snapshot ${snapshot_tag} of ${disk_img}" echo "SUCCESS! Created snapshot ${TAG} of ${disk_img}"
else else
echo "ERROR! Failed to create snapshot ${snapshot_tag} of ${disk_img}" echo "ERROR! Failed to create snapshot ${TAG} of ${disk_img}"
fi fi
else else
echo "NOTE! ${disk_img} not found. Doing nothing." echo "NOTE! ${disk_img} not found. Doing nothing."
@ -49,18 +49,18 @@ function snapshot_create() {
} }
function snapshot_delete() { function snapshot_delete() {
local snapshot_tag="${1}" local TAG="${1}"
if [ -z "${snapshot_tag}" ]; then if [ -z "${TAG}" ]; then
echo "ERROR! No snapshot tag provided." echo "ERROR! No snapshot tag provided."
exit exit
fi fi
if [ -e "${disk_img}" ]; then if [ -e "${disk_img}" ]; then
${QEMU_IMG} snapshot -q -d "${snapshot_tag}" "${disk_img}" ${QEMU_IMG} snapshot -q -d "${TAG}" "${disk_img}"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "SUCCESS! Deleted snapshot ${snapshot_tag} of ${disk_img}" echo "SUCCESS! Deleted snapshot ${TAG} of ${disk_img}"
else else
echo "ERROR! Failed to delete snapshot ${snapshot_tag} of ${disk_img}" echo "ERROR! Failed to delete snapshot ${TAG} of ${disk_img}"
fi fi
else else
echo "NOTE! ${disk_img} not found. Doing nothing." echo "NOTE! ${disk_img} not found. Doing nothing."