@@ -2438,8 +2438,7 @@ class CinderFixture(fixtures.Fixture):
2438
2438
# This represents a bootable volume backed by iSCSI storage.
2439
2439
ISCSI_BACKED_VOL = uuidsentinel .iscsi_backed_volume
2440
2440
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
2443
2442
VOLUME_CONNECTION_INFO = {
2444
2443
uuidsentinel .iscsi_backed_volume : {
2445
2444
'driver_volume_type' : 'iscsi' ,
@@ -2608,6 +2607,21 @@ def _find_attachment(attachment_id):
2608
2607
raise exception .VolumeAttachmentNotFound (
2609
2608
attachment_id = attachment_id )
2610
2609
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
+
2611
2625
def fake_attachment_create (_self , context , volume_id , instance_uuid ,
2612
2626
connector = None , mountpoint = None ):
2613
2627
attachment_id = uuidutils .generate_uuid ()
@@ -2617,10 +2631,8 @@ def fake_attachment_create(_self, context, volume_id, instance_uuid,
2617
2631
attachment = {'id' : attachment_id }
2618
2632
2619
2633
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 )
2624
2636
self .volume_to_attachment [volume_id ][attachment_id ] = {
2625
2637
'id' : attachment_id ,
2626
2638
'instance_uuid' : instance_uuid ,
@@ -2658,9 +2670,8 @@ def fake_attachment_update(_self, context, attachment_id, connector,
2658
2670
LOG .info ('Updating volume attachment: %s' , attachment_id )
2659
2671
attachment_ref = {
2660
2672
'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 )
2664
2675
}
2665
2676
if attachment_id == self .SWAP_ERR_ATTACH_ID :
2666
2677
# This intentionally triggers a TypeError for the
@@ -2674,9 +2685,8 @@ def fake_attachment_get(_self, context, attachment_id):
2674
2685
2675
2686
attachment_ref = {
2676
2687
'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 )
2680
2690
}
2681
2691
return attachment_ref
2682
2692
0 commit comments