]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Implement copy_image_to_volume and copy_volume_to_image on nfs backends
authorMehdi Abaakouk <mehdi.abaakouk@enovance.com>
Tue, 7 May 2013 08:37:10 +0000 (10:37 +0200)
committerMehdi Abaakouk <mehdi.abaakouk@enovance.com>
Tue, 7 May 2013 08:37:58 +0000 (10:37 +0200)
Fixes: bug #1177288
Change-Id: I1c034de4acf13c52e399ba4623a0c8f2110fd695

cinder/volume/drivers/nfs.py

index 4638e1268054dd58840ec67ddf9685cc105e3313..ac98b972eba8722cc7b68c7301293c92f2e36f41 100755 (executable)
@@ -22,6 +22,7 @@ import os
 from oslo.config import cfg
 
 from cinder import exception
+from cinder.image import image_utils
 from cinder.openstack.common import log as logging
 from cinder.volume import driver
 
@@ -340,3 +341,17 @@ class NfsDriver(RemoteFsDriver):
         data['reserved_percentage'] = 0
         data['QoS_support'] = False
         self._stats = data
+
+    def copy_image_to_volume(self, context, volume, image_service, image_id):
+        """Fetch the image from image_service and write it to the volume."""
+        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_meta):
+        """Copy the volume to the specified image."""
+        image_utils.upload_volume(context,
+                                  image_service,
+                                  image_meta,
+                                  self.local_path(volume))