From: Arne Wiebalck Date: Thu, 20 Nov 2014 07:36:34 +0000 (+0100) Subject: Add limited retype support for rbd X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=2fb9b07ea6646609e4bdf9b08613b3c1d587378e;p=openstack-build%2Fcinder-build.git Add limited retype support for rbd This patch enables limited retype support for rbd. In addition to basic retyping between volume types that only differ in their name, retyping between volume types that imply a change of the qos_specs are supported. This hence allows to adapt the quality-of-service settings of a volume after its creation. All other changes, such as host migration, change of encryption or changes of settings as defined by the extra_specs are not supported by this commit and left for later patches. Implements: blueprint ceph-rbd-support-retype Change-Id: Ib9edf83eb3ade1e6b2dcf1121a16a6f2e68753e1 --- diff --git a/cinder/tests/test_rbd.py b/cinder/tests/test_rbd.py index 8c721b24f..f40409b46 100644 --- a/cinder/tests/test_rbd.py +++ b/cinder/tests/test_rbd.py @@ -736,6 +736,36 @@ class RBDTestCase(test.TestCase): self.mox.VerifyAll() + @common_mocks + def test_retype(self): + context = {} + diff = {'encryption': {}, + 'extra_specs': {}} + fake_volume = {'name': 'testvolume', + 'host': 'currenthost'} + fake_type = 'high-IOPS' + + # no support for migration + host = {'host': 'anotherhost'} + self.assertFalse(self.driver.retype(context, fake_volume, + fake_type, diff, host)) + host = {'host': 'currenthost'} + + # no support for changing encryption + diff['encryption'] = {'non-empty': 'non-empty'} + self.assertFalse(self.driver.retype(context, fake_volume, + fake_type, diff, host)) + diff['encryption'] = {} + + # no support for changing extra_specs + diff['extra_specs'] = {'non-empty': 'non-empty'} + self.assertFalse(self.driver.retype(context, fake_volume, + fake_type, diff, host)) + diff['extra_specs'] = {} + + self.assertTrue(self.driver.retype(context, fake_volume, + fake_type, diff, host)) + def test_rbd_volume_proxy_init(self): mock_driver = mock.Mock(name='driver') mock_driver._connect_to_rados.return_value = (None, None) diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py index 2ccbb0e35..3c7dda251 100644 --- a/cinder/volume/drivers/rbd.py +++ b/cinder/volume/drivers/rbd.py @@ -696,6 +696,31 @@ class RBDDriver(driver.VolumeDriver): raise exception.SnapshotIsBusy(snapshot_name=snap_name) volume.remove_snap(snap_name) + def retype(self, context, volume, new_type, diff, host): + """Retypes a volume, allows QoS change only.""" + LOG.debug('Retype volume request %(vol)s to be %(type)s ' + '(host: %(host)s), diff %(diff)s.', + { + 'vol': volume['name'], + 'type': new_type, + 'host': host, + 'diff': diff + }) + + if volume['host'] != host['host']: + LOG.error(_LE('Retype with host migration not supported')) + return False + + if diff['encryption']: + LOG.error(_LE('Retype of encryption type not supported')) + return False + + if diff['extra_specs']: + LOG.error(_LE('Retype of extra_specs not supported')) + return False + + return True + def ensure_export(self, context, volume): """Synchronously recreates an export for a logical volume.""" pass