def __init__(self, host, conf=None): self.state_rpc = agent_rpc.PluginReportStateAPI( n_topics.SVMDEVICE_DRIVER_TOPIC) self.agent_state = { 'binary': 'neutron-servicevm-agent', 'host': host, 'topic': topics.SERVICEVM_AGENT, 'configurations': {}, 'start_flag': True, 'agent_type': constants.AGENT_TYPE_SERVICEVM } report_interval = cfg.CONF.AGENT.report_interval self.use_call = True self._initialize_rpc(host) self.topic = topics.SERVICEVM self.endpoints = [self] consumers = [[topics.SUBNET, topics.UPDATE], [topics.SUBNET, topics.DELETE], [topics.SUBNET, topics.CREATE]] self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers) #self._agent_registration() super(ServiceVMAgentWithStateReport, self).__init__(host=host, conf=conf) if report_interval: self.heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) #self.heartbeat.start(interval=report_interval) self.heartbeat.start(interval=2)
def _setup_rpc(self): self.agent_id = 'mlnx-agent.%s' % socket.gethostname() LOG.info(_("RPC agent_id: %s"), self.agent_id) self.topic = topics.AGENT self.plugin_rpc = MlnxEswitchPluginApi(topics.PLUGIN) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) # RPC network init self.context = context.get_admin_context_without_session() # Handle updates from service self.callbacks = MlnxEswitchRpcCallbacks(self.context, self) self.dispatcher = self.callbacks.create_rpc_dispatcher() # Define the listening consumers for the agent consumers = [[topics.PORT, topics.UPDATE], [topics.NETWORK, topics.DELETE], [topics.SECURITY_GROUP, topics.UPDATE]] self.connection = agent_rpc.create_consumers(self.dispatcher, self.topic, consumers) report_interval = cfg.CONF.AGENT.report_interval if report_interval: heartbeat = loopingcall.LoopingCall(self._report_state) heartbeat.start(interval=report_interval)
def setup_rpc(self): self.agent_id = 'dvs-agent-%s' % self.conf.host self.topic = topics.AGENT self.plugin_rpc = DVSPluginApi(topics.PLUGIN) self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) # RPC network init self.context = neutron.context.get_admin_context_without_session() # Handle updates from service self.endpoints = [self] # Define the listening consumers for the agent consumers = [[topics.PORT, topics.CREATE], [topics.PORT, topics.UPDATE], [topics.PORT, topics.DELETE], [topics.NETWORK, topics.CREATE], [topics.NETWORK, topics.UPDATE], [topics.NETWORK, topics.DELETE], [topics.SECURITY_GROUP, topics.UPDATE]] self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers, start_listening=False)
def __init__(self): self.context = context.get_admin_context_without_session() self.agent_id = uuidutils.generate_uuid(dashed=True) self.agent_host = socket.gethostname() # Set up oslo_messaging notifier and listener to keep track of other # members # NOTE(hjensas): Override the control_exchange for the notification # transport to allow setting amqp_auto_delete = true. # TODO(hjensas): Remove this and override the exchange when setting up # the notifier once the fix for bug is available. # https://bugs.launchpad.net/oslo.messaging/+bug/1814797 CONF.set_override('control_exchange', 'ironic-neutron-agent') self.transport = oslo_messaging.get_notification_transport( CONF, url=_get_notification_transport_url()) self.notifier = _set_up_notifier(self.transport, self.agent_id) # Note(hjensas): We need to have listener consuming the non-pool queue. # See bug: https://bugs.launchpad.net/oslo.messaging/+bug/1814544 self.listener = _set_up_listener(self.transport, None) self.pool_listener = _set_up_listener( self.transport, '-'.join( ['ironic-neutron-agent-member-manager-pool', self.agent_id])) self.member_manager = HashRingMemberManagerNotificationEndpoint() self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS) self.ironic_client = ironic_client.get_client() self.reported_nodes = {} LOG.info('Agent networking-baremetal initialized.')
def __init__(self, host, conf=None): super(L3NATAgentWithStateReport, self).__init__(host=host, conf=conf) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS) self.failed_report_state = False self.agent_state = { 'binary': lib_const.AGENT_PROCESS_L3, 'host': host, 'availability_zone': self.conf.AGENT.availability_zone, 'topic': topics.L3_AGENT, 'configurations': { 'agent_mode': self.conf.agent_mode, 'handle_internal_only_routers': self.conf.handle_internal_only_routers, 'interface_driver': self.conf.interface_driver, 'log_agent_heartbeats': self.conf.AGENT.log_agent_heartbeats, 'extensions': self.l3_ext_manager.names() }, 'start_flag': True, 'agent_type': lib_const.AGENT_TYPE_L3 } report_interval = self.conf.AGENT.report_interval if report_interval: self.heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) self.heartbeat.start(interval=report_interval)
def setup_rpc(self): # print("cfarquhar: in setup_rpc") self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN) self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.sg_agent = agent_sg_rpc.SecurityGroupAgentRpc( self.context, self.sg_plugin_rpc, defer_refresh_firewall=True) # LOG.info("cfarquhar: vars(plugin_rpc): {}".format(vars(self.plugin_rpc))) # LOG.info("cfarquhar: vars(sg_plugin_rpc): {}".format(vars(self.sg_plugin_rpc))) # LOG.info("cfarquhar: vars(sg_agent.plugin_rpc): {}".format(vars(self.sg_agent.plugin_rpc))) self.agent_id = self.mgr.get_agent_id() LOG.info("RPC agent_id: %s", self.agent_id) self.topic = topics.AGENT self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS) # RPC network init # Handle updates from service self.rpc_callbacks = self.mgr.get_rpc_callbacks( self.context, self, self.sg_agent) self.endpoints = [self.rpc_callbacks] self._validate_rpc_endpoints() # Define the listening consumers for the agent consumers = self.mgr.get_rpc_consumers() self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers, start_listening=False)
def _setup_rpc(self): self.agent_id = 'nic-switch-agent.%s' % socket.gethostname() LOG.info(_LI("RPC agent_id: %s"), self.agent_id) self.topic = topics.AGENT self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) # RPC network init # Handle updates from service self.endpoints = [ SriovNicSwitchRpcCallbacks(self.context, self, self.sg_agent) ] # Define the listening consumers for the agent consumers = [[topics.PORT, topics.UPDATE], [topics.NETWORK, topics.DELETE], [topics.SECURITY_GROUP, topics.UPDATE]] self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers, start_listening=False) report_interval = cfg.CONF.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
def setup_rpc(self, physical_interfaces): if physical_interfaces: mac = utils.get_interface_mac(physical_interfaces[0]) else: devices = ip_lib.IPWrapper().get_devices(True) if devices: mac = utils.get_interface_mac(devices[0].name) else: LOG.error( _LE("Unable to obtain MAC address for unique ID. " "Agent terminated!")) exit(1) self.agent_id = '%s%s' % ('lb', (mac.replace(":", ""))) LOG.info(_LI("RPC agent_id: %s"), self.agent_id) self.topic = topics.AGENT self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS) # RPC network init # Handle updates from service self.endpoints = [ LinuxBridgeRpcCallbacks(self.context, self, self.sg_agent) ] # Define the listening consumers for the agent consumers = [[topics.PORT, topics.UPDATE], [topics.NETWORK, topics.DELETE], [topics.SECURITY_GROUP, topics.UPDATE]] if cfg.CONF.VXLAN.l2_population: consumers.append([topics.L2POPULATION, topics.UPDATE]) self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers) report_interval = cfg.CONF.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
def _setup_rpc(self, root_helper): self.agent_id = 'hyperv_%s' % platform.node() self.topic = topics.AGENT self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN) self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) # RPC network init self.context = context.get_admin_context_without_session() # Handle updates from service self.endpoints = [self] # Define the listening consumers for the agent consumers = [[topics.PORT, topics.UPDATE], [topics.NETWORK, topics.DELETE], [topics.PORT, topics.DELETE], [constants.TUNNEL, topics.UPDATE]] self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers) self.sec_groups_agent = HyperVSecurityAgent(self.context, self.sg_plugin_rpc, root_helper) report_interval = CONF.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
def setup_rpc(self): self.plugin_rpc = OVSPluginApi(topics.PLUGIN) self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.dvr_plugin_rpc = dvr_rpc.DVRServerRpcApi(topics.PLUGIN) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS) # RPC network init self.context = context.get_admin_context_without_session() # Define the listening consumers for the agent consumers = [[constants.TUNNEL, topics.UPDATE], [constants.TUNNEL, topics.DELETE], [topics.SECURITY_GROUP, topics.UPDATE], [topics.DVR, topics.UPDATE], [topics.NETWORK, topics.UPDATE]] if self.l2_pop: consumers.append([topics.L2POPULATION, topics.UPDATE]) self.connection = agent_rpc.create_consumers([self], topics.AGENT, consumers, start_listening=False) # NOTE(rtheis): This will initialize all workers (API, RPC, # plugin service and OVN) with OVN IDL connections. trigger = ovsdb_monitor.OvnWorker self._nb_ovn, self._sb_ovn = impl_idl_ovn.get_ovn_idls(self, trigger)
def setup_rpc(self): self.host = socket.gethostname() self.agent_id = 'nec-q-agent.%s' % self.host LOG.info(_("RPC agent_id: %s"), self.agent_id) self.topic = topics.AGENT self.context = q_context.get_admin_context_without_session() self.plugin_rpc = NECPluginApi(topics.PLUGIN) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.sg_agent = SecurityGroupAgentRpc(self.context) # RPC network init # Handle updates from service self.callback_nec = NECAgentRpcCallback(self.context, self, self.sg_agent) self.callback_sg = SecurityGroupAgentRpcCallback( self.context, self.sg_agent) self.endpoints = [self.callback_nec, self.callback_sg] # Define the listening consumer for the agent consumers = [[topics.PORT, topics.UPDATE], [topics.SECURITY_GROUP, topics.UPDATE]] self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers) report_interval = config.CONF.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
def __init__(self, host, conf=None): super(L3NATAgentWithStateReport, self).__init__(host=host, conf=conf) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.agent_state = { 'binary': 'neutron-l3-agent', 'host': host, 'topic': topics.L3_AGENT, 'configurations': { 'use_namespaces': self.conf.use_namespaces, 'router_id': self.conf.router_id, 'handle_internal_only_routers': self.conf.handle_internal_only_routers, 'gateway_external_network_id': self.conf.gateway_external_network_id, 'interface_driver': self.conf.interface_driver }, 'start_flag': True, 'agent_type': l3_constants.AGENT_TYPE_L3 } report_interval = cfg.CONF.AGENT.report_interval self.use_call = True if report_interval: self.heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) self.heartbeat.start(interval=report_interval)
def setup_rpc(self, physical_interfaces): if physical_interfaces: mac = utils.get_interface_mac(physical_interfaces[0]) else: devices = ip_lib.IPWrapper(self.root_helper).get_devices(True) if devices: mac = utils.get_interface_mac(devices[0].name) else: LOG.error( _("Unable to obtain MAC address for unique ID. " "Agent terminated!")) exit(1) self.agent_id = '%s%s' % ('lb', (mac.replace(":", ""))) LOG.info(_("RPC agent_id: %s"), self.agent_id) self.topic = topics.AGENT self.plugin_rpc = LinuxBridgePluginApi(topics.PLUGIN) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) # RPC network init self.context = context.get_admin_context_without_session() # Handle updates from service self.callbacks = LinuxBridgeRpcCallbacks(self.context, self) self.dispatcher = self.callbacks.create_rpc_dispatcher() # Define the listening consumers for the agent consumers = [[topics.PORT, topics.UPDATE], [topics.NETWORK, topics.DELETE], [topics.SECURITY_GROUP, topics.UPDATE]] self.connection = agent_rpc.create_consumers(self.dispatcher, self.topic, consumers) report_interval = cfg.CONF.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
def _setup_rpc(self): self.agent_id = 'vbox_%s' % platform.node() self.topic = topics.AGENT self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) # RPC network init self.context = n_context.get_admin_context_without_session() # Handle updates from service self.endpoints = [self] # Define the listening consumers for the agent consumers = [[topics.PORT, topics.UPDATE], [topics.NETWORK, topics.DELETE], [topics.PORT, topics.DELETE], [constants.TUNNEL, topics.UPDATE]] self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers) self.sec_groups_agent = VBoxSecurityAgent(self.context, self.plugin_rpc) report_interval = CONF.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval) self.agent_state = { 'binary': 'neutron-vbox-agent', 'host': cfg.CONF.host, 'topic': n_const.L2_AGENT_TOPIC, 'configurations': { 'network_mappings': self._physical_network_mappings }, 'agent_type': n_const.AGENT_TYPE_VBOX, 'start_flag': True }
def __init__(self, host, conf=None): super(L3NATAgentWithStateReport, self).__init__(host=host, conf=conf) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS) self.agent_state = { 'binary': 'neutron-l3-agent', 'host': host, 'availability_zone': self.conf.AGENT.availability_zone, 'topic': topics.L3_AGENT, 'configurations': { 'agent_mode': self.conf.agent_mode, 'handle_internal_only_routers': self.conf.handle_internal_only_routers, 'external_network_bridge': self.conf.external_network_bridge, 'gateway_external_network_id': self.conf.gateway_external_network_id, 'interface_driver': self.conf.interface_driver, 'log_agent_heartbeats': self.conf.AGENT.log_agent_heartbeats }, 'start_flag': True, 'agent_type': lib_const.AGENT_TYPE_L3 } report_interval = self.conf.AGENT.report_interval if report_interval: self.heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) self.heartbeat.start(interval=report_interval)
def _setup_rpc(self): """Setup the RPC client for the current agent.""" self._state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS) report_interval = CONF.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
def _setup_state_rpc(self, topic): # Agent state API self.state_rpc = agent_rpc.PluginReportStateAPI(topic) report_interval = self.conf.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
def _setup_state_rpc(self): self.state_rpc = agent_rpc.PluginReportStateAPI( topics.LOADBALANCER_PLUGIN) report_interval = self.conf.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
def _setup_rpc(self): self.plugin_rpc = agent_api.LbaasAgentApi( plugin_driver.TOPIC_PROCESS_ON_HOST, self.context, self.conf.host) self.state_rpc = agent_rpc.PluginReportStateAPI( plugin_driver.TOPIC_PROCESS_ON_HOST) report_interval = self.conf.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
def _setup_rpc(self): self.topic = topics.AGENT #self.plugin_rpc = MAPPluginApi(topics.PLUGIN) self.context = q_context.get_admin_context_without_session() self.endpoints = [self] consumers = [[topics.PORT, topics.UPDATE], [topics.SECURITY_GROUP, topics.UPDATE]] self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
def test_plugin_report_state_cast(self): topic = 'test' reportStateAPI = rpc.PluginReportStateAPI(topic) expected_agent_state = {'agent': 'test'} with mock.patch.object(reportStateAPI, 'cast') as cast: ctxt = context.RequestContext('fake_user', 'fake_project') reportStateAPI.report_state(ctxt, expected_agent_state) self.assertEqual(cast.call_args[0][0], ctxt) self.assertEqual(cast.call_args[0][1]['method'], 'report_state') self.assertEqual(cast.call_args[0][1]['args']['agent_state'], {'agent_state': expected_agent_state}) self.assertIsInstance(cast.call_args[0][1]['args']['time'], str)
def __init__(self, host, conf=None): super(ZenicAgentWithStateReport, self).__init__(host=host, conf=conf) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.agent_state = { 'binary': 'neutron_zenic_agent', 'host': host, 'topic': topics.L3_AGENT, 'configurations': {'agent_mode': self.conf.agent_mode, }, 'start_flag': True, 'agent_type': 'L3 agent'} self.use_call = True self.heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) self.heartbeat.start(30)
def _init_agent_report_thread(self): self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.agent_state = { 'binary': const.AGENT_BINARY_NAME, 'host': config.CONF.host, 'topic': 'N/A', 'configurations': {}, 'start_flag': True, 'agent_type': const.AGENT_TYPE_INFOBLOX_IPAM } self.use_call = True if self.report_interval: self.report_thread = loopingcall.FixedIntervalLoopingCall( self._report_state) self.report_thread.start(interval=self.report_interval)
def _setup_rpc(self): # Setting up outbound (callbacks) communications from agent # setup the topic to send oslo messages RPC calls # from this agent to the controller topic = constants.TOPIC_LBAASV2_BIGIQ_DRIVER # create our class we will use to send callbacks to the controller # for processing by the driver plugin self.plugin_rpc = plugin_rpc.LBaaSv2PluginRPC(self.context, topic, self.agent_host) # Setting up outbound communcations with the neutron agent extension self.state_rpc = agent_rpc.PluginReportStateAPI(topic)
def _setup_rpc(self): self.topic = topics.AGENT self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN) self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.context = q_context.get_admin_context_without_session() self.endpoints = [self] consumers = [[topics.PORT, topics.UPDATE], [topics.SECURITY_GROUP, topics.UPDATE]] self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) report_interval = cfg.CONF.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
def __init__(self, host, conf=None): super(BgpDrAgentWithStateReport, self).__init__(host, conf) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.agent_state = { 'agent_type': bgp_consts.AGENT_TYPE_BGP_ROUTING, 'binary': 'neutron-bgp-dragent', 'configurations': {}, 'host': host, 'topic': bgp_consts.BGP_DRAGENT, 'start_flag': True} report_interval = cfg.CONF.AGENT.report_interval if report_interval: self.heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) self.heartbeat.start(interval=report_interval)
def setup_rpc(self): """setup_rpc """ self.context = q_context.get_admin_context_without_session() self.nwa_l2_rpc = tenant_binding_api.TenantBindingServerRpcApi( topics.PLUGIN ) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.callback_nwa = nwa_agent_callback.NwaAgentRpcCallback( self.context, self.server_manager) self.callback_proxy = nwa_proxy_callback.NwaProxyCallback( self.context, self.proxy_l2) self.callback_l3 = nwa_l3_proxy_callback.NwaL3ProxyCallback( self.context, self.proxy_l3) # lbaas self.lbaas_driver = None self.callback_lbaas = None if self.conf.NWA.lbaas_driver: pass # fwaas self.fwaas_driver = None self.callback_fwaas = None if self.conf.NWA.fwaas_driver: pass # endpoints self.endpoints = [self.callback_nwa, self.callback_proxy, self.callback_l3] # create connection self.conn = n_rpc.create_connection() self.conn.create_consumer(self.topic, self.endpoints, fanout=False) self.conn.consume_in_threads() report_interval = cfg.CONF.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
def test_plugin_report_state_cast(self): topic = 'test' reportStateAPI = rpc.PluginReportStateAPI(topic) expected_agent_state = {'agent': 'test'} with contextlib.nested( mock.patch.object(reportStateAPI.client, 'call'), mock.patch.object(reportStateAPI.client, 'cast'), mock.patch.object(reportStateAPI.client, 'prepare'), ) as (mock_call, mock_cast, mock_prepare): mock_prepare.return_value = reportStateAPI.client ctxt = oslo_context.RequestContext('fake_user', 'fake_project') reportStateAPI.report_state(ctxt, expected_agent_state) self.assertEqual(mock_cast.call_args[0][0], ctxt) self.assertEqual(mock_cast.call_args[0][1], 'report_state') self.assertEqual(mock_cast.call_args[1]['agent_state'], {'agent_state': expected_agent_state}) self.assertIsInstance(mock_cast.call_args[1]['time'], str)
def setup_rpc(self): if self.int_br: mac = self.int_br.get_local_port_mac() self.agent_id = '%s%s' % ('sdnve', (mac.replace(":", ""))) else: nameaddr = socket.gethostbyname(socket.gethostname()) self.agent_id = '%s%s' % ('sdnve_', (nameaddr.replace(".", "_"))) self.topic = topics.AGENT self.plugin_rpc = SdnvePluginApi(topics.PLUGIN) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.context = context.get_admin_context_without_session() self.dispatcher = self.create_rpc_dispatcher() consumers = [[constants.INFO, topics.UPDATE]] self.connection = agent_rpc.create_consumers(self.dispatcher, self.topic, consumers)
def _setup_rpc(self): self.topic = "FP_AGENT" self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS) # RPC network init # Handle updates from service self.endpoints = [self] # Define the listening consumers for the agent consumers = [["info", "update"]] self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers, start_listening=False) report_interval = 30 if report_interval: self.heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) self.heartbeat.start(interval=report_interval)