From 033d21f6f0a93ab664d7615e2c71486c7fbce03a Mon Sep 17 00:00:00 2001 From: Avishay Traeger Date: Thu, 7 Feb 2013 11:11:03 +0200 Subject: [PATCH] Move create_cloned_volume() to LVMVolumeDriver. 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 | 15 +-------------- cinder/volume/drivers/lvm.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 5c5677be4..8b63424b0 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -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.""" diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index d3dc9a228..51df63546 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -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 -- 2.45.2