#NEWLINE# def add_floating_ip( uid , pool_name , context ) : #NEWLINE# #INDENT# '\n    Adds an ip to an VM instance.\n\n    uid -- id of the VM.\n    pool_name -- name of the pool\n    context -- The os context.\n    ' #NEWLINE# vm_instance = vm . get_vm ( uid , context ) #NEWLINE# tmp = NETWORK_API . get_instance_nw_info ( context , vm_instance ) [ 0 ] #NEWLINE# fixed_ip = tmp . fixed_ips ( ) [ 0 ] [ 'address' ] #NEWLINE# float_address = NETWORK_API . allocate_floating_ip ( context , pool_name ) #NEWLINE# try : #NEWLINE# #INDENT# address = fixed_ip #NEWLINE# NETWORK_API . associate_floating_ip ( context , vm_instance , float_address , address ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# raise AttributeError ( e . message ) #NEWLINE# #UNINDENT# return float_address