#NEWLINE# def port_update_event( self , port_info ) : #NEWLINE# #INDENT# port = port_info . get ( 'port' ) #NEWLINE# if ( not vm ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# bhost_id = port . get ( 'binding:host_id' ) #NEWLINE# if ( not bhost_id ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# port_id = port . get ( 'id' ) #NEWLINE# LOG . debug ( 'port_update_event for %(port)s %(host)s.' , { #NEWLINE# #INDENT# 'port' : port_id , #NEWLINE# 'host' : bhost_id , #NEWLINE# #UNINDENT# } ) #NEWLINE# vm = self . get_vm ( port_id ) #NEWLINE# if ( not vm ) : #NEWLINE# #INDENT# LOG . error ( _LE ( 'port_update_event: port %s does not exist.' ) , port_id ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( vm . host == bhost_id ) : #NEWLINE# #INDENT# LOG . info ( _LI ( 'Port %(port)s update event is received but host %(host)s is the same.' ) , { #NEWLINE# #INDENT# 'port' : port_id , #NEWLINE# 'host' : vm . host , #NEWLINE# #UNINDENT# } ) #NEWLINE# return #NEWLINE# #UNINDENT# vm_info = self . _make_vm_info ( port , 'up' ) #NEWLINE# self . port [ port_id ] = vm_info #NEWLINE# LOG . debug ( 'port_update_event : %s' , vm_info ) #NEWLINE# if ( ( not vm . host ) and bhost_id ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . neutron_event . send_vm_info ( str ( bhost_id ) , str ( vm_info ) ) #NEWLINE# #UNINDENT# except ( rpc . MessagingTimeout , rpc . RPCException , rpc . RemoteError ) : #NEWLINE# #INDENT# LOG . error ( _LE ( 'Failed to send VM info to agent %s.' ) , bhost_id ) #NEWLINE# params = dict ( columns = dict ( host = bhost_id , instance_id = vm_info . get ( 'oui' ) . get ( 'vm_uuid' ) , name = vm_info . get ( 'oui' ) . get ( 'vm_name' ) , result = constants . CREATE_FAIL ) ) #NEWLINE# self . update_vm_db ( vm . port_id , ** params ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# params = dict ( columns = dict ( host = bhost_id , instance_id = vm_info . get ( 'oui' ) . get ( 'vm_uuid' ) , name = vm_info . get ( 'oui' ) . get ( 'vm_name' ) , result = constants . RESULT_SUCCESS ) ) #NEWLINE# self . update_vm_db ( vm . port_id , ** params ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( vm . host != bhost_id ) : #NEWLINE# #INDENT# LOG . debug ( 'Binding host for port %(port)s changedfrom %(host_p)s to %(host_n)s.This is live migration and currently it is not supported.' , { #NEWLINE# #INDENT# 'port' : port_id , #NEWLINE# 'host_p' : vm . host , #NEWLINE# 'host_n' : bhost_id , #NEWLINE# #UNINDENT# } )