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
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)
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()])
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()
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()
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()
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)
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()
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()
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()
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)
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()
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()
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'])
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()
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()
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()
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 )
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()
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()
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()
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() )
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)
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()