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
This commit is contained in:
LisaLi
2015-11-12 06:08:11 +00:00
committed by lisali
parent 6a942ba647
commit 1e3213591d
2 changed files with 25 additions and 35 deletions
+18 -14
View 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
+7 -21
View 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):