From c70d356352ee21b102a33e0b84928419894ed3c8 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Fri, 28 Mar 2014 10:47:07 +0200 Subject: [PATCH] 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 (cherry picked from commit 601d54c9ef926fa2d8abfe0121019f7ad94eefd5) --- cinder/volume/drivers/windows/windows_utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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: -- 2.45.2