]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Clone_image should return dict of vol properties, clone status.
authorNavneet Singh <singn@netapp.com>
Sat, 13 Jul 2013 06:55:30 +0000 (12:25 +0530)
committerNavneet Singh <singn@netapp.com>
Sat, 13 Jul 2013 08:09:57 +0000 (13:39 +0530)
The method will work fine in case of drivers not dependent
on volume properties like provider_location. It will fail to
restart in case of nfs drivers and also leave volume created as
result of clone_image functionality created in the
nfs share in dangling state after deletion as provider_location
is None. This fix requires dict of volume properties, cloned status
to be returned which facilitates passing back provider_location
in case of nfs drivers and hence resolves the issue.

bug 1200708

Change-Id: I590571e52d1c64b6dba7d7e76cd71badd74e51d1

cinder/tests/test_rbd.py
cinder/volume/driver.py
cinder/volume/drivers/lvm.py
cinder/volume/drivers/rbd.py
cinder/volume/drivers/scality.py
cinder/volume/manager.py

index a36a278b2c1e290a2e125decbffa6ecde2169fc2..8272389c08f12baea3ef0f7d636cee7084da0206 100644 (file)
@@ -454,7 +454,7 @@ class ManagedRBDTestCase(DriverTestCase):
         afterwards.
         """
         def fake_clone_image(volume, image_location):
-            return True
+            return {'provider_location': None}, True
 
         def fake_clone_error(volume, image_location):
             raise exception.CinderException()
index a5ce64444264c9dc5eb32e4f85f9ddf8f1c31254..0f95ce0deb7893cbf0321454857cf3146d175402 100644 (file)
@@ -201,9 +201,10 @@ class VolumeDriver(object):
         image service backend in use. The driver should use it
         to determine whether cloning is possible.
 
-        Returns a boolean indicating whether cloning occurred
+        Returns a dict of volume properties eg. provider_location,
+        boolean indicating whether cloning occurred
         """
-        return False
+        return None, False
 
     def backup_volume(self, context, backup, backup_service):
         """Create a new backup from an existing volume."""
index a905a15db710a5a7e8d1d8be16638ea8d00ee5cc..3b943089ba045986056084fc6051808644322640 100644 (file)
@@ -316,7 +316,7 @@ class LVMVolumeDriver(driver.VolumeDriver):
             self.delete_snapshot(temp_snapshot)
 
     def clone_image(self, volume, image_location):
-        return False
+        return None, False
 
     def backup_volume(self, context, backup, backup_service):
         """Create a new backup from an existing volume."""
index 288742b089343085fe5f70c5dce85b48a5bda9fc..7252e349c357ffa8718def20e809d31fe67cf2da 100644 (file)
@@ -486,7 +486,7 @@ class RBDDriver(driver.VolumeDriver):
         _, pool, image, snapshot = self._parse_location(image_location)
         self._clone(volume, pool, image, snapshot)
         self._resize(volume)
-        return True
+        return {'provider_location': None}, True
 
     def _ensure_tmp_exists(self):
         tmp_dir = self.configuration.volume_tmp_dir
index 03e97fe63b9e46e8c840c61211425dca2b94a9ba..3a6a498134840a37c0b25d3e539263b277d91c71 100644 (file)
@@ -253,6 +253,7 @@ class ScalityDriver(driver.VolumeDriver):
         image service backend in use. The driver should use it
         to determine whether cloning is possible.
 
-        Returns a boolean indicating whether cloning occurred
+        Returns a dict of volume properties eg. provider_location,
+        boolean indicating whether cloning occurred
         """
-        return False
+        return None, False
index 7c8500797a9df73d769bc281d47b74fa0bc1d5e9..32ed8981b4cf79a72ef4a5f288d2eef638e57015 100644 (file)
@@ -185,7 +185,11 @@ class VolumeManager(manager.SchedulerDependentManager):
                                       {'bootable': True})
         else:
             # create the volume from an image
-            cloned = self.driver.clone_image(volume_ref, image_location)
+            # NOTE (singn): two params need to be returned
+            # dict containing provider_location for cloned volume
+            # and clone status
+            model_update, cloned = self.driver.clone_image(
+                volume_ref, image_location)
             if not cloned:
                 model_update = self.driver.create_volume(volume_ref)