Merge "Add tests for multiattach check in cinder.objects"
This commit is contained in:
commit
f3543cff0e
@ -567,6 +567,9 @@ class Volume(cleanable.CinderCleanableObject, base.CinderObject,
|
||||
def is_replicated(self):
|
||||
return self.volume_type and self.volume_type.is_replicated()
|
||||
|
||||
def is_multiattach(self):
|
||||
return self.volume_type and self.volume_type.is_multiattach()
|
||||
|
||||
|
||||
@base.CinderObjectRegistry.register
|
||||
class VolumeList(base.ObjectListBase, base.CinderObject):
|
||||
|
@ -165,6 +165,9 @@ class VolumeType(base.CinderPersistentObject, base.CinderObject,
|
||||
def is_replicated(self):
|
||||
return utils.is_replicated_spec(self.extra_specs)
|
||||
|
||||
def is_multiattach(self):
|
||||
return utils.is_multiattach_spec(self.extra_specs)
|
||||
|
||||
|
||||
@base.CinderObjectRegistry.register
|
||||
class VolumeTypeList(base.ObjectListBase, base.CinderObject):
|
||||
|
@ -227,6 +227,18 @@ class TestVolumeType(test_objects.BaseObjectsTestCase):
|
||||
self.context, extra_specs={'replication_enabled': not_enabled})
|
||||
self.assertFalse(volume_type.is_replicated())
|
||||
|
||||
@ddt.data('<is> False', '<is> false', '<is> f')
|
||||
def test_is_multiattach_specs_false(self, false):
|
||||
volume_type = fake_volume.fake_volume_type_obj(
|
||||
self.context, extra_specs={'multiattach': false})
|
||||
self.assertFalse(volume_type.is_multiattach())
|
||||
|
||||
@ddt.data('<is> True', '<is> True')
|
||||
def test_is_multiattach_specs_true(self, true):
|
||||
volume_type = fake_volume.fake_volume_type_obj(
|
||||
self.context, extra_specs={'multiattach': true})
|
||||
self.assertTrue(volume_type.is_multiattach())
|
||||
|
||||
|
||||
class TestVolumeTypeList(test_objects.BaseObjectsTestCase):
|
||||
@mock.patch('cinder.volume.volume_types.get_all_types')
|
||||
|
@ -967,6 +967,11 @@ def is_replicated_spec(extra_specs):
|
||||
is_replicated_str(extra_specs.get('replication_enabled')))
|
||||
|
||||
|
||||
def is_multiattach_spec(extra_specs):
|
||||
return (extra_specs and
|
||||
is_replicated_str(extra_specs.get('multiattach')))
|
||||
|
||||
|
||||
def group_get_by_id(group_id):
|
||||
ctxt = context.get_admin_context()
|
||||
group = db.group_get(ctxt, group_id)
|
||||
|
Loading…
Reference in New Issue
Block a user