]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fixes cinder volume delete on Windows
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Fri, 28 Mar 2014 08:47:07 +0000 (10:47 +0200)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Fri, 28 Mar 2014 19:13:08 +0000 (21:13 +0200)
Because of the fact that an iSCSI target is not created anymore
at volume creation time, not all volumes will have a corresponding
target. For this reason, when removing an iSCSI target we must
first check if the target actually exists.

Change-Id: I8e571397df6d9a2eeb05e883b7da8494d4bfa1ad
Closes-Bug: #1299124

cinder/volume/drivers/windows/windows_utils.py

index 5edbf154c7dd4b1eb941bbac44871f87c0d37dd2..3af2021c3c3c593e07925e675aa835a477b33df4 100644 (file)
@@ -235,7 +235,12 @@ class WindowsUtils(object):
     def remove_iscsi_target(self, target_name):
         """Removes ISCSI target."""
         try:
-            wt_host = self._conn_wmi.WT_Host(HostName=target_name)[0]
+            host = self._conn_wmi.WT_Host(HostName=target_name)
+            if not host:
+                LOG.debug(_('Skipping removing target %s as it does not '
+                            'exist.') % target_name)
+                return
+            wt_host = host[0]
             wt_host.RemoveAllWTDisks()
             wt_host.Delete_()
         except wmi.x_wmi as exc: