def __init__(self, host, conf=None): self.conf = conf or cfg.CONF self._load_drivers() self.root_helper = config.get_root_helper(self.conf) self.context = context.get_admin_context_without_session() self.metering_info = {} self.metering_loop = loopingcall.FixedIntervalLoopingCall( self._metering_loop) measure_interval = self.conf.measure_interval self.last_report = 0 self.metering_loop.start(interval=measure_interval) self.host = host self.label_tenant_id = {} self.routers = {} self.metering_infos = {} super(MeteringAgent, self).__init__(host=host)
def __init__(self, agent, host): self.host = host self.conn = n_rpc.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)) self.periodic_report = loopingcall.FixedIntervalLoopingCall( self.report_status, context) self.periodic_report.start( interval=agent.conf.cisco_csr_ipsec.status_check_interval) LOG.debug("Device driver initialized for %s", node_topic)
def __init__(self, host, conf=None): super(NetconfFirewallAgentWithStateReport, self).__init__(host=host, conf=conf) self.conf = cfg.CONF self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.agent_state = { 'binary': 'neutron-FW-appliance-aS', 'host': host, 'topic': topics.L3_AGENT, 'configurations': { 'use_namespaces': self.conf.use_namespaces, '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 __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' + cfg.CONF.agent_index, 'host': host, 'topic': topics.L3_AGENT, 'configurations': { 'agent_mode': self.conf.agent_mode, }, '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 _init_state_reporting(self): self.context = context.get_admin_context_without_session() self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.agent_state = { 'binary': 'neutron-metadata-agent', 'host': cfg.CONF.host, 'topic': 'N/A', 'configurations': { 'metadata_proxy_socket': cfg.CONF.metadata_proxy_socket, 'nova_metadata_ip': cfg.CONF.nova_metadata_ip, 'nova_metadata_port': cfg.CONF.nova_metadata_port, }, 'start_flag': True, 'agent_type': n_const.AGENT_TYPE_METADATA} report_interval = cfg.CONF.AGENT.report_interval if report_interval: self.heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) self.heartbeat.start(interval=report_interval)
def __init__(self, host, conf=None): super(QosAgentWithStateReport, self).__init__(host=host, conf=conf) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.agent_state = { 'binary': 'neutron-qos-agent', 'host': host, 'topic': qos_rpc_agent_api.QOS_AGENT, 'configurations': { 'report_interval': self.conf.report_interval, }, 'start_flag': True, 'agent_type': 'Qos agent', } 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 __init__(self, host, conf=None): self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.agent_state = { 'binary': 'neutron-cisco-cfg-agent', 'host': host, 'topic': c_constants.CFG_AGENT, 'configurations': {}, 'start_flag': True, 'agent_type': c_constants.AGENT_TYPE_CFG} report_interval = cfg.CONF.AGENT.report_interval self.use_call = True self._initialize_rpc(host) self._agent_registration() super(CiscoCfgAgentWithStateReport, self).__init__(host=host, conf=conf) if report_interval: self.heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) self.heartbeat.start(interval=report_interval)
def __init__(self, host=None): super(DhcpAgentWithStateReport, self).__init__(host=host) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.agent_state = { 'binary': 'neutron-dhcp-agent', 'host': host, 'topic': topics.DHCP_AGENT, 'configurations': { 'dhcp_driver': cfg.CONF.dhcp_driver, 'use_namespaces': cfg.CONF.use_namespaces, 'dhcp_lease_duration': cfg.CONF.dhcp_lease_duration}, 'start_flag': True, 'agent_type': constants.AGENT_TYPE_DHCP} 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_server_rpc(self): self.agent_id = 'zvm_agent_%s' % self._zhcp_node self.topic = topics.AGENT self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.context = context.get_admin_context_without_session() self.endpoints = [self] consumers = [[topics.PORT, topics.UPDATE], [topics.NETWORK, topics.DELETE]] 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 __init__(self, host, conf=None): super(TunnelAgentWithStateReport, self).__init__(host=host, conf=conf) self.state_rpc = agent_rpc.PluginReportStateAPI( topics.GRE_DRIVER_TOPIC) self.agent_state = { 'binary': 'neutron-tunnel-agent', 'host': host, 'topic': n_topics.TUNNEL_AGENT, 'configurations': { 'device_driver': self.conf.tunnel_agent.tunnel_device_driver }, 'agent_type': n_constants.AGENT_TYPE_TUNNEL, 'start_flag': True } report_interval = cfg.CONF.tunnel_agent.report_interval self.use_call = False if report_interval: self.heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) self.heartbeat.start(interval=report_interval)
def __init__(self, conf): super(LbaasProxyManager, self).__init__() self.conf = conf self.root_helper = config.get_root_helper(conf) self.context = context.get_admin_context_without_session() self.agent_rpc = LbassProxyApi( '%s-%s' % (topics.LOADBALANCER_INTEGRATION_PROXY, self.conf.cluster_name), self.context, self.conf.host ) self.state_path = self.conf.loadbalancer_state_path self.pools_config = '' self.needs_resync = False self.sync_state() report_interval = self.conf.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
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 = n_rpc.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): mac = self.int_br.get_local_port_mac() self.agent_id = '%s%s' % ('ovs', (mac.replace(":", ""))) self.topic = topics.AGENT self.plugin_rpc = OFAPluginApi(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.SECURITY_GROUP, topics.UPDATE], [topics.L2POPULATION, topics.UPDATE, cfg.CONF.host]] 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): 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.endpoints = [self] consumers = [[constants.INFO, topics.UPDATE]] self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers) if self.polling_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=self.polling_interval)
def __init__(self, host, conf=None): super(MeteringAgentWithStateReport, self).__init__(host=host, conf=conf) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.agent_state = { 'binary': 'neutron-metering-agent', 'host': host, 'topic': topics.METERING_AGENT, 'configurations': { 'metering_driver': self.conf.driver, 'measure_interval': self.conf.measure_interval, 'report_interval': self.conf.report_interval }, 'start_flag': True, 'agent_type': constants.AGENT_TYPE_METERING } 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]] if cfg.CONF.VXLAN.l2_population: consumers.append([topics.L2POPULATION, topics.UPDATE, cfg.CONF.host]) 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 __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): self.agent_id = 'nic-switch-agent.%s' % socket.gethostname() LOG.info(_("RPC agent_id: %s"), self.agent_id) self.topic = topics.AGENT self.plugin_rpc = SriovNicSwitchPluginApi(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 = [SriovNicSwitchRpcCallbacks(self.context, self)] # 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) report_interval = cfg.CONF.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
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.create_connection(new=True) self.context = context.get_admin_context_without_session() self.topic = topics.SSL_VPN_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 = linux_driver.VpnDriverApi( topics.SSL_VPN_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.sslvpn.sslvpn_status_check_interval)
def __init__(self, agent, host): self.host = host self.conn = rpc.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.conn.create_consumer(node_topic, self.create_rpc_dispatcher(), fanout=False) self.conn.consume_in_thread() 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 __init__(self, host, conf=None): if conf: self.conf = conf else: self.conf = cfg.CONF self.root_helper = config.get_root_helper(self.conf) self.router_info = {} self._check_config_params() try: self.driver = importutils.import_object( self.conf.interface_driver, self.conf ) except Exception: msg = _("Error importing interface driver " "'%s'") % self.conf.interface_driver LOG.error(msg) raise SystemExit(1) self.context = context.get_admin_context_without_session() self.plugin_rpc = L3PluginApi(topics.L3PLUGIN, host) self.fullsync = True self.updated_routers = set() self.removed_routers = set() self.sync_progress = False self._clean_stale_namespaces = self.conf.use_namespaces self.rpc_loop = loopingcall.FixedIntervalLoopingCall( self._rpc_loop) self.rpc_loop.start(interval=RPC_LOOP_INTERVAL) super(L3NATAgent, self).__init__(conf=self.conf) self.target_ex_net_id = None
def _start_periodic_tasks(self): self.loop = loopingcall.FixedIntervalLoopingCall(self.process_services) self.loop.start(interval=2)
def do_init(self, conf): LOG.info(_('Initializing LbaasAgentManager')) self.conf = conf self.context = context.get_admin_context_without_session() self.serializer = None global PERIODIC_TASK_INTERVAL PERIODIC_TASK_INTERVAL = self.conf.periodic_interval # create the cache of provisioned services self.cache = LogicalServiceCache() self.last_resync = datetime.datetime.now() self.needs_resync = False self.plugin_rpc = None self.tunnel_rpc = None self.l2_pop_rpc = None self.state_rpc = None self.pending_services = {} if conf.service_resync_interval: self.service_resync_interval = conf.service_resync_interval else: self.service_resync_interval = constants.RESYNC_INTERVAL LOG.debug( _('setting service resync interval to %d seconds' % self.service_resync_interval)) self.lbdriver = importutils.import_object( conf.f5_bigip_lbaas_device_driver, self.conf) # Set the agent ID if self.conf.agent_id: self.agent_host = self.conf.agent_id LOG.debug('setting agent host to %s' % self.agent_host) else: # If not set statically, add the driver agent env hash agent_hash = str( uuid.uuid5( uuid.NAMESPACE_DNS, self.conf.environment_prefix + '.' + self.lbdriver.hostnames[0])) self.agent_host = conf.host + ":" + agent_hash LOG.debug('setting agent host to %s' % self.agent_host) agent_configurations = ({ 'environment_prefix': self.conf.environment_prefix, 'environment_group_number': self.conf.environment_group_number, 'global_routed_mode': self.conf.f5_global_routed_mode }) if self.conf.static_agent_configuration_data: entries = \ str(self.conf.static_agent_configuration_data).split(',') for entry in entries: nv = entry.strip().split(':') if len(nv) > 1: agent_configurations[nv[0]] = nv[1] self.admin_state_up = self.conf.start_agent_admin_state_up self.agent_state = { 'binary': lbaasv1constants.AGENT_BINARY_NAME, 'host': self.agent_host, 'topic': lbaasv1constants.TOPIC_LOADBALANCER_AGENT, 'agent_type': neutron_constants.AGENT_TYPE_LOADBALANCER, 'l2_population': self.conf.l2_population, 'configurations': agent_configurations, 'start_flag': True } # Setup RPC for communications to and from controller self._setup_rpc() # Load the driver. self._load_driver(conf) # Set driver context for RPC. self.lbdriver.set_context(self.context) # Allow the driver to make callbacks to the LBaaS driver plugin self.lbdriver.set_plugin_rpc(self.plugin_rpc) # Allow the driver to update tunnel endpoints self.lbdriver.set_tunnel_rpc(self.tunnel_rpc) # Allow the driver to update forwarding records in the SDN self.lbdriver.set_l2pop_rpc(self.l2_pop_rpc) # Allow the driver to force and agent state report to the controller self.lbdriver.set_agent_report_state(self._report_state) # Set the flag to resync tunnels/services self.needs_resync = True # Mark this agent admin_state_up per startup policy if (self.admin_state_up): self.plugin_rpc.set_agent_admin_state(self.admin_state_up) # Start state reporting of agent to Neutron report_interval = self.conf.AGENT.report_interval if report_interval: heartbeat = loopingcall.FixedIntervalLoopingCall( self._report_state) heartbeat.start(interval=report_interval)
def start_polling(self, interval): loop_call = loopingcall.FixedIntervalLoopingCall(self._run) loop_call.start(interval=interval) return loop_call
def _setup_backlog_handling(self): self._heartbeat = loopingcall.FixedIntervalLoopingCall( self._process_backlogged_routers) self._heartbeat.start( interval=cfg.CONF.general.backlog_processing_interval)
def _start_periodic_tasks(self): self.loop = loopingcall.FixedIntervalLoopingCall(self.process_services) self.loop.start(interval=self.conf.cfg_agent.rpc_loop_interval)
def _setup_rpc(self): # LBaaS Callbacks API topic = lbaasv1constants.TOPIC_PROCESS_ON_HOST if self.conf.environment_specific_plugin: topic = topic + '_' + self.conf.environment_prefix LOG.debug('agent in %s environment will send callbacks to %s' % (self.conf.environment_prefix, topic)) self.plugin_rpc = agent_api.LbaasAgentApi( topic, self.context, self.conf.environment_prefix, self.conf.environment_group_number, self.agent_host ) # Allow driver to make callbacks using the # same RPC proxy as the manager self.lbdriver.set_plugin_rpc(self.plugin_rpc) # Agent state Callbacks 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) # The LBaaS agent listener with it's host are registered # as part of the rpc.Service. Here we are setting up # other message queues to listen for updates from # Neutron. if not self.conf.f5_global_routed_mode: # Core plugin Callbacks API for tunnel updates self.lbdriver.set_tunnel_rpc(agent_api.CoreAgentApi(topics.PLUGIN)) # L2 Populate plugin Callbacks API if self.conf.l2_population: self.lbdriver.set_l2pop_rpc(agent_api.L2PopulationApi()) # Besides LBaaS Plugin calls... what else to consume # tunnel updates to support vxlan and gre endpoint # NOTE: the driver can decide to handle endpoint # membership based on the rpc notification or through # other means (i.e. as part of a service definition) consumers = [[constants.TUNNEL, topics.UPDATE]] # L2 populate fdb calls # NOTE: the driver can decide to handle fdb updates # or use some other mechanism (i.e. flooding) to # learn about port updates. if self.conf.l2_population: consumers.append( [topics.L2POPULATION, topics.UPDATE, self.agent_host] ) if preJuno: self.dispatcher = dispatcher.RpcDispatcher([self]) else: self.endpoints = [self] LOG.debug(_('registering to %s consumer on RPC topic: %s' % (consumers, topics.AGENT))) if preJuno: self.connection = agent_rpc.create_consumers( self.dispatcher, topics.AGENT, consumers ) else: self.connection = agent_rpc.create_consumers( self.endpoints, topics.AGENT, consumers )