Merge "Keep attach_mode as top-level field in _translate_attachment_ref"

This commit is contained in:
Zuul 2019-05-31 00:56:13 +00:00 committed by Gerrit Code Review
commit 6e4ab9714c
5 changed files with 7 additions and 11 deletions

View File

@ -4273,10 +4273,7 @@ class API(base.Base):
# nova.volume.cinder code translates it and puts the
# attach_mode in the connection_info for some legacy
# reason...
if attachment_record.get(
'connection_info', {}).get(
# attachments are read/write by default
'attach_mode', 'rw') == 'rw':
if attachment_record['attach_mode'] == 'rw':
count += 1
except exception.VolumeAttachmentNotFound:
# attachments are read/write by default so count it

View File

@ -1010,7 +1010,7 @@ class SwapVolumeMultiattachTestCase(test.NoDBTestCase):
raise exception.VolumeNotFound(volume_id=volume_id)
def fake_attachment_get(_context, attachment_id):
return {'connection_info': {'attach_mode': 'rw'}}
return {'attach_mode': 'rw'}
ctxt = context.get_admin_context()
instance = fake_instance.fake_instance_obj(

View File

@ -2773,7 +2773,7 @@ class _ComputeAPIUnitTestMixIn(object):
if attachment_id == uuids.attachment1:
raise exception.VolumeAttachmentNotFound(
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',
side_effect=fake_attachment_get) as mock_get:

View File

@ -408,8 +408,8 @@ class CinderApiTestCase(test.NoDBTestCase):
expected_attachment_ref = {
'id': uuids.attachment_id,
'volume_id': fake_attachment.volume_id,
'connection_info': {
'attach_mode': 'rw',
'connection_info': {
'attached_at': fake_attachment.attached_at,
'data': {'foo': 'bar', 'target_lun': '1'},
'detached_at': None,
@ -438,8 +438,8 @@ class CinderApiTestCase(test.NoDBTestCase):
expected_attachment_ref = {
'id': uuids.attachment_id,
'volume_id': fake_attachment.volume_id,
'connection_info': {
'attach_mode': 'rw',
'connection_info': {
'attached_at': fake_attachment.attached_at,
'data': {'foo': 'bar', 'target_lun': '1'},
'detached_at': None,

View File

@ -373,8 +373,6 @@ def _translate_attachment_ref(attachment_ref):
translated_con_info['data'] = connection_info_data
translated_con_info['status'] = attachment_ref.pop('status', 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',
None)
translated_con_info['detached_at'] = attachment_ref.pop('detached_at',
@ -382,7 +380,8 @@ def _translate_attachment_ref(attachment_ref):
# Now the catch all...
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
attachment_ref['connection_info'] = translated_con_info