#NEWLINE# def _associate_floating_ip( self , context , floating_address , fixed_address , interface , instance_uuid ) : #NEWLINE# #INDENT# 'Performs db and driver calls to associate floating IP & fixed IP.' #NEWLINE# interface = ( CONF . public_interface or interface ) #NEWLINE# @ utils . synchronized ( six . text_type ( floating_address ) ) #NEWLINE# def do_associate( ) : #NEWLINE# #INDENT# floating = objects . FloatingIP . associate ( context , floating_address , fixed_address , self . host ) #NEWLINE# fixed = floating . fixed_ip #NEWLINE# if ( not fixed ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# self . l3driver . add_floating_ip ( floating_address , fixed_address , interface , fixed [ 'network' ] ) #NEWLINE# #UNINDENT# except processutils . ProcessExecutionError as e : #NEWLINE# #INDENT# with excutils . save_and_reraise_exception ( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# objects . FloatingIP . disassociate ( context , floating_address ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# LOG . warning ( _LW ( 'Failed to disassociated floating address: %s' ) , floating_address ) #NEWLINE# pass #NEWLINE# #UNINDENT# if ( 'Cannot find device' in six . text_type ( e ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# LOG . error ( _LE ( 'Interface %s not found' ) , interface ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# raise exception . NoFloatingIpInterface ( interface = interface ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# payload = dict ( project_id = context . project_id , instance_id = instance_uuid , floating_ip = floating_address ) #NEWLINE# self . notifier . info ( context , 'network.floating_ip.associate' , payload ) #NEWLINE# #UNINDENT# do_associate ( )