Don't clobber all iSCSI connections during nova cleanup

The existing cleanup_nova() code inadvertently logs out of all iSCSI
connections on the machine because it does not pass the target name
as the -T parameter. This patch changes it to step through the targets
that match the pattern, logging out of each individually, and following
up with a delete op to cleanup the database.

Change-Id: I26c14acbe0e8de18f0e3bf7ad83b37379503e199
This commit is contained in:
Dan Smith 2013-03-28 12:22:25 -07:00
parent 40ef624e36
commit c0fad2b6a1

View File

@ -156,8 +156,11 @@ function cleanup_nova() {
fi
# Logout and delete iscsi sessions
sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | xargs sudo iscsiadm --mode node --logout || true
sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d " " -f2 | sudo iscsiadm --mode node --op delete || true
tgts=$(sudo iscsiadm --mode node | grep $VOLUME_NAME_PREFIX | cut -d ' ' -f2)
for target in $tgts; do
sudo iscsiadm --mode node -T $target --logout || true
done
sudo iscsiadm --mode node --op delete || true
# Clean out the instances directory.
sudo rm -rf $NOVA_INSTANCES_PATH/*