]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fixes Windows Volume Driver upload volume fails
authorAdelina Tuvenie <atuvenie@cloudbasesolutions.com>
Fri, 5 Sep 2014 15:16:55 +0000 (18:16 +0300)
committerAdelina Tuvenie <atuvenie@cloudbasesolutions.com>
Thu, 11 Sep 2014 07:03:53 +0000 (10:03 +0300)
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

cinder/tests/windows/test_windows.py [changed mode: 0644->0755]
cinder/volume/drivers/windows/windows.py [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 055f4e8..43c1d3f
@@ -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)
old mode 100644 (file)
new mode 100755 (executable)
index 571a741..522a762
@@ -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