]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Delete unused codes in rbd.retype
authorLisaLi <xiaoyan.li@intel.com>
Thu, 12 Nov 2015 06:08:11 +0000 (06:08 +0000)
committerlisali <xiaoyan.li@intel.com>
Wed, 2 Dec 2015 02:46:47 +0000 (10:46 +0800)
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
cinder/volume/drivers/rbd.py

index bb60f4aa81cda77c9803d5066ec8f04c846b1637..c92c984ccb4c2ead875477bfe6d512a2a5099b25 100644 (file)
@@ -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
index 3711c08d9f8afa0662fb53ad7d01be854ef71857..ce239962791deb7b2544afff5be41bb6a321c991 100644 (file)
@@ -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):