From: Adelina Tuvenie Date: Fri, 5 Sep 2014 15:16:55 +0000 (+0300) Subject: Fixes Windows Volume Driver upload volume fails X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=d790e899447f6871ca69a2def0f723ba404be1d9;p=openstack-build%2Fcinder-build.git Fixes Windows Volume Driver upload volume fails The copy_volume_to_image requires in some cases an intermediary conversion, which takes place in the configured image conversion dir. If this folder is not created, the operation will fail. This patch ensures that method will create the folder if it does not exist. Change-Id: I82b5e76c6d6f3114666f184672667dc3b95bab8b Closes-Bug: #1356415 --- diff --git a/cinder/tests/windows/test_windows.py b/cinder/tests/windows/test_windows.py old mode 100644 new mode 100755 index 055f4e80c..43c1d3f0f --- a/cinder/tests/windows/test_windows.py +++ b/cinder/tests/windows/test_windows.py @@ -305,15 +305,19 @@ class TestWindowsDriver(test.TestCase): image_meta = db_fakes.get_fake_image_meta() fake_get_supported_format = lambda x: supported_format + + self.stubs.Set(os.path, 'exists', lambda x: False) self.stubs.Set(drv, 'local_path', self.fake_local_path) self.stubs.Set(windows_utils.WindowsUtils, 'get_supported_format', fake_get_supported_format) + self.mox.StubOutWithMock(fileutils, 'ensure_tree') self.mox.StubOutWithMock(fileutils, 'delete_if_exists') self.mox.StubOutWithMock(image_utils, 'upload_volume') self.mox.StubOutWithMock(windows_utils.WindowsUtils, 'copy_vhd_disk') self.mox.StubOutWithMock(vhdutils.VHDUtils, 'convert_vhd') + fileutils.ensure_tree(CONF.image_conversion_dir) temp_vhd_path = os.path.join(CONF.image_conversion_dir, str(image_meta['id']) + "." + supported_format) diff --git a/cinder/volume/drivers/windows/windows.py b/cinder/volume/drivers/windows/windows.py old mode 100644 new mode 100755 index 571a7414b..522a76289 --- a/cinder/volume/drivers/windows/windows.py +++ b/cinder/volume/drivers/windows/windows.py @@ -187,6 +187,9 @@ class WindowsDriver(driver.ISCSIDriver): def copy_volume_to_image(self, context, volume, image_service, image_meta): """Copy the volume to the specified image.""" disk_format = self.utils.get_supported_format() + if not os.path.exists(self.configuration.image_conversion_dir): + fileutils.ensure_tree(self.configuration.image_conversion_dir) + temp_vhd_path = os.path.join(self.configuration.image_conversion_dir, str(image_meta['id']) + '.' + disk_format) upload_image = temp_vhd_path