rpc.call - Fetch router list of L3 agent

来源:互联网 发布:ubuntu软件中心没了 编辑:程序博客网 时间:2024/06/15 03:10

1.  L3 agent daemon

--> neutron.agent.l3_agent.L3PluginApi

class L3PluginApi(n_rpc.RpcProxy):

...

...def get_routers(self, context, router_ids=None):
        """Make a remote process call to retrieve the sync data for routers."""
        return self.call(context,
                         self.make_msg('sync_routers', host=self.host,router_ids=router_ids), topic=self.topic)

 

2.  Neutron server daemon

2.1 -->  api-paste.ini

[app:neutronapiapp_v2_0]
paste.app_factory = neutron.api.v2.router:APIRouter.factory

2.2 --> api.v2.router

class APIRouter(wsgi.Router):

...

...def __init__(self, **local_config):
        mapper = routes_mapper.Mapper()
        plugin = manager.NeutronManager.get_plugin()
        ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
        ext_mgr.extend_resources("2.0", attributes.RESOURCE_ATTRIBUTE_MAP)

2.3 --> api.extensions

class PluginAwareExtensionManager(ExtensionManager):

...

    @classmethod
    def get_instance(cls):
        if cls._instance is None:
            cls._instance = cls(get_extensions_path(),
                                manager.NeutronManager.get_service_plugins())
        return cls._instance


#neutron.conf
#service_plugins =
#neutron.services.l3_router.l3_router_plugin.L3RouterPlugin,
#neutron.services.loadbalancer.plugin.LoadBalancerPlugin,
#neutron.services.vpn.plugin.VPNDriverPlugin,
#neutron.services.firewall.fwaas_plugin.FirewallPlugin
   
#{'L3_ROUTER_NAT':<neutron.services.l3_router.l3_router_plugin.L3RouterPlugin object at 0x2c91850>,
#'CORE': <neutron.plugins.ml2.plugin.Ml2Plugin object at 0x3715f50>,
#'VPN': <neutron.services.vpn.plugin.VPNDriverPlugin object at 0x40c9c50>,
#'LOADBALANCER': <neutron.services.loadbalancer.plugin.LoadBalancerPlugin object at 0x3bf33d0>,
#'FIREWALL': <neutron.services.firewall.fwaas_plugin.FirewallPlugin object at 0x420b690>}

 

2.4 --> service.l3_router.l3_router_plugin

 

class L3RouterPluginRpcCallbacks(n_rpc.RpcCallback,
                                 l3_rpc_base.L3RpcCallbackMixin):

    RPC_API_VERSION = '1.1'

 

class L3RouterPlugin(db_base_plugin_v2.CommonDbMixin,
                     extraroute_db.ExtraRoute_db_mixin,
                     l3_gwmode_db.L3_NAT_db_mixin,
                     l3_agentschedulers_db.L3AgentSchedulerDbMixin):

    def __init__(self):
        qdbapi.register_models(base=model_base.BASEV2)
        self.setup_rpc()
        self.router_scheduler = importutils.import_object(
            cfg.CONF.router_scheduler_driver)

    def setup_rpc(self):
        # RPC support
        self.topic = topics.L3PLUGIN
        self.conn = n_rpc.create_connection(new=True)
        self.agent_notifiers.update(
            {q_const.AGENT_TYPE_L3: l3_rpc_agent_api.L3AgentNotifyAPI()})
        self.endpoints = [L3RouterPluginRpcCallbacks()]
        self.conn.create_consumer(self.topic, self.endpoints,
                                  fanout=False)
        self.conn.consume_in_threads()

 

2.5 --> db.l3_rpc_base

class L3RpcCallbackMixin(object):

    def sync_routers(self, context, **kwargs):

...

        context = neutron_context.get_admin_context()
        l3plugin = manager.NeutronManager.get_service_plugins()[
            plugin_constants.L3_ROUTER_NAT]

...      routers = l3plugin.list_active_sync_routers_on_active_l3_agent(
                context, host, router_ids)

...

     return routers

2.6 --> db.l3_agentschedulers_db

class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
                              agentschedulers_db.AgentSchedulerDbMixin):

...

def list_active_sync_routers_on_active_l3_agent(

...  query query....

 

 

 

 

 

0 0