Merge "Handle multiattach attribute when managing volumes"

This commit is contained in:
Zuul 2018-08-27 18:16:33 +00:00 committed by Gerrit Code Review
commit c9cb469c6f
3 changed files with 33 additions and 1 deletions

View File

@ -38,7 +38,7 @@ class ManageVolumeFlowTestCase(test.TestCase):
self.counter = float(0)
def test_cast_manage_existing(self):
volume = fake_volume.fake_volume_type_obj(self.ctxt)
volume = fake_volume.fake_volume_obj(self.ctxt)
spec = {
'name': 'name',
@ -62,6 +62,28 @@ class ManageVolumeFlowTestCase(test.TestCase):
create_what.pop('volume_id')
task.execute(self.ctxt, **create_what)
def test_create_db_entry_task_with_multiattach(self):
fake_volume_type = fake_volume.fake_volume_type_obj(
self.ctxt, extra_specs={'multiattach': '<is> True'})
spec = {
'name': 'name',
'description': 'description',
'host': 'host',
'ref': 'ref',
'volume_type': fake_volume_type,
'metadata': {},
'availability_zone': 'availability_zone',
'bootable': 'bootable',
'volume_type_id': fake_volume_type.id,
'cluster_name': 'fake_cluster'
}
task = manage_existing.EntryCreateTask(fake_volume_api.FakeDb())
result = task.execute(self.ctxt, **spec)
self.assertTrue(result['volume_properties']['multiattach'])
@staticmethod
def _stub_volume_object_get(self):
volume = {

View File

@ -53,6 +53,11 @@ class EntryCreateTask(flow_utils.CinderTask):
volume_type = kwargs.pop('volume_type')
volume_type_id = volume_type['id'] if volume_type else None
multiattach = False
if volume_type and volume_type.get('extra_specs'):
multiattach = volume_type['extra_specs'].get(
'multiattach', '') == '<is> True'
volume_properties = {
'size': 0,
'user_id': context.user_id,
@ -68,6 +73,7 @@ class EntryCreateTask(flow_utils.CinderTask):
'volume_type_id': volume_type_id,
'metadata': kwargs.pop('metadata') or {},
'bootable': kwargs.pop('bootable'),
'multiattach': multiattach,
}
volume = objects.Volume(context=context, **volume_properties)

View File

@ -0,0 +1,4 @@
---
fixes:
- Now cinder will keep track of 'multiattach' attribute when managing
backend volumes.