]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add limited retype support for rbd
authorArne Wiebalck <Arne.Wiebalck@cern.ch>
Thu, 20 Nov 2014 07:36:34 +0000 (08:36 +0100)
committerMike Perez <thingee@gmail.com>
Tue, 25 Nov 2014 19:04:26 +0000 (11:04 -0800)
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

cinder/tests/test_rbd.py
cinder/volume/drivers/rbd.py

index 8c721b24f756343ebca5873a5e653053a56b2e74..f40409b464f9cff20ad1891e8ca9c5446e63eadb 100644 (file)
@@ -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)
index 2ccbb0e3525b605673dc98b3104f84ad248ea724..3c7dda251132b8e528a7b7c96a6f70cd50f8f149 100644 (file)
@@ -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