Fixes cinder error state volume delete on Windows

If the volume creation fails and the iSCSI disk is not created,
trying to delete the error state volume will fail on Windows.

Deleting the iSCSI disk must be skipped when it does not exist.

Change-Id: I2cd615e71fe457c241bea207c4bd8904c1ffd9cb
Closes-Bug: #1304516
(cherry picked from commit 1317776885)
This commit is contained in:
Lucian Petrut 2014-04-08 19:35:10 +03:00 committed by Chuck Short
parent 978b036a64
commit d0602f6f2a
1 changed files with 6 additions and 1 deletions

View File

@ -148,7 +148,12 @@ class WindowsUtils(object):
def delete_volume(self, vol_name, vhd_path):
"""Driver entry point for destroying existing volumes."""
try:
wt_disk = self._conn_wmi.WT_Disk(Description=vol_name)[0]
disk = self._conn_wmi.WT_Disk(Description=vol_name)
if not disk:
LOG.debug(_('Skipping deleting disk %s as it does not '
'exist.') % vol_name)
return
wt_disk = disk[0]
wt_disk.Delete_()
vhdfiles = self._conn_cimv2.query(
"Select * from CIM_DataFile where Name = '" +