#NEWLINE# def _conditionally_add_logical_global_router( self , context , router ) : #NEWLINE# #INDENT# filters = { #NEWLINE# #INDENT# routerrole . ROUTER_ROLE_ATTR : [ ROUTER_ROLE_LOGICAL_GLOBAL ] , #NEWLINE# routertype . TYPE_ATTR : [ router [ routertype . TYPE_ATTR ] ] , #NEWLINE# #UNINDENT# } #NEWLINE# logical_global_routers = self . _l3_plugin . get_routers ( logical_global_routers , filters = filters ) #NEWLINE# if ( not logical_global_routers ) : #NEWLINE# #INDENT# ext_nw = router [ l3 . EXTERNAL_GW_INFO ] [ 'network_id' ] #NEWLINE# r_spec = { #NEWLINE# #INDENT# 'router' : { #NEWLINE# #INDENT# 'tenant_id' : '' , #NEWLINE# 'name' : self . _global_router_name ( '' , logical = True ) , #NEWLINE# 'admin_state_up' : True , #NEWLINE# l3 . EXTERNAL_GW_INFO : { #NEWLINE# #INDENT# 'network_id' : ext_nw , #NEWLINE# #UNINDENT# } , #NEWLINE# routertypeawarescheduler . AUTO_SCHEDULE_ATTR : False , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# with context . session . begin ( subtransactions = True ) : #NEWLINE# #INDENT# ( logical_global_router , r_hd_b_db ) = self . _l3_plugin . do_create_router ( context , r_spec , router [ routertype . TYPE_ATTR ] , False , True , None , ROUTER_ROLE_LOGICAL_GLOBAL ) #NEWLINE# self . _provision_ha ( context , logical_global_router ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# logical_global_router = logical_global_routers [ 0 ] #NEWLINE# with context . session . begin ( subtransactions = True ) : #NEWLINE# #INDENT# self . _update_ha_redundancy_level ( context , logical_global_router , 1 ) #NEWLINE# #UNINDENT# #UNINDENT# return logical_global_router