#NEWLINE# @ testtools . skipUnless ( CONF . aws . image_id , 'image id is not defined' ) #NEWLINE# def test_attach_network_interface( self ) : #NEWLINE# #INDENT# data = self . client . create_network_interface ( SubnetId = self . subnet_id ) #NEWLINE# ni_id = data [ 'NetworkInterface' ] [ 'NetworkInterfaceId' ] #NEWLINE# self . addResourceCleanUp ( self . client . delete_network_interface , NetworkInterfaceId = ni_id ) #NEWLINE# ni = data [ 'NetworkInterface' ] #NEWLINE# address = ni . get ( 'PrivateIpAddress' ) #NEWLINE# self . assertIsNotNone ( address ) #NEWLINE# self . get_network_interface_waiter ( ) . wait_available ( ni_id ) #NEWLINE# instance_id = self . run_instance ( SubnetId = self . subnet_id ) #NEWLINE# kwargs = { #NEWLINE# #INDENT# 'DeviceIndex' : 0 , #NEWLINE# 'InstanceId' : instance_id , #NEWLINE# 'NetworkInterfaceId' : ni_id , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertRaises ( 'InvalidParameterValue' , self . client . attach_network_interface , ** kwargs ) #NEWLINE# kwargs = { #NEWLINE# #INDENT# 'DeviceIndex' : 2 , #NEWLINE# 'InstanceId' : instance_id , #NEWLINE# 'NetworkInterfaceId' : ni_id , #NEWLINE# #UNINDENT# } #NEWLINE# data = self . client . attach_network_interface ( * [ ] , ** kwargs ) #NEWLINE# attachment_id = data [ 'AttachmentId' ] #NEWLINE# instance = self . get_instance ( instance_id ) #NEWLINE# nis = instance . get ( 'NetworkInterfaces' , [ ] ) #NEWLINE# self . assertEqual ( 2 , len ( nis ) ) #NEWLINE# ids = [ nis [ 0 ] [ 'Attachment' ] [ 'AttachmentId' ] , nis [ 1 ] [ 'Attachment' ] [ 'AttachmentId' ] ] #NEWLINE# self . assertIn ( attachment_id , ids ) #NEWLINE# self . assertRaises ( 'InvalidParameterValue' , self . client . delete_network_interface , NetworkInterfaceId = ni_id ) #NEWLINE# self . client . detach_network_interface ( AttachmentId = attachment_id ) #NEWLINE# self . client . terminate_instances ( InstanceIds = [ instance_id ] ) #NEWLINE# self . get_instance_waiter ( ) . wait_delete ( instance_id )