コード例 #1
0
ファイル: rpc.py プロジェクト: brucezy/neutron
def create_consumers(endpoints, prefix, topic_details):
    """Create agent RPC consumers.

    :param endpoints: The list of endpoints to process the incoming messages.
    :param prefix: Common prefix for the plugin/agent message queues.
    :param topic_details: A list of topics. Each topic has a name, an
                          operation, and an optional host param keying the
                          subscription to topic.host for plugin calls.

    :returns: A common Connection.
    """

    connection = rpc_compat.create_connection(new=True)
    for details in topic_details:
        topic, operation, node_name = itertools.islice(
            itertools.chain(details, [None]), 3)

        topic_name = topics.get_topic_name(prefix, topic, operation)
        connection.create_consumer(topic_name, endpoints, fanout=True)
        if node_name:
            node_topic_name = '%s.%s' % (topic_name, node_name)
            connection.create_consumer(node_topic_name,
                                       endpoints,
                                       fanout=False)
    connection.consume_in_threads()
    return connection
コード例 #2
0
ファイル: ipsec.py プロジェクト: fyelles/neutron
    def __init__(self, agent, host):
        # TODO(ihrachys): we can't use RpcCallback here due to
        # inheritance issues
        self.agent = agent
        self.conf = self.agent.conf
        self.root_helper = self.agent.root_helper
        self.host = host
        self.conn = rpc_compat.create_connection(new=True)
        self.context = context.get_admin_context_without_session()
        self.topic = topics.IPSEC_AGENT_TOPIC
        node_topic = '%s.%s' % (self.topic, self.host)

        self.processes = {}
        self.process_status_cache = {}

        self.conn.create_consumer(
            node_topic,
            self.create_rpc_dispatcher(),
            fanout=False)
        self.conn.consume_in_thread()
        self.agent_rpc = IPsecVpnDriverApi(topics.IPSEC_DRIVER_TOPIC, '1.0')
        self.process_status_cache_check = loopingcall.FixedIntervalLoopingCall(
            self.report_status, self.context)
        self.process_status_cache_check.start(
            interval=self.conf.ipsec.ipsec_status_check_interval)
コード例 #3
0
ファイル: cisco_ipsec.py プロジェクト: brucezy/neutron
    def __init__(self, agent, host):
        self.host = host
        self.conn = rpc_compat.create_connection(new=True)
        context = ctx.get_admin_context_without_session()
        node_topic = '%s.%s' % (topics.CISCO_IPSEC_AGENT_TOPIC, self.host)

        self.service_state = {}

        self.endpoints = [self]
        self.conn.create_consumer(node_topic, self.endpoints, fanout=False)
        self.conn.consume_in_threads()
        self.agent_rpc = (
            CiscoCsrIPsecVpnDriverApi(topics.CISCO_IPSEC_DRIVER_TOPIC, '1.0'))
        self.periodic_report = loopingcall.FixedIntervalLoopingCall(
            self.report_status, context)
        self.periodic_report.start(
            interval=agent.conf.cisco_csr_ipsec.status_check_interval)

        csrs_found = find_available_csrs_from_config(cfg.CONF.config_file)
        if csrs_found:
            LOG.info(_("Loaded %(num)d Cisco CSR configuration%(plural)s"),
                     {'num': len(csrs_found),
                      'plural': 's'[len(csrs_found) == 1:]})
        else:
            raise SystemExit(_('No Cisco CSR configurations found in: %s') %
                             cfg.CONF.config_file)
        self.csrs = dict([(k, csr_client.CsrRestClient(v['rest_mgmt'],
                                                       v['tunnel_ip'],
                                                       v['username'],
                                                       v['password'],
                                                       v['timeout']))
                          for k, v in csrs_found.items()])
コード例 #4
0
ファイル: plugin.py プロジェクト: fyelles/neutron
 def start_rpc_listener(self):
     self.callbacks = rpc.RpcCallbacks(self.notifier, self.type_manager)
     self.topic = topics.PLUGIN
     self.conn = rpc_compat.create_connection(new=True)
     self.dispatcher = self.callbacks.create_rpc_dispatcher()
     self.conn.create_consumer(self.topic, self.dispatcher,
                               fanout=False)
     return self.conn.consume_in_thread()
コード例 #5
0
ファイル: plugin.py プロジェクト: brucezy/neutron
 def start_rpc_listeners(self):
     self.endpoints = [rpc.RpcCallbacks(self.notifier, self.type_manager),
                       agents_db.AgentExtRpcCallback()]
     self.topic = topics.PLUGIN
     self.conn = rpc_compat.create_connection(new=True)
     self.conn.create_consumer(self.topic, self.endpoints,
                               fanout=False)
     return self.conn.consume_in_threads()
コード例 #6
0
 def _setup_rpc(self):
     self.service_topics = {svc_constants.CORE: topics.PLUGIN,
                            svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN}
     self.conn = rpc_compat.create_connection(new=True)
     self.notifier = AgentNotifierApi(topics.AGENT)
     self.endpoints = [RyuRpcCallbacks(self.ofp_api_host)]
     for svc_topic in self.service_topics.values():
         self.conn.create_consumer(svc_topic, self.endpoints, fanout=False)
     self.conn.consume_in_threads()
コード例 #7
0
ファイル: ipsec.py プロジェクト: brucezy/neutron
 def __init__(self, service_plugin):
     super(IPsecVPNDriver, self).__init__(service_plugin)
     self.endpoints = [IPsecVpnDriverCallBack(self)]
     self.conn = rpc_compat.create_connection(new=True)
     self.conn.create_consumer(
         topics.IPSEC_DRIVER_TOPIC, self.endpoints, fanout=False)
     self.conn.consume_in_threads()
     self.agent_rpc = IPsecVpnAgentApi(
         topics.IPSEC_AGENT_TOPIC, BASE_IPSEC_VERSION)
コード例 #8
0
ファイル: l3_router_plugin.py プロジェクト: brucezy/neutron
 def setup_rpc(self):
     # RPC support
     self.topic = topics.L3PLUGIN
     self.conn = rpc_compat.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()
コード例 #9
0
 def setup_rpc(self):
     # RPC support
     self.topic = topics.PLUGIN
     self.conn = rpc_compat.create_connection(new=True)
     self.notifier = AgentNotifierApi(topics.AGENT)
     self.callbacks = SdnveRpcCallbacks(self.notifier)
     self.dispatcher = self.callbacks.create_rpc_dispatcher()
     self.conn.create_consumer(self.topic, self.dispatcher,
                               fanout=False)
     # Consume from all consumers in a thread
     self.conn.consume_in_thread()
コード例 #10
0
ファイル: l3_router_plugin.py プロジェクト: fyelles/neutron
 def setup_rpc(self):
     # RPC support
     self.topic = topics.L3PLUGIN
     self.conn = rpc_compat.create_connection(new=True)
     self.agent_notifiers.update(
         {q_const.AGENT_TYPE_L3: l3_rpc_agent_api.L3AgentNotify})
     self.callbacks = L3RouterPluginRpcCallbacks()
     self.dispatcher = self.callbacks.create_rpc_dispatcher()
     self.conn.create_consumer(self.topic, self.dispatcher,
                               fanout=False)
     self.conn.consume_in_thread()
コード例 #11
0
ファイル: cisco_ipsec.py プロジェクト: fyelles/neutron
 def __init__(self, service_plugin):
     super(CiscoCsrIPsecVPNDriver, self).__init__(service_plugin)
     self.callbacks = CiscoCsrIPsecVpnDriverCallBack(self)
     self.conn = rpc_compat.create_connection(new=True)
     self.conn.create_consumer(
         topics.CISCO_IPSEC_DRIVER_TOPIC,
         self.callbacks.create_rpc_dispatcher(),
         fanout=False)
     self.conn.consume_in_thread()
     self.agent_rpc = CiscoCsrIPsecVpnAgentApi(
         topics.CISCO_IPSEC_AGENT_TOPIC, BASE_IPSEC_VERSION)
コード例 #12
0
 def setup_rpc(self):
     # RPC support
     self.topic = topics.PLUGIN
     self.conn = rpc_compat.create_connection(new=True)
     self.notifier = AgentNotifierApi(topics.AGENT)
     self.endpoints = [SdnveRpcCallbacks(self.notifier),
                       agents_db.AgentExtRpcCallback()]
     self.conn.create_consumer(self.topic, self.endpoints,
                               fanout=False)
     # Consume from all consumers in threads
     self.conn.consume_in_threads()
コード例 #13
0
ファイル: agent_driver_base.py プロジェクト: fyelles/neutron
    def _set_callbacks_on_plugin(self):
        # other agent based plugin driver might already set callbacks on plugin
        if hasattr(self.plugin, 'agent_callbacks'):
            return

        self.plugin.agent_callbacks = LoadBalancerCallbacks(self.plugin)
        self.plugin.conn = rpc_compat.create_connection(new=True)
        self.plugin.conn.create_consumer(
            topics.LOADBALANCER_PLUGIN,
            self.plugin.agent_callbacks.create_rpc_dispatcher(),
            fanout=False)
        self.plugin.conn.consume_in_thread()
コード例 #14
0
ファイル: dhcpmeta_modes.py プロジェクト: fyelles/neutron
 def _setup_rpc_dhcp_metadata(self, notifier=None):
     self.topic = topics.PLUGIN
     self.conn = rpc_compat.create_connection(new=True)
     self.dispatcher = nsx_rpc.NSXRpcCallbacks().create_rpc_dispatcher()
     self.conn.create_consumer(self.topic, self.dispatcher, fanout=False)
     self.agent_notifiers[const.AGENT_TYPE_DHCP] = (
         notifier or dhcp_rpc_agent_api.DhcpAgentNotifyAPI())
     self.conn.consume_in_thread()
     self.network_scheduler = importutils.import_object(
         cfg.CONF.network_scheduler_driver
     )
     self.supported_extension_aliases.extend(
         ['agent', 'dhcp_agent_scheduler'])
コード例 #15
0
 def _setup_rpc(self):
     # RPC support
     self.service_topics = {svc_constants.CORE: topics.PLUGIN,
                            svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN}
     self.conn = rpc_compat.create_connection(new=True)
     self.notifier = agent_notifier_api.AgentNotifierApi(
         topics.AGENT)
     self.endpoints = [rpc_callbacks.HyperVRpcCallbacks(self.notifier),
                       agents_db.AgentExtRpcCallback()]
     for svc_topic in self.service_topics.values():
         self.conn.create_consumer(svc_topic, self.endpoints, fanout=False)
     # Consume from all consumers in threads
     self.conn.consume_in_threads()
コード例 #16
0
ファイル: metering_plugin.py プロジェクト: fyelles/neutron
    def __init__(self):
        super(MeteringPlugin, self).__init__()

        self.callbacks = metering_rpc.MeteringRpcCallbacks(self)

        self.conn = rpc_compat.create_connection(new=True)
        self.conn.create_consumer(
            topics.METERING_PLUGIN,
            self.callbacks.create_rpc_dispatcher(),
            fanout=False)
        self.conn.consume_in_thread()

        self.meter_rpc = metering_rpc_agent_api.MeteringAgentNotifyAPI()
コード例 #17
0
ファイル: plugin.py プロジェクト: xiandiancloud/neutron
 def _setup_rpc(self):
     self.conn = rpc_compat.create_connection(new=True)
     self.topic = topics.PLUGIN
     self.notifier = AgentNotifierApi(topics.AGENT)
     # init dhcp agent support
     self._dhcp_agent_notifier = dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
     self.agent_notifiers[const.AGENT_TYPE_DHCP] = (
         self._dhcp_agent_notifier
     )
     self.endpoints = [RestProxyCallbacks(),
                       agents_db.AgentExtRpcCallback()]
     self.conn.create_consumer(self.topic, self.endpoints,
                               fanout=False)
     # Consume from all consumers in threads
     self.conn.consume_in_threads()
コード例 #18
0
ファイル: fwaas_plugin.py プロジェクト: brucezy/neutron
    def __init__(self):
        """Do the initialization for the firewall service plugin here."""
        qdbapi.register_models()

        self.endpoints = [FirewallCallbacks(self)]

        self.conn = rpc_compat.create_connection(new=True)
        self.conn.create_consumer(
            topics.FIREWALL_PLUGIN, self.endpoints, fanout=False)
        self.conn.consume_in_threads()

        self.agent_rpc = FirewallAgentApi(
            topics.L3_AGENT,
            cfg.CONF.host
        )
コード例 #19
0
ファイル: plugin.py プロジェクト: gjholler/neutron
 def _setup_rpc(self):
     self.conn = rpc_compat.create_connection(new=True)
     self.topic = topics.PLUGIN
     self.notifier = AgentNotifierApi(topics.AGENT)
     # init dhcp agent support
     self._dhcp_agent_notifier = dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
     self.agent_notifiers[const.AGENT_TYPE_DHCP] = (
         self._dhcp_agent_notifier
     )
     self.callbacks = RestProxyCallbacks()
     self.dispatcher = self.callbacks.create_rpc_dispatcher()
     self.conn.create_consumer(self.topic, self.dispatcher,
                               fanout=False)
     # Consume from all consumers in a thread
     self.conn.consume_in_thread()
コード例 #20
0
    def _set_callbacks_on_plugin(self):
        # other agent based plugin driver might already set callbacks on plugin
        if hasattr(self.plugin, 'agent_callbacks'):
            return

        self.plugin.agent_endpoints = [
            LoadBalancerCallbacks(self.plugin),
            agents_db.AgentExtRpcCallback(self.plugin)
        ]
        self.plugin.conn = rpc_compat.create_connection(new=True)
        self.plugin.conn.create_consumer(
            topics.LOADBALANCER_PLUGIN,
            self.plugin.agent_endpoints,
            fanout=False)
        self.plugin.conn.consume_in_threads()
コード例 #21
0
ファイル: ovs_neutron_plugin.py プロジェクト: fyelles/neutron
 def setup_rpc(self):
     # RPC support
     self.service_topics = {svc_constants.CORE: topics.PLUGIN,
                            svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN}
     self.conn = rpc_compat.create_connection(new=True)
     self.notifier = AgentNotifierApi(topics.AGENT)
     self.agent_notifiers[q_const.AGENT_TYPE_DHCP] = (
         dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
     )
     self.agent_notifiers[q_const.AGENT_TYPE_L3] = (
         l3_rpc_agent_api.L3AgentNotify
     )
     self.callbacks = OVSRpcCallbacks(self.notifier, self.tunnel_type)
     self.dispatcher = self.callbacks.create_rpc_dispatcher()
     for svc_topic in self.service_topics.values():
         self.conn.create_consumer(svc_topic, self.dispatcher, fanout=False)
     # Consume from all consumers in a thread
     self.conn.consume_in_thread()
コード例 #22
0
ファイル: mlnx_plugin.py プロジェクト: xiandiancloud/neutron
 def _setup_rpc(self):
     # RPC support
     self.service_topics = {svc_constants.CORE: topics.PLUGIN,
                            svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN}
     self.conn = rpc_compat.create_connection(new=True)
     self.endpoints = [rpc_callbacks.MlnxRpcCallbacks(),
                       agents_db.AgentExtRpcCallback()]
     for svc_topic in self.service_topics.values():
         self.conn.create_consumer(svc_topic, self.endpoints, fanout=False)
     # Consume from all consumers in threads
     self.conn.consume_in_threads()
     self.notifier = agent_notify_api.AgentNotifierApi(topics.AGENT)
     self.agent_notifiers[q_const.AGENT_TYPE_DHCP] = (
         dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
     )
     self.agent_notifiers[q_const.AGENT_TYPE_L3] = (
         l3_rpc_agent_api.L3AgentNotifyAPI()
     )
コード例 #23
0
ファイル: ipsec.py プロジェクト: xiandiancloud/neutron
    def __init__(self, agent, host):
        self.agent = agent
        self.conf = self.agent.conf
        self.root_helper = self.agent.root_helper
        self.host = host
        self.conn = rpc_compat.create_connection(new=True)
        self.context = context.get_admin_context_without_session()
        self.topic = topics.IPSEC_AGENT_TOPIC
        node_topic = '%s.%s' % (self.topic, self.host)

        self.processes = {}
        self.process_status_cache = {}

        self.endpoints = [self]
        self.conn.create_consumer(node_topic, self.endpoints, fanout=False)
        self.conn.consume_in_threads()
        self.agent_rpc = IPsecVpnDriverApi(topics.IPSEC_DRIVER_TOPIC, '1.0')
        self.process_status_cache_check = loopingcall.FixedIntervalLoopingCall(
            self.report_status, self.context)
        self.process_status_cache_check.start(
            interval=self.conf.ipsec.ipsec_status_check_interval)
コード例 #24
0
ファイル: nec_plugin.py プロジェクト: xiandiancloud/neutron
    def setup_rpc(self):
        self.service_topics = {svc_constants.CORE: topics.PLUGIN,
                               svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN}
        self.conn = rpc_compat.create_connection(new=True)
        self.notifier = NECPluginV2AgentNotifierApi(topics.AGENT)
        self.agent_notifiers[const.AGENT_TYPE_DHCP] = (
            dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
        )
        self.agent_notifiers[const.AGENT_TYPE_L3] = (
            nec_router.L3AgentNotifyAPI()
        )

        # NOTE: callback_sg is referred to from the sg unit test.
        self.callback_sg = SecurityGroupServerRpcCallback()
        self.endpoints = [
            NECPluginV2RPCCallbacks(self.safe_reference),
            DhcpRpcCallback(),
            L3RpcCallback(),
            self.callback_sg,
            agents_db.AgentExtRpcCallback()]
        for svc_topic in self.service_topics.values():
            self.conn.create_consumer(svc_topic, self.endpoints, fanout=False)
        # Consume from all consumers in threads
        self.conn.consume_in_threads()