#NEWLINE# def _add_csnat_router_interface_port( self , context , router , network_id , subnet_id , do_pop = True ) : #NEWLINE# #INDENT# 'Add SNAT interface to the specified router and subnet.' #NEWLINE# port_data = { #NEWLINE# #INDENT# 'tenant_id' : '' , #NEWLINE# 'network_id' : network_id , #NEWLINE# 'fixed_ips' : [ { #NEWLINE# #INDENT# 'subnet_id' : subnet_id , #NEWLINE# #UNINDENT# } ] , #NEWLINE# 'device_id' : router . id , #NEWLINE# 'device_owner' : const . DEVICE_OWNER_ROUTER_SNAT , #NEWLINE# 'admin_state_up' : True , #NEWLINE# 'name' : '' , #NEWLINE# #UNINDENT# } #NEWLINE# snat_port = p_utils . create_port ( self . _core_plugin , context , { #NEWLINE# #INDENT# 'port' : port_data , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( not snat_port ) : #NEWLINE# #INDENT# msg = _ ( 'Unable to create the SNAT Interface Port' ) #NEWLINE# raise n_exc . BadRequest ( resource = 'router' , msg = msg ) #NEWLINE# #UNINDENT# with context . session . begin ( subtransactions = True ) : #NEWLINE# #INDENT# router_port = l3_db . RouterPort ( port_id = snat_port [ 'id' ] , router_id = router . id , port_type = const . DEVICE_OWNER_ROUTER_SNAT ) #NEWLINE# context . session . add ( router_port ) #NEWLINE# #UNINDENT# if do_pop : #NEWLINE# #INDENT# return self . _populate_mtu_and_subnets_for_ports ( router_port , [ snat_port ] ) #NEWLINE# #UNINDENT# return snat_port