<s> from oslo_config import cfg <EOL> from neutron . api . rpc . agentnotifiers import l3_rpc_agent_api <EOL> from neutron . api . rpc . handlers import l3_rpc <EOL> from neutron . common import constants as q_const <EOL> from neutron . common import rpc as n_rpc <EOL> from neutron . common import topics <EOL> from neutron . db import extraroute_db <EOL> from neutron . db import l3_agentschedulers_db <EOL> from neutron . db import l3_gwmode_db <EOL> from neutron . plugins . common import constants <EOL> from networking_onos . common import config <EOL> from networking_onos . plugins . l3 import floating_ip as onos_fip <EOL> from networking_onos . plugins . l3 import router as onos_router <EOL> try : <EOL> from neutron . db . db_base_plugin_v2 import common_db_mixin <EOL> except ImportError as e : <EOL> from neutron . db import common_db_mixin <EOL> class ONOSL3Plugin ( common_db_mixin . CommonDbMixin , <EOL> extraroute_db . ExtraRoute_db_mixin , <EOL> l3_gwmode_db . L3_NAT_db_mixin , <EOL> l3_agentschedulers_db . L3AgentSchedulerDbMixin , <EOL> onos_router . ONOSRouter , <EOL> onos_fip . ONOSFloatingIP ) : <EOL> """<STR_LIT>""" <EOL> supported_extension_aliases = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> def __init__ ( self ) : <EOL> self . setup_rpc ( ) <EOL> self . onos_path = cfg . CONF . onos . url_path <EOL> self . onos_auth = ( cfg . CONF . onos . username , cfg . CONF . onos . password ) <EOL> def setup_rpc ( self ) : <EOL> self . topic = topics . L3PLUGIN <EOL> self . conn = n_rpc . create_connection ( ) <EOL> self . agent_notifiers . update ( <EOL> { q_const . AGENT_TYPE_L3 : l3_rpc_agent_api . L3AgentNotifyAPI ( ) } ) <EOL> self . endpoints = [ l3_rpc . L3RpcCallback ( ) ] <EOL> self . conn . create_consumer ( self . topic , self . endpoints , fanout = False ) <EOL> self . conn . consume_in_threads ( ) <EOL> def get_plugin_type ( self ) : <EOL> return constants . L3_ROUTER_NAT <EOL> def get_plugin_description ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( "<STR_LIT>" ) <EOL> def create_router ( self , context , router ) : <EOL> router_dict = super ( ONOSL3Plugin , self ) . create_router ( context , router ) <EOL> self . handle_create_router ( router_dict ) <EOL> return router_dict <EOL> def update_router ( self , context , id , router ) : <EOL> router_dict = super ( ONOSL3Plugin , self ) . update_router ( context , id , <EOL> router ) <EOL> self . handle_update_router ( router_dict , id ) <EOL> return router_dict <EOL> def delete_router ( self , context , id ) : <EOL> super ( ONOSL3Plugin , self ) . delete_router ( context , id ) <EOL> self . handle_delete_router ( id ) <EOL> def create_floatingip ( self , context , floatingip , <EOL> initial_status = q_const . FLOATINGIP_STATUS_ACTIVE ) : <EOL> fip_dict = super ( ONOSL3Plugin , self ) . create_floatingip ( context , <EOL> floatingip , <EOL> initial_status ) <EOL> self . handle_create_floatingip ( fip_dict ) <EOL> return fip_dict <EOL> def update_floatingip ( self , context , id , floatingip ) : <EOL> fip_dict = super ( ONOSL3Plugin , self ) . update_floatingip ( context , id , <EOL> floatingip ) <EOL> self . handle_update_floatingip ( id , fip_dict ) <EOL> return fip_dict <EOL> def delete_floatingip ( self , context , id ) : <EOL> super ( ONOSL3Plugin , self ) . delete_floatingip ( context , id ) <EOL> self . handle_delete_floatingip ( id ) <EOL> def add_router_interface ( self , context , router_id , interface_info ) : <EOL> router = super ( ONOSL3Plugin , self ) . add_router_interface ( context , <EOL> router_id , <EOL> interface_info ) <EOL> intf_add_type = self . _get_intf_add_type ( router , interface_info ) <EOL> self . handle_add_router_interface ( router , router_id , <EOL> interface_info , intf_add_type ) <EOL> return router <EOL> def remove_router_interface ( self , context , router_id , interface_info ) : <EOL> router = super ( ONOSL3Plugin , self ) . remove_router_interface ( <EOL> context , router_id , interface_info ) <EOL> intf_add_type = self . _get_intf_add_type ( router , interface_info ) <EOL> self . handle_remove_router_interface ( router , router_id , <EOL> interface_info , intf_add_type ) <EOL> return router <EOL> def _get_intf_add_type ( self , router_info , intf_info ) : <EOL> add_by_port , add_by_sub = self . _validate_interface_info ( intf_info ) <EOL> if add_by_sub : <EOL> return onos_router . ADD_INTF_BY_SUBNET <EOL> return onos_router . ADD_INTF_BY_PORT </s>
