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
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
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):