From 2dc4335338c3de8949c4a501d49f7cbe0315207e Mon Sep 17 00:00:00 2001 From: LisaLi Date: Fri, 13 Nov 2015 02:09:03 +0000 Subject: [PATCH] Add retype in lvm driver During retype operation, it makes sure that volume types have same encryption, and same backend qos before moving on. In lvm driver, no extra_spec and qos are used. As a result, if retype a volume to same host, it just needs to return True, and no needs to migrate the volume. Change-Id: Id6273046424190ee3e36dabd4bfcf69466bf23ad Closes-Bug: #1515840 --- cinder/tests/unit/test_volume.py | 9 +++++++++ cinder/volume/drivers/lvm.py | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/cinder/tests/unit/test_volume.py b/cinder/tests/unit/test_volume.py index 112f436a3..12477fe3c 100644 --- a/cinder/tests/unit/test_volume.py +++ b/cinder/tests/unit/test_volume.py @@ -7104,6 +7104,15 @@ class LVMVolumeDriverTestCase(DriverTestCase): mock_volume_get.assert_called_with(self.context, vol['id']) + def test_retype_volume(self): + vol = tests_utils.create_volume(self.context) + new_type = 'fake' + diff = {} + host = 'fake_host' + retyped = self.volume.driver.retype(self.context, vol, new_type, + diff, host) + self.assertTrue(retyped) + def test_update_migrated_volume(self): fake_volume_id = 'vol1' fake_new_volume_id = 'vol2' diff --git a/cinder/volume/drivers/lvm.py b/cinder/volume/drivers/lvm.py index 2c163788f..0c1d2d1a2 100644 --- a/cinder/volume/drivers/lvm.py +++ b/cinder/volume/drivers/lvm.py @@ -625,6 +625,14 @@ class LVMVolumeDriver(driver.VolumeDriver): existing_ref = {"source-name": existing_ref} return self.manage_existing(snapshot_temp, existing_ref) + def retype(self, context, volume, new_type, diff, host): + """Retypes a volume, allow QoS and extra_specs change.""" + + LOG.debug('LVM retype called for volume %s. No action ' + 'required for LVM volumes.', + volume['id']) + return True + def migrate_volume(self, ctxt, volume, host, thin=False, mirror_count=0): """Optimize the migration if the destination is on the same server. -- 2.45.2