]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Move create_cloned_volume() to LVMVolumeDriver.
authorAvishay Traeger <avishay@il.ibm.com>
Thu, 7 Feb 2013 09:11:03 +0000 (11:11 +0200)
committerAvishay Traeger <avishay@il.ibm.com>
Thu, 7 Feb 2013 09:11:03 +0000 (11:11 +0200)
The implementation of create_cloned_volume() that was in driver.py
relied on functions that aren't declared there, such as
_create_volume(), _copy_volume(), and _sizestr().  Moved the function
to LVMVolumeDriver in lvm.py, where those functions exist.

Change-Id: I5ab77a119b3af0a152a3b5e0c2ff6a5ce196ad0f
Fixes: bug #1112485
cinder/volume/driver.py
cinder/volume/drivers/lvm.py

index 5c5677be417a7f18b78b498ff727be733bff682c..8b63424b01f12981fcf728c0a2a767c904a6fcf6 100644 (file)
@@ -102,20 +102,7 @@ class VolumeDriver(object):
 
     def create_cloned_volume(self, volume, src_vref):
         """Creates a clone of the specified volume."""
-        LOG.info(_('Creating clone of volume: %s') % src_vref['id'])
-        volume_name = FLAGS.volume_name_template % src_vref['id']
-        temp_snapshot = {'volume_name': volume_name,
-                         'size': src_vref['size'],
-                         'volume_size': src_vref['size'],
-                         'name': 'clone-snap-%s' % src_vref['id']}
-        self.create_snapshot(temp_snapshot)
-        self._create_volume(volume['name'], self._sizestr(volume['size']))
-        try:
-            self._copy_volume(self.local_path(temp_snapshot),
-                              self.local_path(volume),
-                              src_vref['size'])
-        finally:
-            self.delete_snapshot(temp_snapshot)
+        raise NotImplementedError()
 
     def delete_volume(self, volume):
         """Deletes a volume."""
index d3dc9a2285c82f479bea3f2ee32370329e56fdb0..51df63546241465079a40530cca445a10dacfdde 100644 (file)
@@ -248,6 +248,23 @@ class LVMVolumeDriver(driver.VolumeDriver):
                                   image_meta,
                                   self.local_path(volume))
 
+    def create_cloned_volume(self, volume, src_vref):
+        """Creates a clone of the specified volume."""
+        LOG.info(_('Creating clone of volume: %s') % src_vref['id'])
+        volume_name = FLAGS.volume_name_template % src_vref['id']
+        temp_snapshot = {'volume_name': volume_name,
+                         'size': src_vref['size'],
+                         'volume_size': src_vref['size'],
+                         'name': 'clone-snap-%s' % src_vref['id']}
+        self.create_snapshot(temp_snapshot)
+        self._create_volume(volume['name'], self._sizestr(volume['size']))
+        try:
+            self._copy_volume(self.local_path(temp_snapshot),
+                              self.local_path(volume),
+                              src_vref['size'])
+        finally:
+            self.delete_snapshot(temp_snapshot)
+
     def clone_image(self, volume, image_location):
         return False