#NEWLINE# def test_attach_when_foreign_device_has_next_device( self ) : #NEWLINE# #INDENT# '\n        ``attach_volume`` does not attempt to use device paths that are already\n        assigned to volumes that have been attached outside of Flocker.\n        ' #NEWLINE# try : #NEWLINE# #INDENT# config = get_blockdevice_config ( ) #NEWLINE# #UNINDENT# except InvalidConfig as e : #NEWLINE# #INDENT# self . skipTest ( str ( e ) ) #NEWLINE# #UNINDENT# dataset_id = uuid4 ( ) #NEWLINE# ec2_client = get_ec2_client_for_test ( config ) #NEWLINE# meta_client = ec2_client . connection . meta . client #NEWLINE# requested_volume = meta_client . create_volume ( Size = 1 , AvailabilityZone = ec2_client . zone ) #NEWLINE# created_volume = ec2_client . connection . Volume ( requested_volume [ 'VolumeId' ] ) #NEWLINE# def clean_volume( volume ) : #NEWLINE# #INDENT# volume . detach_from_instance ( ) #NEWLINE# _wait_for_volume_state_change ( VolumeOperations . DETACH , volume ) #NEWLINE# volume . delete ( ) #NEWLINE# #UNINDENT# self . addCleanup ( clean_volume , created_volume ) #NEWLINE# _wait_for_volume_state_change ( VolumeOperations . CREATE , created_volume ) #NEWLINE# instance_id = self . api . compute_instance_id ( ) #NEWLINE# device_name = _next_device ( ) . replace ( '/sd' , '/xvd' ) #NEWLINE# self . api . _attach_ebs_volume ( created_volume . id , self , device_name ) #NEWLINE# _wait_for_volume_state_change ( VolumeOperations . ATTACH , created_volume ) #NEWLINE# blockdevice_volume = self . api . create_volume ( dataset_id = dataset_id , size = ONE_GIB ) #NEWLINE# flocker_volume = ec2_client . connection . Volume ( blockdevice_volume . blockdevice_id ) #NEWLINE# self . addCleanup ( clean_volume , flocker_volume ) #NEWLINE# self . api . attach_volume ( blockdevice_volume . blockdevice_id , instance_id )