def setup_rpc(self): self.host = socket.gethostname() self.agent_id = 'nec-q-agent.%s' % self.host LOG.info(_LI("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_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context, self.sg_plugin_rpc) # 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, physical_devices_mappings, exclude_devices, polling_interval): self.polling_interval = polling_interval self.conf = cfg.CONF self.setup_eswitch_mgr(physical_devices_mappings, exclude_devices) configurations = {'device_mappings': physical_devices_mappings} self.agent_state = { 'binary': 'neutron-sriov-nic-agent', 'host': self.conf.host, 'topic': n_constants.L2_AGENT_TOPIC, 'configurations': configurations, 'agent_type': n_constants.AGENT_TYPE_NIC_SWITCH, 'start_flag': True } # Stores port update notifications for processing in the main loop self.updated_devices = set() self.mac_to_port_id_mapping = {} self.context = context.get_admin_context_without_session() self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN) self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context, self.sg_plugin_rpc) self._setup_rpc() self.ext_manager = self._create_agent_extension_manager( self.connection) # The initialization is complete; we can start receiving messages self.connection.consume_in_threads() # Initialize iteration counter self.iter_num = 0
def __init__(self, physical_devices_mappings, exclude_devices, polling_interval): self.polling_interval = polling_interval self.setup_eswitch_mgr(physical_devices_mappings, exclude_devices) configurations = {'device_mappings': physical_devices_mappings} self.agent_state = { 'binary': 'neutron-sriov-nic-agent', 'host': cfg.CONF.host, 'topic': q_constants.L2_AGENT_TOPIC, 'configurations': configurations, 'agent_type': q_constants.AGENT_TYPE_NIC_SWITCH, 'start_flag': True } # Stores port update notifications for processing in the main loop self.updated_devices = set() self.context = context.get_admin_context_without_session() self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN) self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context, self.sg_plugin_rpc) self._setup_rpc() # Initialize iteration counter self.iter_num = 0
def setup_rpc(self): self.host = socket.gethostname() self.agent_id = 'nvsd-q-agent.%s' % self.host LOG.info(_LI("RPC agent_id: %s"), self.agent_id) self.topic = topics.AGENT self.context = n_context.get_admin_context_without_session() self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context, self.sg_plugin_rpc, self.root_helper) # RPC network init # Handle updates from service self.callback_oc = NVSDAgentRpcCallback(self.context, self, self.sg_agent) self.callback_sg = SecurityGroupAgentRpcCallback( self.context, self.sg_agent) self.endpoints = [self.callback_oc, 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)
def start(self): self.prevent_arp_spoofing = cfg.CONF.AGENT.prevent_arp_spoofing self.setup_linux_bridge(self.bridge_mappings, self.interface_mappings) configurations = { 'bridge_mappings': self.bridge_mappings, 'interface_mappings': self.interface_mappings } if self.br_mgr.vxlan_mode != lconst.VXLAN_NONE: configurations['tunneling_ip'] = self.br_mgr.local_ip configurations['tunnel_types'] = [p_const.TYPE_VXLAN] configurations['l2_population'] = cfg.CONF.VXLAN.l2_population self.agent_state = { 'binary': 'neutron-linuxbridge-agent', 'host': cfg.CONF.host, 'topic': constants.L2_AGENT_TOPIC, 'configurations': configurations, 'agent_type': constants.AGENT_TYPE_LINUXBRIDGE, 'start_flag': True } # stores received port_updates for processing by the main loop self.updated_devices = set() # flag to do a sync after revival self.fullsync = False self.context = context.get_admin_context_without_session() self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN) self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.sg_agent = sg_rpc.SecurityGroupAgentRpc( self.context, self.sg_plugin_rpc, defer_refresh_firewall=True) self.setup_rpc(self.interface_mappings.values()) self.daemon_loop()
def __init__(self, interface_mappings, polling_interval): self.polling_interval = polling_interval self.setup_linux_bridge(interface_mappings) configurations = {'interface_mappings': interface_mappings} if self.br_mgr.vxlan_mode != lconst.VXLAN_NONE: configurations['tunneling_ip'] = self.br_mgr.local_ip configurations['tunnel_types'] = [p_const.TYPE_VXLAN] configurations['l2_population'] = cfg.CONF.VXLAN.l2_population self.agent_state = { 'binary': 'neutron-linuxbridge-agent', 'host': cfg.CONF.host, 'topic': constants.L2_AGENT_TOPIC, 'configurations': configurations, 'agent_type': constants.AGENT_TYPE_LINUXBRIDGE, 'start_flag': True } # stores received port_updates for processing by the main loop self.updated_devices = set() self.context = context.get_admin_context_without_session() self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN) self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context, self.sg_plugin_rpc) self.setup_rpc(interface_mappings.values())
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 __init__(self, integ_br, polling_interval, vs='ovs'): super(RestProxyAgent, self).__init__() self.polling_interval = polling_interval self._setup_rpc() self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context, self.sg_plugin_rpc) if vs == 'ivs': self.int_br = IVSBridge(integ_br) else: self.int_br = ovs_lib.OVSBridge(integ_br)
def __init__(self, physical_devices_mappings, exclude_devices, polling_interval, rp_bandwidths, rp_inventory_defaults, rp_hypervisors): self.polling_interval = polling_interval self.network_ports = collections.defaultdict(list) self.conf = cfg.CONF self.device_mappings = physical_devices_mappings self.exclude_devices = exclude_devices self.setup_eswitch_mgr(physical_devices_mappings, exclude_devices) # Stores port update notifications for processing in the main loop self.updated_devices = set() # Stores <mac, pci_slot> pairs for ports whose binding has been # activated. self.activated_bindings = set() self.context = context.get_admin_context_without_session() 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) self._setup_rpc() self.ext_manager = self._create_agent_extension_manager( self.connection) configurations = { 'device_mappings': physical_devices_mappings, n_constants.RP_BANDWIDTHS: rp_bandwidths, n_constants.RP_INVENTORY_DEFAULTS: rp_inventory_defaults, 'resource_provider_hypervisors': rp_hypervisors, 'extensions': self.ext_manager.names() } # TODO(mangelajo): optimize resource_versions (see ovs agent) self.agent_state = { 'binary': n_constants.AGENT_PROCESS_NIC_SWITCH, 'host': self.conf.host, 'topic': n_constants.L2_AGENT_TOPIC, 'configurations': configurations, 'agent_type': n_constants.AGENT_TYPE_NIC_SWITCH, 'resource_versions': resources.LOCAL_RESOURCE_VERSIONS, 'start_flag': True } # The initialization is complete; we can start receiving messages self.connection.consume_in_threads() # Initialize iteration counter self.iter_num = 0
def setUp(self): super(TestOneConvergenceAgentBase, self).setUp() cfg.CONF.set_default('firewall_driver', 'neutron.agent.firewall.NoopFirewallDriver', group='SECURITYGROUP') with mock.patch('oslo_service.loopingcall.' 'FixedIntervalLoopingCall') as loopingcall: kwargs = {'integ_br': 'integration_bridge', 'polling_interval': 5} context = mock.Mock() self.agent = nvsd_neutron_agent.NVSDNeutronAgent(**kwargs) sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.sg_agent = sg_rpc.SecurityGroupAgentRpc( context, sg_plugin_rpc) self.callback_nvsd = nvsd_neutron_agent.NVSDAgentRpcCallback( context, self.agent, self.sg_agent) self.loopingcall = loopingcall
def __init__(self, physical_devices_mappings, exclude_devices, polling_interval): self.polling_interval = polling_interval self.network_ports = collections.defaultdict(list) self.conf = cfg.CONF self.device_mappings = physical_devices_mappings self.exclude_devices = exclude_devices self.setup_eswitch_mgr(physical_devices_mappings, exclude_devices) # Stores port update notifications for processing in the main loop self.updated_devices = set() self.context = context.get_admin_context_without_session() 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) self._setup_rpc() self.ext_manager = self._create_agent_extension_manager( self.connection) configurations = { 'device_mappings': physical_devices_mappings, 'extensions': self.ext_manager.names() } #TODO(mangelajo): optimize resource_versions (see ovs agent) self.agent_state = { 'binary': 'neutron-sriov-nic-agent', 'host': self.conf.host, 'topic': n_constants.L2_AGENT_TOPIC, 'configurations': configurations, 'agent_type': n_constants.AGENT_TYPE_NIC_SWITCH, 'resource_versions': resources.LOCAL_RESOURCE_VERSIONS, 'start_flag': True } # The initialization is complete; we can start receiving messages self.connection.consume_in_threads() # Initialize iteration counter self.iter_num = 0
def setup_rpc(self): self.agent_id = 'opflex-agent-%s' % cfg.CONF.host self.context = context.get_admin_context_without_session() # Set GBP rpc API self.of_rpc = rpc.GBPServerRpcApi(rpc.TOPIC_OPFLEX) self.plugin_rpc = ovs.OVSPluginApi(topics.PLUGIN) self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.sg_agent = sg_rpc.SecurityGroupAgentRpc( self.context, self.sg_plugin_rpc, defer_refresh_firewall=True) self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self.topic = topics.AGENT self.endpoints = [self] consumers = [[topics.PORT, topics.UPDATE], [topics.PORT, topics.DELETE], [topics.SECURITY_GROUP, topics.UPDATE], [topics.SUBNET, topics.UPDATE], [rpc.TOPIC_OPFLEX, rpc.VRF, topics.UPDATE]] self.connection = agent_rpc.create_consumers( self.endpoints, self.topic, consumers, start_listening=False)
def __init__(self, interface_mapping, root_helper): self._polling_interval = cfg.CONF.AGENT.polling_interval self._setup_eswitches(interface_mapping) configurations = {'interface_mappings': interface_mapping} self.agent_state = { 'binary': 'neutron-mlnx-agent', 'host': cfg.CONF.host, 'topic': q_constants.L2_AGENT_TOPIC, 'configurations': configurations, 'agent_type': q_constants.AGENT_TYPE_MLNX, 'start_flag': True } # Stores port update notifications for processing in main rpc loop self.updated_ports = set() self.context = context.get_admin_context_without_session() self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN) self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN) self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context, self.sg_plugin_rpc, root_helper) self._setup_rpc()
def __init__(self, ryuapp, integ_br, local_ip, bridge_mappings, interface_mappings, polling_interval, tunnel_types=None): """Constructor. :param ryuapp: object of the ryu app. :param integ_br: name of the integration bridge. :param local_ip: local IP address of this hypervisor. :param bridge_mappings: mappings from physical network name to bridge. (deprecated) :param interface_mappings: mappings from physical network name to interface. :param polling_interval: interval (secs) to poll DB. :param tunnel_types: A list of tunnel types to enable support for in the agent. If set, will automatically set enable_tunneling to True. """ super(OFANeutronAgent, self).__init__() self.ryuapp = ryuapp # TODO(yamamoto): Remove this VLAN leftover self.available_local_vlans = set( range(ofa_const.LOCAL_VLAN_MIN, ofa_const.LOCAL_VLAN_MAX)) self.tunnel_types = tunnel_types or [] l2pop_network_types = list( set(self.tunnel_types + [p_const.TYPE_VLAN, p_const.TYPE_FLAT, p_const.TYPE_LOCAL])) self.agent_state = { 'binary': 'neutron-ofa-agent', 'host': cfg.CONF.host, 'topic': n_const.L2_AGENT_TOPIC, 'configurations': { 'bridge_mappings': bridge_mappings, 'interface_mappings': interface_mappings, 'tunnel_types': self.tunnel_types, 'tunneling_ip': local_ip, 'l2_population': True, 'l2pop_network_types': l2pop_network_types }, 'agent_type': n_const.AGENT_TYPE_OFA, 'start_flag': True } # Keep track of int_br's device count for use by _report_state() self.int_br_device_count = 0 self.int_br = Bridge(integ_br, self.ryuapp) # Stores port update notifications for processing in main loop self.updated_ports = set() self.setup_rpc() self.setup_integration_br() self.int_ofports = {} self.setup_physical_interfaces(interface_mappings) self.local_vlan_map = {} self.tun_ofports = {} # network_type -> tunnel ofport self.polling_interval = polling_interval self.enable_tunneling = bool(self.tunnel_types) self.local_ip = local_ip self.tunnel_count = 0 self.vxlan_udp_port = cfg.CONF.AGENT.vxlan_udp_port self.dont_fragment = cfg.CONF.AGENT.dont_fragment # Security group agent support self.sg_agent = sg_rpc.SecurityGroupAgentRpc( self.context, self.sg_plugin_rpc, defer_refresh_firewall=True) # Initialize iteration counter self.iter_num = 0