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
This commit is contained in:
parent
fa8d88b6e1
commit
2fb9b07ea6
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user