From 084efc7158f60530205e5ccad2947ec3948b7f26 Mon Sep 17 00:00:00 2001 From: Waldemar Znoinski Date: Wed, 9 Mar 2016 12:18:51 +0000 Subject: [PATCH] run tgt-admin --delete only if input not empty This change provides better handling of tgtadm --op show output as input of tgt-admin --delete command. In situation where no output of the first command is present no tgt-admin command is run. Change-Id: Ief5e1d50dd679f4d47cffef29ff07e54cc37f80a Closes-bug: 1554997 --- lib/lvm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lvm b/lib/lvm index ae6023a836..b9d7c390a2 100644 --- a/lib/lvm +++ b/lib/lvm @@ -124,7 +124,7 @@ function init_lvm_volume_group { if [ "$CINDER_ISCSI_HELPER" = "lioadm" ]; then sudo cinder-rtstool get-targets | sudo xargs -rn 1 cinder-rtstool delete else - sudo tgtadm --op show --mode target | grep Target | cut -f3 -d ' ' | sudo xargs -n1 tgt-admin --delete || true + sudo tgtadm --op show --mode target | awk '/Target/ {print $3}' | sudo xargs -r -n1 tgt-admin --delete fi _clean_lvm_volume_group $vg }