#NEWLINE# def record_port_status_changed( self , port , current_port_status , previous_port_status , initiator ) : #NEWLINE# #INDENT# 'Determine if nova needs to be notified due to port status change.\n        ' #NEWLINE# port . _notify_event = None #NEWLINE# if ( not port . device_id ) : #NEWLINE# #INDENT# LOG . debug ( 'device_id is not set on port yet.' ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( not port . id ) : #NEWLINE# #INDENT# LOG . warning ( _LW ( 'Port ID not set! Nova will not be notified of port status change.' ) ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( not self . _is_compute_port ( port ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( ( previous_port_status == constants . PORT_STATUS_ACTIVE ) and ( current_port_status == constants . PORT_STATUS_DOWN ) ) : #NEWLINE# #INDENT# event_name = VIF_UNPLUGGED #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( previous_port_status in [ sql_attr . NO_VALUE , constants . PORT_STATUS_DOWN , constants . PORT_STATUS_BUILD ] ) and ( current_port_status in [ constants . PORT_STATUS_ACTIVE , constants . PORT_STATUS_ERROR ] ) ) : #NEWLINE# #INDENT# event_name = VIF_PLUGGED #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# LOG . debug ( 'Ignoring state change previous_port_status: %(pre_status)s current_port_status: %(cur_status)s port_id %(id)s' , { #NEWLINE# #INDENT# 'pre_status' : previous_port_status , #NEWLINE# 'cur_status' : current_port_status , #NEWLINE# 'id' : port . id , #NEWLINE# #UNINDENT# } ) #NEWLINE# return #NEWLINE# #UNINDENT# #UNINDENT# port . _notify_event = { #NEWLINE# #INDENT# 'server_uuid' : port . device_id , #NEWLINE# 'name' : event_name , #NEWLINE# 'status' : NEUTRON_NOVA_EVENT_STATUS_MAP . get ( current_port_status ) , #NEWLINE# 'tag' : port . id , #NEWLINE# #UNINDENT# }