summaryrefslogtreecommitdiff
path: root/nova/tests/fixtures
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-08-20 15:24:04 +0000
committerGerrit Code Review <review@openstack.org>2021-08-20 15:24:04 +0000
commitdc26565b377fd6c1e80a5c541f748f99bb73ab2f (patch)
treea6496301f3528f485346366b4512de5df23c2de9 /nova/tests/fixtures
parentd62b6b91db195d2f92158be0ecf6e440d1c3bb43 (diff)
parentd4cc10d7bbc1448ae8a38da63ebe2ee8c3243d30 (diff)
downloadnova-dc26565b377fd6c1e80a5c541f748f99bb73ab2f.tar.gz
Merge "fup: Make connection_info returned by CinderFixture unique per attachment"
Diffstat (limited to 'nova/tests/fixtures')
-rw-r--r--nova/tests/fixtures/cinder.py34
1 files changed, 22 insertions, 12 deletions
diff --git a/nova/tests/fixtures/cinder.py b/nova/tests/fixtures/cinder.py
index 33b933f9b4..8bb7b4379d 100644
--- a/nova/tests/fixtures/cinder.py
+++ b/nova/tests/fixtures/cinder.py
@@ -49,8 +49,7 @@ class CinderFixture(fixtures.Fixture):
# This represents a bootable volume backed by iSCSI storage.
ISCSI_BACKED_VOL = uuids.iscsi_backed_volume
- # Dict of connection_info for the above volumes key'd by the volume id
- # TODO(lyarwood): Make this unique and tracked per attachment somehow.
+ # Dict of connection_info for the above volumes keyed by the volume id
VOLUME_CONNECTION_INFO = {
uuids.iscsi_backed_volume: {
'driver_volume_type': 'iscsi',
@@ -209,6 +208,21 @@ class CinderFixture(fixtures.Fixture):
raise exception.VolumeAttachmentNotFound(
attachment_id=attachment_id)
+ def _find_connection_info(volume_id, attachment_id):
+ """Find the connection_info associated with an attachment
+
+ :returns: A connection_info dict based on a deepcopy associated
+ with the volume_id but containing the attachment_id, making it
+ unique for the attachment.
+ """
+ connection_info = copy.deepcopy(
+ self.VOLUME_CONNECTION_INFO.get(
+ volume_id, self.VOLUME_CONNECTION_INFO.get('fake')
+ )
+ )
+ connection_info['data']['attachment_id'] = attachment_id
+ return connection_info
+
def fake_attachment_create(
_self, context, volume_id, instance_uuid, connector=None,
mountpoint=None,
@@ -220,10 +234,8 @@ class CinderFixture(fixtures.Fixture):
attachment = {'id': attachment_id}
if connector:
- connection_info = self.VOLUME_CONNECTION_INFO.get(
- volume_id, self.VOLUME_CONNECTION_INFO.get('fake'))
- attachment['connection_info'] = copy.deepcopy(connection_info)
-
+ attachment['connection_info'] = _find_connection_info(
+ volume_id, attachment_id)
self.volume_to_attachment[volume_id][attachment_id] = {
'id': attachment_id,
'instance_uuid': instance_uuid,
@@ -268,9 +280,8 @@ class CinderFixture(fixtures.Fixture):
LOG.info('Updating volume attachment: %s', attachment_id)
attachment_ref = {
'id': attachment_id,
- 'connection_info': copy.deepcopy(
- self.VOLUME_CONNECTION_INFO.get(
- volume_id, self.VOLUME_CONNECTION_INFO.get('fake')))
+ 'connection_info': _find_connection_info(
+ volume_id, attachment_id)
}
if attachment_id == self.SWAP_ERR_ATTACH_ID:
# This intentionally triggers a TypeError for the
@@ -283,9 +294,8 @@ class CinderFixture(fixtures.Fixture):
volume_id, _, _ = _find_attachment(attachment_id)
attachment_ref = {
'id': attachment_id,
- 'connection_info': copy.deepcopy(
- self.VOLUME_CONNECTION_INFO.get(
- volume_id, self.VOLUME_CONNECTION_INFO.get('fake')))
+ 'connection_info': _find_connection_info(
+ volume_id, attachment_id)
}
return attachment_ref