Make copy_to_volume a bit more useful.
The current implementation of cinder.driver.copy_to_volume does not take in to account image type and is only valid for raw images. This doesn't do much good for the majority of cases, and rather than require folks to have a raw version uploaded to Glance, let's just do a convert if needed on the fly. This simply creates a temp file, does the conversion and then writes the temp file directly to the volume. Change-Id: I849b04b8aae76da068abcd2a20c1fcecca8a5caa
This commit is contained in:
committed by
John Griffith
parent
51a438c8f3
commit
6a31bf3e43
@@ -26,6 +26,7 @@ import time
|
||||
|
||||
from cinder import exception
|
||||
from cinder import flags
|
||||
from cinder.image import image_utils
|
||||
from cinder.openstack.common import cfg
|
||||
from cinder.openstack.common import log as logging
|
||||
from cinder import utils
|
||||
@@ -586,10 +587,10 @@ class ISCSIDriver(VolumeDriver):
|
||||
|
||||
def copy_image_to_volume(self, context, volume, image_service, image_id):
|
||||
"""Fetch the image from image_service and write it to the volume."""
|
||||
volume_path = self.local_path(volume)
|
||||
with utils.temporary_chown(volume_path):
|
||||
with utils.file_open(volume_path, "wb") as image_file:
|
||||
image_service.download(context, image_id, image_file)
|
||||
image_utils.fetch_to_raw(context,
|
||||
image_service,
|
||||
image_id,
|
||||
self.local_path(volume))
|
||||
|
||||
def copy_volume_to_image(self, context, volume, image_service, image_id):
|
||||
"""Copy the volume to the specified image."""
|
||||
|
||||
Reference in New Issue
Block a user