Skip to content

Commit

Permalink
Merge "Flatten Volume from Snapshot"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jun 14, 2013
2 parents 3a8a58d + 997c619 commit 0a26b70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cinder/volume/drivers/rbd.py
Expand Up @@ -52,6 +52,10 @@
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'
Expand Down Expand Up @@ -254,6 +258,12 @@ def create_volume(self, volume):
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,
Expand All @@ -276,6 +286,8 @@ def create_volume_from_snapshot(self, volume, snapshot):
"""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)

Expand Down
2 changes: 2 additions & 0 deletions etc/cinder/cinder.conf.sample
Expand Up @@ -1083,6 +1083,8 @@
# 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
Expand Down

0 comments on commit 0a26b70

Please sign in to comment.