From: Alessandro Pilotti Date: Wed, 12 Dec 2012 20:10:35 +0000 (+0200) Subject: Fixes a Windows volume driver bug on disk export X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=147e30b4a8a9ce8361b048239a0187ac04679db1;p=openstack-build%2Fcinder-build.git Fixes a Windows volume driver bug on disk export Fixes Bug #1089168 When a VHD created by Cinder using the iSCSI Target Server is deleted manually, at the next startup the cinder-volume service terminates with an exception. This fix adds a check to verify if the disk exists. Change-Id: I830cb8332dcef845591bd88cccef1e0e9781ffcc --- diff --git a/cinder/tests/test_windows.py b/cinder/tests/test_windows.py index 430eb40f4..2ee09b73d 100644 --- a/cinder/tests/test_windows.py +++ b/cinder/tests/test_windows.py @@ -37,7 +37,7 @@ class TestWindowsDriver(basetestcase.BaseTestCase): def setUp(self): super(TestWindowsDriver, self).setUp() self.flags( - windows_iscsi_lun_path='D:\iSCSIVirtualDisks', + windows_iscsi_lun_path='C:\iSCSIVirtualDisks', ) self._volume_data = None self._volume_data_2 = None diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_check_for_setup_errors_wmi.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_check_for_setup_errors_wmi.p.gz index 32a00b3d1..dada5e654 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_check_for_setup_errors_wmi.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_check_for_setup_errors_wmi.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_export_os.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_export_os.p.gz index a511d37bf..c425615b9 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_export_os.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_export_os.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_export_wmi.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_export_wmi.p.gz index a12005af1..2f6ea72b5 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_export_wmi.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_export_wmi.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_snapshot_os.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_snapshot_os.p.gz index a8b094f0c..5e55a96f3 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_snapshot_os.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_snapshot_os.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_snapshot_wmi.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_snapshot_wmi.p.gz index a862e77f8..4e5879f67 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_snapshot_wmi.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_snapshot_wmi.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_from_snapshot_os.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_from_snapshot_os.p.gz index f8e073691..5de824a7c 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_from_snapshot_os.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_from_snapshot_os.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_from_snapshot_wmi.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_from_snapshot_wmi.p.gz index 3cd1f0add..8b9ead48f 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_from_snapshot_wmi.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_from_snapshot_wmi.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_os.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_os.p.gz index f3f75ab7b..fc8eee072 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_os.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_os.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_wmi.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_wmi.p.gz index 3fe0c038f..dad1f8520 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_wmi.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_create_volume_wmi.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_snapshot_os.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_snapshot_os.p.gz index 50522d795..69184224f 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_snapshot_os.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_snapshot_os.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_snapshot_wmi.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_snapshot_wmi.p.gz index 6013757f2..26de5bdac 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_snapshot_wmi.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_snapshot_wmi.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_volume_os.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_volume_os.p.gz index b4494a845..5ec542941 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_volume_os.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_volume_os.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_volume_wmi.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_volume_wmi.p.gz index 48df24bc2..11fed29bb 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_volume_wmi.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_delete_volume_wmi.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_ensure_export_os.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_ensure_export_os.p.gz index 36e30e6ec..3c5813515 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_ensure_export_os.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_ensure_export_os.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_ensure_export_wmi.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_ensure_export_wmi.p.gz index d561a318a..a0b4f4fd3 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_ensure_export_wmi.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_ensure_export_wmi.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_initialize_connection_os.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_initialize_connection_os.p.gz index 0bc36f254..5373f0178 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_initialize_connection_os.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_initialize_connection_os.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_initialize_connection_wmi.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_initialize_connection_wmi.p.gz index 273068866..b2af2519f 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_initialize_connection_wmi.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_initialize_connection_wmi.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_remove_export_os.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_remove_export_os.p.gz index d1d4eda1b..64fdc6bef 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_remove_export_os.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_remove_export_os.p.gz differ diff --git a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_remove_export_wmi.p.gz b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_remove_export_wmi.p.gz index 008d530f4..9a8fe70b4 100644 Binary files a/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_remove_export_wmi.p.gz and b/cinder/tests/windows/stubs/test_windows.TestWindowsDriver.test_remove_export_wmi.p.gz differ diff --git a/cinder/volume/drivers/windows.py b/cinder/volume/drivers/windows.py index 037737440..e664427c2 100644 --- a/cinder/volume/drivers/windows.py +++ b/cinder/volume/drivers/windows.py @@ -206,7 +206,11 @@ class WindowsDriver(driver.ISCSIDriver): ' while ensuring export'), exc) #Get the disk to add vol_name = volume['name'] - wt_disk = self._conn_wmi.WT_Disk(Description=vol_name)[0] + q = self._conn_wmi.WT_Disk(Description=vol_name) + if not len(q): + LOG.debug(_('Disk not found: %s'), vol_name) + return None + wt_disk = q[0] wt_host = self._conn_wmi.WT_Host(HostName=target_name)[0] wt_host.AddWTDisk(wt_disk.WTD)