From d15cc07690f2ee230e80e21ce5a7333110017bf8 Mon Sep 17 00:00:00 2001 From: Davide Panarese Date: Fri, 25 Jan 2019 12:23:30 +0100 Subject: [PATCH] Fix --noop condition [ ! -z "$1" ] execute code when an argument is defined. Remove ! into the condition to make --noop work properly Signed-off-by: Davide Panarese Change-Id: Ib9ec04a37bfe69e323f14f6bf4cb72b0fa818803 --- libvirt/cleanup-orphaned-vms.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libvirt/cleanup-orphaned-vms.sh b/libvirt/cleanup-orphaned-vms.sh index 23f5725..90e140b 100755 --- a/libvirt/cleanup-orphaned-vms.sh +++ b/libvirt/cleanup-orphaned-vms.sh @@ -22,11 +22,11 @@ for i in `virsh list --all | grep -E '^ [0-9-]+' | awk '{print $2;}'` ; do virsh dumpxml $i | grep "source file" | grep -E "$UUIDS" >/dev/null if [ $? -ne 0 ]; then echo -n "+ $i is NOT known to OpenStack, removing managedsave info... " - [ ! -z "$1" ] && virsh managedsave-remove $i 1>/dev/null 2>&1 + [ -z "$1" ] && virsh managedsave-remove $i 1>/dev/null 2>&1 echo -n "destroying VM... " - [ ! -z "$1" ] && virsh destroy $i 1>/dev/null 2>&1 + [ -z "$1" ] && virsh destroy $i 1>/dev/null 2>&1 echo -n "undefining VM... " - [ ! -z "$1" ] && virsh undefine $i 1>/dev/null 2>&1 + [ -z "$1" ] && virsh undefine $i 1>/dev/null 2>&1 echo DONE else echo "* $i is known to OpenStack, not removing."