@@ -2438,8 +2438,7 @@ class CinderFixture(fixtures.Fixture):
24382438 # This represents a bootable volume backed by iSCSI storage.
24392439 ISCSI_BACKED_VOL = uuidsentinel .iscsi_backed_volume
24402440
2441- # Dict of connection_info for the above volumes key'd by the volume id
2442- # TODO(lyarwood): Make this unique and tracked per attachment somehow.
2441+ # Dict of connection_info for the above volumes keyed by the volume id
24432442 VOLUME_CONNECTION_INFO = {
24442443 uuidsentinel .iscsi_backed_volume : {
24452444 'driver_volume_type' : 'iscsi' ,
@@ -2608,6 +2607,21 @@ def _find_attachment(attachment_id):
26082607 raise exception .VolumeAttachmentNotFound (
26092608 attachment_id = attachment_id )
26102609
2610+ def _find_connection_info (volume_id , attachment_id ):
2611+ """Find the connection_info associated with an attachment
2612+
2613+ :returns: A connection_info dict based on a deepcopy associated
2614+ with the volume_id but containing the attachment_id, making it
2615+ unique for the attachment.
2616+ """
2617+ connection_info = copy .deepcopy (
2618+ self .VOLUME_CONNECTION_INFO .get (
2619+ volume_id , self .VOLUME_CONNECTION_INFO .get ('fake' )
2620+ )
2621+ )
2622+ connection_info ['data' ]['attachment_id' ] = attachment_id
2623+ return connection_info
2624+
26112625 def fake_attachment_create (_self , context , volume_id , instance_uuid ,
26122626 connector = None , mountpoint = None ):
26132627 attachment_id = uuidutils .generate_uuid ()
@@ -2617,10 +2631,8 @@ def fake_attachment_create(_self, context, volume_id, instance_uuid,
26172631 attachment = {'id' : attachment_id }
26182632
26192633 if connector :
2620- connection_info = self .VOLUME_CONNECTION_INFO .get (
2621- volume_id , self .VOLUME_CONNECTION_INFO .get ('fake' ))
2622- attachment ['connection_info' ] = copy .deepcopy (connection_info )
2623-
2634+ attachment ['connection_info' ] = _find_connection_info (
2635+ volume_id , attachment_id )
26242636 self .volume_to_attachment [volume_id ][attachment_id ] = {
26252637 'id' : attachment_id ,
26262638 'instance_uuid' : instance_uuid ,
@@ -2658,9 +2670,8 @@ def fake_attachment_update(_self, context, attachment_id, connector,
26582670 LOG .info ('Updating volume attachment: %s' , attachment_id )
26592671 attachment_ref = {
26602672 'id' : attachment_id ,
2661- 'connection_info' : copy .deepcopy (
2662- self .VOLUME_CONNECTION_INFO .get (
2663- volume_id , self .VOLUME_CONNECTION_INFO .get ('fake' )))
2673+ 'connection_info' : _find_connection_info (
2674+ volume_id , attachment_id )
26642675 }
26652676 if attachment_id == self .SWAP_ERR_ATTACH_ID :
26662677 # This intentionally triggers a TypeError for the
@@ -2674,9 +2685,8 @@ def fake_attachment_get(_self, context, attachment_id):
26742685
26752686 attachment_ref = {
26762687 'id' : attachment_id ,
2677- 'connection_info' : copy .deepcopy (
2678- self .VOLUME_CONNECTION_INFO .get (
2679- volume_id , self .VOLUME_CONNECTION_INFO .get ('fake' )))
2688+ 'connection_info' : _find_connection_info (
2689+ volume_id , attachment_id )
26802690 }
26812691 return attachment_ref
26822692
0 commit comments