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)
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