#NEWLINE# @ mock . patch ( 'ec2api.api.instance.security_group_api' ) #NEWLINE# @ mock . patch ( 'ec2api.api.instance.network_interface_api' ) #NEWLINE# def test_get_metadata_integral( self , network_interface_api , security_group_api ) : #NEWLINE# #INDENT# fake_context = base . create_context ( is_os_admin = True ) #NEWLINE# self . set_mock_db_items ( fakes . DB_INSTANCE_1 , fakes . DB_INSTANCE_2 , fakes . DB_NETWORK_INTERFACE_1 , fakes . DB_NETWORK_INTERFACE_2 , fakes . DB_IMAGE_1 , fakes . DB_IMAGE_2 , fakes . DB_IMAGE_ARI_1 , fakes . DB_IMAGE_AKI_1 , fakes . DB_VOLUME_1 , fakes . DB_VOLUME_2 , fakes . DB_VOLUME_3 ) #NEWLINE# self . nova_admin . servers . list . return_value = [ fakes . OSInstance_full ( fakes . OS_INSTANCE_1 ) , fakes . OSInstance_full ( fakes . OS_INSTANCE_2 ) ] #NEWLINE# self . nova_admin . servers . get . side_effect = tools . get_by_1st_arg_getter ( { #NEWLINE# #INDENT# fakes . ID_OS_INSTANCE_1 : fakes . OSInstance_full ( fakes . OS_INSTANCE_1 ) , #NEWLINE# fakes . ID_OS_INSTANCE_2 : fakes . OSInstance_full ( fakes . OS_INSTANCE_2 ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . nova_admin . keypairs . _get . return_value = fakes . NovaKeyPair ( fakes . OS_KEY_PAIR ) #NEWLINE# self . cinder . volumes . list . return_value = [ fakes . OSVolume ( fakes . OS_VOLUME_1 ) , fakes . OSVolume ( fakes . OS_VOLUME_2 ) , fakes . OSVolume ( fakes . OS_VOLUME_3 ) ] #NEWLINE# network_interface_api . describe_network_interfaces . side_effect = ( lambda * args , **kwargs : copy . deepcopy ( { #NEWLINE# #INDENT# 'networkInterfaceSet' : [ fakes . EC2_NETWORK_INTERFACE_1 , fakes . EC2_NETWORK_INTERFACE_2 ] , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# security_group_api . describe_security_groups . return_value = { #NEWLINE# #INDENT# 'securityGroupInfo' : [ fakes . EC2_SECURITY_GROUP_1 , fakes . EC2_SECURITY_GROUP_3 ] , #NEWLINE# #UNINDENT# } #NEWLINE# retval = api . get_metadata_item ( fake_context , [ 'latest' , 'meta-data' , 'instance-id' ] , fakes . ID_OS_INSTANCE_1 , fakes . IP_NETWORK_INTERFACE_2 ) #NEWLINE# self . assertEqual ( fakes . ID_EC2_INSTANCE_1 , retval ) #NEWLINE# retval = api . get_metadata_item ( fake_context , [ 'latest' , 'meta-data' , 'instance-id' ] , fakes . ID_OS_INSTANCE_2 , '10.200.1.15' ) #NEWLINE# self . assertEqual ( fakes . ID_EC2_INSTANCE_2 , self )