#NEWLINE# def create_ha_port_and_bind( self , plugin , context , router_id , tenant_id , agent ) : #NEWLINE# #INDENT# 'Creates and binds a new HA port for this agent.' #NEWLINE# ctxt = context . elevated ( ) #NEWLINE# creator = functools . partial ( self . _add_port_from_net , plugin , ctxt , router_id , tenant_id ) #NEWLINE# dep_getter = functools . partial ( plugin . get_ha_network , ctxt , tenant_id ) #NEWLINE# dep_creator = functools . partial ( plugin . _create_ha_network , ctxt , tenant_id ) #NEWLINE# dep_id_attr = 'network_id' #NEWLINE# try : #NEWLINE# #INDENT# port_binding = utils . create_object_with_dependency ( creator , dep_getter , dep_creator , dep_id_attr ) [ 0 ] #NEWLINE# with db_api . autonested_transaction ( context . session ) : #NEWLINE# #INDENT# port_binding . l3_agent_id = agent [ 'id' ] #NEWLINE# #UNINDENT# #UNINDENT# except db_exc . DBDuplicateEntry : #NEWLINE# #INDENT# LOG . debug ( 'Router %(router)s already scheduled for agent %(agent)s' , { #NEWLINE# #INDENT# 'router' : router_id , #NEWLINE# 'agent' : agent [ 'id' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# except l3 . RouterNotFound : #NEWLINE# #INDENT# LOG . debug ( 'Router %s has already been removed by concurrent operation' , router_id ) #NEWLINE# return #NEWLINE# #UNINDENT# self . bind_router ( context , router_id , agent )