From 1e3213591d6a518049d1ee94a308fb37efb6e383 Mon Sep 17 00:00:00 2001 From: LisaLi Date: Thu, 12 Nov 2015 06:08:11 +0000 Subject: [PATCH] Delete unused codes in rbd.retype Before rbd.retype is called, encryption and host have been checked so that encryptions are different and host are same. Meanwhile, as extra_spec is not used during the rbd driver. As a result, even if they are different rbd.retype can still return True which means no need to do further migration. Change-Id: Id025a51631676389203b8e3892a5826c834105ca Closes-Bug: #1515493 Closes-Bug: #1514775 --- cinder/tests/unit/test_rbd.py | 32 ++++++++++++++++++-------------- cinder/volume/drivers/rbd.py | 30 ++++++++---------------------- 2 files changed, 26 insertions(+), 36 deletions(-) diff --git a/cinder/tests/unit/test_rbd.py b/cinder/tests/unit/test_rbd.py index bb60f4aa8..c92c984cc 100644 --- a/cinder/tests/unit/test_rbd.py +++ b/cinder/tests/unit/test_rbd.py @@ -29,6 +29,7 @@ from cinder import exception from cinder.i18n import _ from cinder.image import image_utils from cinder import test +from cinder.tests.unit import fake_volume from cinder.tests.unit.image import fake as fake_image from cinder.tests.unit import test_volume from cinder.tests.unit import utils @@ -839,29 +840,32 @@ class RBDTestCase(test.TestCase): context = {} diff = {'encryption': {}, 'extra_specs': {}} - fake_volume = {'name': 'testvolume', - 'host': 'currenthost'} + updates = {'name': 'testvolume', + 'host': 'currenthost', + 'id': 'fakeid'} fake_type = 'high-IOPS' + volume = fake_volume.fake_volume_obj(context, **updates) - # no support for migration - host = {'host': 'anotherhost'} - self.assertFalse(self.driver.retype(context, fake_volume, - fake_type, diff, host)) + # The hosts have been checked same before rbd.retype + # is called. + # RBD doesn't support multiple pools in a driver. host = {'host': 'currenthost'} + self.assertTrue(self.driver.retype(context, volume, + fake_type, diff, host)) - # no support for changing encryption - diff['encryption'] = {'non-empty': 'non-empty'} - self.assertFalse(self.driver.retype(context, fake_volume, - fake_type, diff, host)) + # The encryptions have been checked as same before rbd.retype + # is called. diff['encryption'] = {} + self.assertTrue(self.driver.retype(context, volume, + fake_type, diff, host)) - # no support for changing extra_specs + # extra_specs changes are supported. diff['extra_specs'] = {'non-empty': 'non-empty'} - self.assertFalse(self.driver.retype(context, fake_volume, - fake_type, diff, host)) + self.assertTrue(self.driver.retype(context, volume, + fake_type, diff, host)) diff['extra_specs'] = {} - self.assertTrue(self.driver.retype(context, fake_volume, + self.assertTrue(self.driver.retype(context, volume, fake_type, diff, host)) @common_mocks diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py index 3711c08d9..ce2399627 100644 --- a/cinder/volume/drivers/rbd.py +++ b/cinder/volume/drivers/rbd.py @@ -763,28 +763,14 @@ class RBDDriver(driver.TransferVD, driver.ExtendVD, 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 - + """Retypes a volume, allow Qos and extra_specs change.""" + + # No need to check encryption, extra_specs and Qos here as: + # encryptions have been checked as same. + # extra_specs are not used in the driver. + # Qos settings are not used in the driver. + LOG.debug('RBD retype called for volume %s. No action ' + 'required for RBD volumes.', volume.id) return True def ensure_export(self, context, volume): -- 2.45.2