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

changes/20/576020/34
Zuul 4 years ago committed by Gerrit Code Review
commit 6e4ab9714c
  1. 5
      nova/compute/api.py
  2. 2
      nova/tests/unit/api/openstack/compute/test_volumes.py
  3. 2
      nova/tests/unit/compute/test_compute_api.py
  4. 4
      nova/tests/unit/volume/test_cinder.py
  5. 5
      nova/volume/cinder.py

@ -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

@ -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(

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

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

@ -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

Loading…
Cancel
Save