]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Flatten Volume from Snapshot
authorMandell Degerness <mdegerne@gmail.com>
Mon, 10 Jun 2013 22:02:28 +0000 (22:02 +0000)
committerMandell Degerness <mdegerne@gmail.com>
Thu, 13 Jun 2013 23:37:13 +0000 (23:37 +0000)
Implements: blueprint flatten-volume-from-snapshot

Change-Id: I77b0a9bf8cfbe4881a75909d2749d0c3f17561c9

cinder/volume/drivers/rbd.py
etc/cinder/cinder.conf.sample

index 024ea4cd735613a1c512302bce63789a794015a0..3ee97b30eb8064da120a91822b97ce5349b82fa6 100644 (file)
@@ -52,6 +52,10 @@ rbd_opts = [
     cfg.StrOpt('rbd_ceph_conf',
                default='',  # default determined by librados
                help='path to the ceph configuration file to use'),
+    cfg.BoolOpt('rbd_flatten_volume_from_snapshot',
+                default=False,
+                help='flatten volumes created from snapshots to remove '
+                     'dependency'),
     cfg.StrOpt('rbd_secret_uuid',
                default=None,
                help='the libvirt uuid of the secret for the rbd_user'
@@ -254,6 +258,12 @@ class RBDDriver(driver.VolumeDriver):
                                   old_format=old_format,
                                   features=features)
 
+    def _flatten(self, pool, volume_name):
+        LOG.debug(_('flattening %(pool)s/%(img)s') %
+                  dict(pool=pool, img=volume_name))
+        with RBDVolumeProxy(self, volume_name, pool) as vol:
+            vol.flatten()
+
     def _clone(self, volume, src_pool, src_image, src_snap):
         LOG.debug(_('cloning %(pool)s/%(img)s@%(snap)s to %(dst)s') %
                   dict(pool=src_pool, img=src_image, snap=src_snap,
@@ -276,6 +286,8 @@ class RBDDriver(driver.VolumeDriver):
         """Creates a volume from a snapshot."""
         self._clone(volume, self.configuration.rbd_pool,
                     snapshot['volume_name'], snapshot['name'])
+        if self.configuration.rbd_flatten_volume_from_snapshot:
+            self._flatten(self.configuration.rbd_pool, volume['name'])
         if int(volume['size']):
             self._resize(volume)
 
index 18d5b1e6c93b1a1d96d374a9917b96450a6ef5c9..871818ca383b9484eb9b0cf9cffb76f3a4cbade0 100644 (file)
 # does not write them directly to the volume (string value)
 #volume_tmp_dir=<None>
 
+# Flatten images created from snapshots (to remove dependency)
+#rbd_flatten_volume_from_snapshot=False
 
 #
 # Options defined in cinder.volume.drivers.san.hp.hp_3par_common