Merge "Keep attach_mode as top-level field in _translate_attachment_ref"
This commit is contained in:
commit
6e4ab9714c
|
@ -4273,10 +4273,7 @@ class API(base.Base):
|
||||||
# nova.volume.cinder code translates it and puts the
|
# nova.volume.cinder code translates it and puts the
|
||||||
# attach_mode in the connection_info for some legacy
|
# attach_mode in the connection_info for some legacy
|
||||||
# reason...
|
# reason...
|
||||||
if attachment_record.get(
|
if attachment_record['attach_mode'] == 'rw':
|
||||||
'connection_info', {}).get(
|
|
||||||
# attachments are read/write by default
|
|
||||||
'attach_mode', 'rw') == 'rw':
|
|
||||||
count += 1
|
count += 1
|
||||||
except exception.VolumeAttachmentNotFound:
|
except exception.VolumeAttachmentNotFound:
|
||||||
# attachments are read/write by default so count it
|
# attachments are read/write by default so count it
|
||||||
|
|
|
@ -1010,7 +1010,7 @@ class SwapVolumeMultiattachTestCase(test.NoDBTestCase):
|
||||||
raise exception.VolumeNotFound(volume_id=volume_id)
|
raise exception.VolumeNotFound(volume_id=volume_id)
|
||||||
|
|
||||||
def fake_attachment_get(_context, attachment_id):
|
def fake_attachment_get(_context, attachment_id):
|
||||||
return {'connection_info': {'attach_mode': 'rw'}}
|
return {'attach_mode': 'rw'}
|
||||||
|
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
instance = fake_instance.fake_instance_obj(
|
instance = fake_instance.fake_instance_obj(
|
||||||
|
|
|
@ -2773,7 +2773,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||||
if attachment_id == uuids.attachment1:
|
if attachment_id == uuids.attachment1:
|
||||||
raise exception.VolumeAttachmentNotFound(
|
raise exception.VolumeAttachmentNotFound(
|
||||||
attachment_id=attachment_id)
|
attachment_id=attachment_id)
|
||||||
return {'connection_info': {'attach_mode': 'ro'}}
|
return {'attach_mode': 'ro'}
|
||||||
|
|
||||||
with mock.patch.object(self.compute_api.volume_api, 'attachment_get',
|
with mock.patch.object(self.compute_api.volume_api, 'attachment_get',
|
||||||
side_effect=fake_attachment_get) as mock_get:
|
side_effect=fake_attachment_get) as mock_get:
|
||||||
|
|
|
@ -408,8 +408,8 @@ class CinderApiTestCase(test.NoDBTestCase):
|
||||||
expected_attachment_ref = {
|
expected_attachment_ref = {
|
||||||
'id': uuids.attachment_id,
|
'id': uuids.attachment_id,
|
||||||
'volume_id': fake_attachment.volume_id,
|
'volume_id': fake_attachment.volume_id,
|
||||||
|
'attach_mode': 'rw',
|
||||||
'connection_info': {
|
'connection_info': {
|
||||||
'attach_mode': 'rw',
|
|
||||||
'attached_at': fake_attachment.attached_at,
|
'attached_at': fake_attachment.attached_at,
|
||||||
'data': {'foo': 'bar', 'target_lun': '1'},
|
'data': {'foo': 'bar', 'target_lun': '1'},
|
||||||
'detached_at': None,
|
'detached_at': None,
|
||||||
|
@ -438,8 +438,8 @@ class CinderApiTestCase(test.NoDBTestCase):
|
||||||
expected_attachment_ref = {
|
expected_attachment_ref = {
|
||||||
'id': uuids.attachment_id,
|
'id': uuids.attachment_id,
|
||||||
'volume_id': fake_attachment.volume_id,
|
'volume_id': fake_attachment.volume_id,
|
||||||
|
'attach_mode': 'rw',
|
||||||
'connection_info': {
|
'connection_info': {
|
||||||
'attach_mode': 'rw',
|
|
||||||
'attached_at': fake_attachment.attached_at,
|
'attached_at': fake_attachment.attached_at,
|
||||||
'data': {'foo': 'bar', 'target_lun': '1'},
|
'data': {'foo': 'bar', 'target_lun': '1'},
|
||||||
'detached_at': None,
|
'detached_at': None,
|
||||||
|
|
|
@ -373,8 +373,6 @@ def _translate_attachment_ref(attachment_ref):
|
||||||
translated_con_info['data'] = connection_info_data
|
translated_con_info['data'] = connection_info_data
|
||||||
translated_con_info['status'] = attachment_ref.pop('status', None)
|
translated_con_info['status'] = attachment_ref.pop('status', None)
|
||||||
translated_con_info['instance'] = attachment_ref.pop('instance', None)
|
translated_con_info['instance'] = attachment_ref.pop('instance', None)
|
||||||
translated_con_info['attach_mode'] = attachment_ref.pop('attach_mode',
|
|
||||||
None)
|
|
||||||
translated_con_info['attached_at'] = attachment_ref.pop('attached_at',
|
translated_con_info['attached_at'] = attachment_ref.pop('attached_at',
|
||||||
None)
|
None)
|
||||||
translated_con_info['detached_at'] = attachment_ref.pop('detached_at',
|
translated_con_info['detached_at'] = attachment_ref.pop('detached_at',
|
||||||
|
@ -382,7 +380,8 @@ def _translate_attachment_ref(attachment_ref):
|
||||||
|
|
||||||
# Now the catch all...
|
# Now the catch all...
|
||||||
for k, v in attachment_ref.items():
|
for k, v in attachment_ref.items():
|
||||||
if k != "id":
|
# Keep these as top-level fields on the attachment record.
|
||||||
|
if k not in ("id", "attach_mode"):
|
||||||
translated_con_info[k] = v
|
translated_con_info[k] = v
|
||||||
|
|
||||||
attachment_ref['connection_info'] = translated_con_info
|
attachment_ref['connection_info'] = translated_con_info
|
||||||
|
|
Loading…
Reference in New Issue