From: Lucian Petrut Date: Fri, 28 Mar 2014 08:47:07 +0000 (+0200) Subject: Fixes cinder volume delete on Windows X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=601d54c9ef926fa2d8abfe0121019f7ad94eefd5;p=openstack-build%2Fcinder-build.git Fixes cinder volume delete on Windows 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 --- diff --git a/cinder/volume/drivers/windows/windows_utils.py b/cinder/volume/drivers/windows/windows_utils.py index 5edbf154c..3af2021c3 100644 --- a/cinder/volume/drivers/windows/windows_utils.py +++ b/cinder/volume/drivers/windows/windows_utils.py @@ -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: