def remove_empty_bridges(): try: interface_mappings = n_utils.parse_mappings( cfg.CONF.LINUX_BRIDGE.physical_interface_mappings) except ValueError as e: LOG.error(_LE("Parsing physical_interface_mappings failed: %s."), e) sys.exit(1) LOG.info(_LI("Interface mappings: %s."), interface_mappings) try: bridge_mappings = n_utils.parse_mappings( cfg.CONF.LINUX_BRIDGE.bridge_mappings) except ValueError as e: LOG.error(_LE("Parsing bridge_mappings failed: %s."), e) sys.exit(1) LOG.info(_LI("Bridge mappings: %s."), bridge_mappings) lb_manager = linuxbridge_neutron_agent.LinuxBridgeManager( bridge_mappings, interface_mappings) # NOTE(mgagne) Don't remove pre-existing user-defined bridges bridge_names = set(lb_manager.get_all_neutron_bridges()) bridge_names -= set(bridge_mappings.values()) for bridge_name in bridge_names: if lb_manager.get_tap_devices_count(bridge_name): continue try: lb_manager.delete_bridge(bridge_name) LOG.info(_LI("Linux bridge %s deleted"), bridge_name) except RuntimeError: LOG.exception(_LE("Linux bridge %s delete failed"), bridge_name) LOG.info(_LI("Linux bridge cleanup completed successfully"))
def create_agent_config_map(config): """Create a map of agent config parameters. :param config: an instance of cfg.CONF :returns: a map of agent configuration parameters """ try: bridge_mappings = n_utils.parse_mappings(config.OVS.bridge_mappings) except ValueError as e: raise ValueError(_("Parsing bridge_mappings failed: %s.") % e) try: interface_mappings = n_utils.parse_mappings(config.AGENT.physical_interface_mappings) except ValueError as e: raise ValueError(_("Parsing physical_interface_mappings failed: %s.") % e) kwargs = dict( integ_br=config.OVS.integration_bridge, local_ip=config.OVS.local_ip, interface_mappings=interface_mappings, bridge_mappings=bridge_mappings, polling_interval=config.AGENT.polling_interval, tunnel_types=config.AGENT.tunnel_types, ) # Verify the tunnel_types specified are valid for tun in kwargs["tunnel_types"]: if tun not in constants.TUNNEL_NETWORK_TYPES: msg = _("Invalid tunnel type specificed: %s"), tun raise ValueError(msg) if not kwargs["local_ip"]: msg = _("Tunneling cannot be enabled without a valid local_ip.") raise ValueError(msg) return kwargs
def main(): common_config.init(sys.argv[1:]) common_config.setup_logging() try: interface_mappings = n_utils.parse_mappings( cfg.CONF.LINUX_BRIDGE.physical_interface_mappings) except ValueError as e: LOG.error(_LE("Parsing physical_interface_mappings failed: %s. " "Agent terminated!"), e) sys.exit(1) LOG.info(_LI("Interface mappings: %s"), interface_mappings) try: bridge_mappings = n_utils.parse_mappings( cfg.CONF.LINUX_BRIDGE.bridge_mappings) except ValueError as e: LOG.error(_LE("Parsing bridge_mappings failed: %s. " "Agent terminated!"), e) sys.exit(1) LOG.info(_LI("Bridge mappings: %s"), bridge_mappings) manager = LinuxBridgeManager(bridge_mappings, interface_mappings) polling_interval = cfg.CONF.AGENT.polling_interval quitting_rpc_timeout = cfg.CONF.AGENT.quitting_rpc_timeout agent = ca.CommonAgentLoop(manager, polling_interval, quitting_rpc_timeout, constants.AGENT_TYPE_LINUXBRIDGE, LB_AGENT_BINARY) LOG.info(_LI("Agent initialized successfully, now running... ")) launcher = service.launch(cfg.CONF, agent) launcher.wait()
def main(): common_config.init(sys.argv[1:]) common_config.setup_logging() try: interface_mappings = n_utils.parse_mappings( cfg.CONF.LINUX_BRIDGE.physical_interface_mappings) except ValueError as e: LOG.error( _LE("Parsing physical_interface_mappings failed: %s. " "Agent terminated!"), e) sys.exit(1) LOG.info(_LI("Interface mappings: %s"), interface_mappings) try: bridge_mappings = n_utils.parse_mappings( cfg.CONF.LINUX_BRIDGE.bridge_mappings) except ValueError as e: LOG.error( _LE("Parsing bridge_mappings failed: %s. " "Agent terminated!"), e) sys.exit(1) LOG.info(_LI("Bridge mappings: %s"), bridge_mappings) manager = LinuxBridgeManager(bridge_mappings, interface_mappings) polling_interval = cfg.CONF.AGENT.polling_interval quitting_rpc_timeout = cfg.CONF.AGENT.quitting_rpc_timeout agent = ca.CommonAgentLoop(manager, polling_interval, quitting_rpc_timeout, constants.AGENT_TYPE_LINUXBRIDGE, LB_AGENT_BINARY) LOG.info(_LI("Agent initialized successfully, now running... ")) launcher = service.launch(cfg.CONF, agent) launcher.wait()
def __init__(self): LOG.debug(_('L2HighNeutronAgent init is STARTING')) self.conf = cfg.CONF try: self.bridge_mappings = common_utils.parse_mappings(self.conf.bridge_mappings) except ValueError as e: raise ValueError(_("Parsing bridge_mappings failed: %s.") % e) self.context = context.get_admin_context_without_session() self.agent_id = 'ovs-agent-%s' % self.conf.host self.l2_plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN) self.l2_state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self._set_l2_rpc_consumers() self.use_call = True self.local_vlan_map = {} self.tunnel_types = [p_const.TYPE_VXLAN] self.l2_pop = self.conf.l2_population self.local_ip = self.conf.local_ip self.arp_responder_enabled = self.conf.arp_responder and self.l2_pop self.l2pop_network_types = self.conf.l2pop_network_types or self.tunnel_types self.l2_agent_state = { 'binary': 'neutron-openvswitch-agent', 'host': self.conf.host, 'topic': l3_constants.L2_AGENT_TOPIC, 'configurations': { 'bridge_mappings': self.bridge_mappings, 'tunnel_types': self.tunnel_types, 'tunneling_ip': self.local_ip.split('/')[0], 'l2_population': self.l2_pop, 'l2pop_network_types': self.l2pop_network_types, 'arp_responder_enabled':self.arp_responder_enabled, 'enable_distributed_routing': True }, 'agent_type': l3_constants.AGENT_TYPE_OVS, 'start_flag': True} LOG.debug(_('RPC l2_state_report heartbeat start'))
def get_chassis_hostname_and_physnets(self): chassis_info_dict = {} for ch in self.idl.tables['Chassis'].rows.values(): bridge_mappings = ch.external_ids.get('ovn-bridge-mappings', '') mapping_dict = n_utils.parse_mappings(bridge_mappings.split(',')) chassis_info_dict[ch.hostname] = mapping_dict.keys() return chassis_info_dict
def main(): common_config.init(sys.argv[1:]) common_config.setup_logging() try: interface_mappings = utils.parse_mappings( cfg.CONF.ESWITCH.physical_interface_mappings) except ValueError as e: LOG.error(_LE("Parsing physical_interface_mappings failed: %s. " "Agent terminated!"), e) sys.exit(1) LOG.info(_LI("Interface mappings: %s"), interface_mappings) try: agent = mlnx_eswitch_neutron_agent.MlnxEswitchNeutronAgent( interface_mappings) except Exception as e: LOG.error(_LE("Failed on Agent initialisation : %s. " "Agent terminated!"), e) sys.exit(1) # Start everything. LOG.info(_LI("Agent initialised successfully, now running... ")) agent.run() sys.exit(0)
def test_device_mappings_with_spaces(self): cfg.CONF.set_override('physical_device_mappings', self.DEVICE_MAPPING_WITH_SPACES_LIST, 'SRIOV_NIC') device_mappings = n_utils.parse_mappings( cfg.CONF.SRIOV_NIC.physical_device_mappings, unique_keys=False) self.assertEqual(self.DEVICE_MAPPING, device_mappings)
def main(): eventlet.monkey_patch() cfg.CONF(project='neutron') # fix-neutron-agent-for-mtu-config hack cfg.CONF.register_opts(interface.OPTS) logging_config.setup_logging(cfg.CONF) LOG.info(_("network_device_mtu: %s"), str(cfg.CONF.network_device_mtu)) try: interface_mappings = q_utils.parse_mappings( cfg.CONF.LINUX_BRIDGE.physical_interface_mappings) except ValueError as e: LOG.error( _("Parsing physical_interface_mappings failed: %s." " Agent terminated!"), e) sys.exit(1) LOG.info(_("Interface mappings: %s"), interface_mappings) polling_interval = cfg.CONF.AGENT.polling_interval root_helper = cfg.CONF.AGENT.root_helper agent = LinuxBridgeNeutronAgentRPC(interface_mappings, polling_interval, root_helper) LOG.info(_("Agent initialized successfully, now running... ")) agent.daemon_loop() sys.exit(0)
def _parse_physical_network_types(self): """Parse physical network types configuration. Verify default physical network type is valid. Parse physical network mappings. """ self.physical_net_type = cfg.CONF.MLNX.physical_network_type if self.physical_net_type not in (constants.TYPE_ETH, constants.TYPE_IB): LOG.error(_("Invalid physical network type %(type)s." "Server terminated!"), {'type': self.physical_net_type}) raise SystemExit(1) try: self.phys_network_type_maps = utils.parse_mappings( cfg.CONF.MLNX.physical_network_type_mappings) except ValueError as e: LOG.error(_("Parsing physical_network_type failed: %s." " Server terminated!"), e) raise SystemExit(1) for network, type in self.phys_network_type_maps.iteritems(): if type not in (constants.TYPE_ETH, constants.TYPE_IB): LOG.error(_("Invalid physical network type %(type)s " " for network %(net)s. Server terminated!"), {'net': network, 'type': type}) raise SystemExit(1) LOG.info(_("Physical Network type mappings: %s"), self.phys_network_type_maps)
def __init__(self): try: self.physnet_mtus = utils.parse_mappings( cfg.CONF.ml2.physical_network_mtus ) except Exception: self.physnet_mtus = []
def _parse_physical_network_types(self): """Parse physical network types configuration. Verify default physical network type is valid. Parse physical network mappings. """ self.physical_net_type = cfg.CONF.MLNX.physical_network_type if self.physical_net_type not in (constants.TYPE_ETH, constants.TYPE_IB): LOG.error( _("Invalid physical network type %(type)s." "Server terminated!"), {'type': self.physical_net_type}) raise SystemExit(1) try: self.phys_network_type_maps = utils.parse_mappings( cfg.CONF.MLNX.physical_network_type_mappings) except ValueError as e: LOG.error( _("Parsing physical_network_type failed: %s." " Server terminated!"), e) raise SystemExit(1) for network, type in self.phys_network_type_maps.iteritems(): if type not in (constants.TYPE_ETH, constants.TYPE_IB): LOG.error( _("Invalid physical network type %(type)s " " for network %(net)s. Server terminated!"), { 'net': network, 'type': type }) raise SystemExit(1) LOG.info(_("Physical Network type mappings: %s"), self.phys_network_type_maps)
def main(): eventlet.monkey_patch() cfg.CONF(project='neutron') logging_config.setup_logging(cfg.CONF) try: interface_mappings = q_utils.parse_mappings( cfg.CONF.ESWITCH.physical_interface_mappings) except ValueError as e: LOG.error(_("Parsing physical_interface_mappings failed: %s." " Agent terminated!"), e) sys.exit(1) LOG.info(_("Interface mappings: %s"), interface_mappings) try: agent = MlnxEswitchNeutronAgent(interface_mappings) except Exception as e: LOG.error(_("Failed on Agent initialisation : %s." " Agent terminated!"), e) sys.exit(1) # Start everything. LOG.info(_("Agent initialised successfully, now running... ")) agent.daemon_loop() sys.exit(0)
def main(): eventlet.monkey_patch() cfg.CONF(project='neutron') # fix-neutron-agent-for-mtu-config hack cfg.CONF.register_opts(interface.OPTS) logging_config.setup_logging(cfg.CONF) LOG.info(_("network_device_mtu: %s"), str(cfg.CONF.network_device_mtu)) try: interface_mappings = q_utils.parse_mappings( cfg.CONF.LINUX_BRIDGE.physical_interface_mappings) except ValueError as e: LOG.error(_("Parsing physical_interface_mappings failed: %s." " Agent terminated!"), e) sys.exit(1) LOG.info(_("Interface mappings: %s"), interface_mappings) polling_interval = cfg.CONF.AGENT.polling_interval root_helper = cfg.CONF.AGENT.root_helper agent = LinuxBridgeNeutronAgentRPC(interface_mappings, polling_interval, root_helper) LOG.info(_("Agent initialized successfully, now running... ")) agent.daemon_loop() sys.exit(0)
def __init__(self, quitting_rpc_timeout=None, conf=None): super(DvsNeutronAgent, self).__init__() self.pool = eventlet.greenpool.GreenPool( size=10) # Start small, so we identify possible bottlenecks self.conf = conf or CONF self.agent_state = { 'binary': 'neutron-dvs-agent', 'host': self.conf.host, 'topic': n_const.L2_AGENT_TOPIC, 'configurations': { 'network_maps': neutron_utils.parse_mappings(self.conf.ML2_VMWARE.network_maps) }, 'agent_type': dvs_constants.AGENT_TYPE_DVS, 'start_flag': True } self.setup_rpc() report_interval = self.conf.AGENT.report_interval or 5 heartbeat = loopingcall.FixedIntervalLoopingCall(self._report_state) heartbeat.start(interval=report_interval, stop_on_exception=False) self.polling_interval = 10 self.api = vcenter_util.VCenter(self.conf.ML2_VMWARE, pool=self.pool) self.enable_security_groups = self.conf.get('SECURITYGROUP', {}).get( 'enable_security_group', False) # Security group agent support if self.enable_security_groups: self.api.setup_security_groups_support() self.sg_agent = dvs_rpc.DVSSecurityGroupRpc( self.context, self.sg_plugin_rpc, local_vlan_map=None, integration_bridge=self.api, # Passed on to FireWall Driver defer_refresh_firewall=True) # Can only be false, if ... # ... we keep track of all the security groups of a port, and probably more changes self.run_daemon_loop = True self.iter_num = 0 self.quitting_rpc_timeout = quitting_rpc_timeout self.updated_ports = {} self.known_ports = {} self.unbound_ports = {} self.deleted_ports = set() self.added_ports = set() self.network_ports = collections.defaultdict(set) self.catch_sigterm = False self.catch_sighup = False self.connection.consume_in_threads()
def __init__(self): try: self.physnet_mtus = utils.parse_mappings( cfg.CONF.ml2.physical_network_mtus, unique_values=False) except Exception as e: LOG.error(_LE("Failed to parse physical_network_mtus: %s"), e) self.physnet_mtus = []
def main(): common_config.init(sys.argv[1:]) common_config.setup_logging() try: interface_mappings = utils.parse_mappings( cfg.CONF.ESWITCH.physical_interface_mappings) except ValueError as e: LOG.error( _LE("Parsing physical_interface_mappings failed: %s. " "Agent terminated!"), e) sys.exit(1) LOG.info(_LI("Interface mappings: %s"), interface_mappings) root_helper = cfg.CONF.AGENT.root_helper try: agent = mlnx_eswitch_neutron_agent.MlnxEswitchNeutronAgent( interface_mappings, root_helper) except Exception as e: LOG.error( _LE("Failed on Agent initialisation : %s. " "Agent terminated!"), e) sys.exit(1) # Start everything. LOG.info(_LI("Agent initialised successfully, now running... ")) agent.run() sys.exit(0)
def test_device_mappings_with_spaces(self): cfg.CONF.set_override('physical_device_mappings', self.DEVICE_MAPPING_WITH_SPACES_LIST, 'SRIOV_NIC') device_mappings = q_utils.parse_mappings( cfg.CONF.SRIOV_NIC.physical_device_mappings) self.assertEqual(device_mappings, self.DEVICE_MAPPING)
def create_agent_config_map(config): """Create a map of agent config parameters. :param config: an instance of cfg.CONF :returns: a map of agent configuration parameters """ try: bridge_mappings = q_utils.parse_mappings(config.OVS.bridge_mappings) except ValueError as e: raise ValueError(_("Parsing bridge_mappings failed: %s.") % e) kwargs = dict( integ_br=config.OVS.integration_bridge, tun_br=config.OVS.tunnel_bridge, local_ip=config.OVS.local_ip, bridge_mappings=bridge_mappings, root_helper=config.AGENT.root_helper, polling_interval=config.AGENT.polling_interval, tunnel_types=config.AGENT.tunnel_types, ) # If enable_tunneling is TRUE, set tunnel_type to default to GRE if config.OVS.enable_tunneling and not kwargs['tunnel_types']: kwargs['tunnel_types'] = [constants.TYPE_GRE] # Verify the tunnel_types specified are valid for tun in kwargs['tunnel_types']: if tun not in constants.TUNNEL_NETWORK_TYPES: msg = _('Invalid tunnel type specificed: %s'), tun raise ValueError(msg) if not kwargs['local_ip']: msg = _('Tunneling cannot be enabled without a valid local_ip.') raise ValueError(msg) return kwargs
def __init__(self, root_helper=None, **kwargs): self.opflex_networks = kwargs['opflex_networks'] if self.opflex_networks and self.opflex_networks[0] == '*': self.opflex_networks = None self.root_helper = root_helper self.notify_worker = opflex_notify.worker() self.host = cfg.CONF.host agent_conf = cfg.CONF.AGENT ovs_conf = cfg.CONF.OVS try: bridge_mappings = q_utils.parse_mappings(ovs_conf.bridge_mappings) except ValueError as e: raise ValueError(_("Parsing bridge_mappings failed: %s.") % e) self.agent_state = { 'binary': 'neutron-opflex-agent', 'host': self.host, 'topic': n_constants.L2_AGENT_TOPIC, 'configurations': { 'bridge_mappings': bridge_mappings, 'opflex_networks': self.opflex_networks }, 'agent_type': ofcst.AGENT_TYPE_OPFLEX_OVS, 'start_flag': True } # Initialize OVS Manager self.bridge_manager = ovs_manager.OvsManager().initialize( self.host, ovs_conf) # Stores port update notifications for processing in main rpc loop self.updated_ports = set() # Stores port delete notifications self.deleted_ports = set() # Stores VRF update notifications self.updated_vrf = set() self.setup_rpc() self.local_ip = ovs_conf.local_ip self.polling_interval = agent_conf.polling_interval self.config_apply_interval = kwargs['config_apply_interval'] self.minimize_polling = agent_conf.minimize_polling self.ovsdb_monitor_respawn_interval = ( agent_conf.ovsdb_monitor_respawn_interval or constants.DEFAULT_OVSDBMON_RESPAWN) self.setup_report() self.supported_pt_network_types = [ofcst.TYPE_OPFLEX] # Initialize iteration counter self.iter_num = 0 self.run_daemon_loop = True # The initialization is complete; we can start receiving messages self.connection.consume_in_threads() self.quitting_rpc_timeout = agent_conf.quitting_rpc_timeout # Initialize the Endpoint Manager. # TODO(ivar): make these components pluggable. self.ep_manager = ep_manager.EndpointFileManager().initialize( self.host, self.bridge_manager, kwargs) self.port_manager = port_manager.AsyncPortManager().initialize( self.host, self, kwargs)
def test_device_mappings(self): cfg.CONF.set_override('physical_device_mappings', self.DEVICE_MAPPING_LIST, 'SRIOV_NIC') device_mappings = q_utils.parse_mappings( cfg.CONF.SRIOV_NIC.physical_device_mappings) self.assertEqual(device_mappings, self.DEVICE_MAPPING)
def create_network_map_from_config(config, connection=None, pool=None): """Creates physical network to dvs map from config""" connection = connection or connect(config) network_map = {} for network, dvs in six.iteritems(neutron_utils.parse_mappings(config.network_maps)): network_map[network] = DVSController(dvs, connection=connection, pool=pool, rectify_wait=config.host_rectify_timeout) return network_map
def __init__(self): try: self.physnet_mtus = utils.parse_mappings( cfg.CONF.ml2.physical_network_mtus, unique_values=False ) except Exception as e: LOG.error(_LE("Failed to parse physical_network_mtus: %s"), e) self.physnet_mtus = []
def parse(self): """Parses device_mappings and exclude_devices. Parse and validate the consistency in both mappings """ self.device_mappings = n_utils.parse_mappings(cfg.CONF.SRIOV_NIC.physical_device_mappings) self.exclude_devices = config.parse_exclude_devices(cfg.CONF.SRIOV_NIC.exclude_devices) self._validate()
def parse(self): """Parses device_mappings and exclude_devices. Parse and validate the consistency in both mappings """ self.device_mappings = n_utils.parse_mappings( cfg.CONF.SRIOV_NIC.physical_device_mappings) self.exclude_devices = config.parse_exclude_devices( cfg.CONF.SRIOV_NIC.exclude_devices) self._validate()
def parse_interface_mappings(): try: interface_mappings = n_utils.parse_mappings( cfg.CONF.macvtap.physical_interface_mappings) LOG.info(_LI("Interface mappings: %s"), interface_mappings) return interface_mappings except ValueError as e: LOG.error(_LE("Parsing physical_interface_mappings failed: %s. " "Agent terminated!"), e) sys.exit(1)
def create_agent_config_map(config): """Create a map of agent config parameters. :param config: an instance of cfg.CONF :returns: a map of agent configuration parameters """ try: bridge_mappings = n_utils.parse_mappings(config.OVS.bridge_mappings) except ValueError as e: raise ValueError(_("Parsing bridge_mappings failed: %s.") % e) try: interface_mappings = n_utils.parse_mappings( config.AGENT.physical_interface_mappings) except ValueError as e: raise ValueError( _("Parsing physical_interface_mappings failed: %s.") % e) kwargs = dict( integ_br=config.OVS.integration_bridge, local_ip=config.OVS.local_ip, interface_mappings=interface_mappings, bridge_mappings=bridge_mappings, root_helper=config.AGENT.root_helper, polling_interval=config.AGENT.polling_interval, tunnel_types=config.AGENT.tunnel_types, veth_mtu=config.AGENT.veth_mtu, ) # If enable_tunneling is TRUE, set tunnel_type to default to GRE if config.OVS.enable_tunneling and not kwargs['tunnel_types']: kwargs['tunnel_types'] = [p_const.TYPE_GRE] # Verify the tunnel_types specified are valid for tun in kwargs['tunnel_types']: if tun not in constants.TUNNEL_NETWORK_TYPES: msg = _('Invalid tunnel type specificed: %s'), tun raise ValueError(msg) if not kwargs['local_ip']: msg = _('Tunneling cannot be enabled without a valid local_ip.') raise ValueError(msg) return kwargs
def run(self, event, row, old): host = row.hostname phy_nets = [] if event != self.ROW_DELETE: bridge_mappings = row.external_ids.get('ovn-bridge-mappings', '') mapping_dict = n_utils.parse_mappings(bridge_mappings.split(',')) phy_nets = list(mapping_dict) self.driver.update_segment_host_mapping(host, phy_nets) if ovn_config.is_ovn_l3(): self.l3_plugin.schedule_unhosted_routers()
def create_agent_config_map(config): try: bridge_mappings = q_utils.parse_mappings(config.servicechain.bridge_mappings) except ValueError as e: raise ValueError(_("Parsing bridge_mappings failed: %s.") % e) kwargs = dict( integ_ebr="ebr-int", bridge_mappings=bridge_mappings, root_helper=config.AGENT.root_helper, polling_interval=config.AGENT.polling_interval, minimize_polling=config.AGENT.minimize_polling, ) return kwargs
def __init__(self): self.bus = None self.cached_topology = {} self.providers = [] try: bridge_mappings = q_utils.parse_mappings(cfg.CONF.OVS.bridge_mappings) except ValueError as e: raise ValueError(_("Parsing bridge_mappings failed: %s.") % e) self.integ_br = cfg.CONF.OVS.integration_bridge self.bridge_mappings = bridge_mappings self.root_helper = cfg.CONF.AGENT.root_helper self.int_br = ovs_lib.OVSBridge(self.integ_br, self.root_helper)
def create_agent_config_map(config): interface_mappings = n_utils.parse_mappings( config.SDNVE.interface_mappings) controller_ips = config.SDNVE.controller_ips LOG.info(_LI("Controller IPs: %s"), controller_ips) controller_ip = controller_ips[0] return { 'integ_br': config.SDNVE.integration_bridge, 'interface_mappings': interface_mappings, 'controller_ip': controller_ip, 'info': config.SDNVE.info, 'polling_interval': config.SDNVE_AGENT.polling_interval, 'reset_br': config.SDNVE.reset_bridge, 'out_of_band': config.SDNVE.out_of_band}
def __init__(self): self.bus = None self.cached_topology = {} self.providers = [] try: bridge_mappings = q_utils.parse_mappings( cfg.CONF.OVS.bridge_mappings) except ValueError as e: raise ValueError(_("Parsing bridge_mappings failed: %s.") % e) self.integ_br = cfg.CONF.OVS.integration_bridge self.bridge_mappings = bridge_mappings self.root_helper = cfg.CONF.AGENT.root_helper self.int_br = ovs_lib.OVSBridge(self.integ_br, self.root_helper)
def create_agent_config_map(config): try: bridge_mappings = q_utils.parse_mappings( config.servicechain.bridge_mappings) except ValueError as e: raise ValueError(_("Parsing bridge_mappings failed: %s.") % e) kwargs = dict( integ_ebr="ebr-int", bridge_mappings=bridge_mappings, root_helper=config.AGENT.root_helper, polling_interval=config.AGENT.polling_interval, minimize_polling=config.AGENT.minimize_polling, ) return kwargs
def main(): common_config.init(sys.argv[1:]) common_config.setup_logging() try: interface_mappings = q_utils.parse_mappings(cfg.CONF.LINUX_BRIDGE.physical_interface_mappings) except ValueError as e: LOG.error(_("Parsing physical_interface_mappings failed: %s." " Agent terminated!"), e) sys.exit(1) LOG.info(_("Interface mappings: %s"), interface_mappings) polling_interval = cfg.CONF.AGENT.polling_interval root_helper = cfg.CONF.AGENT.root_helper agent = LinuxBridgeNeutronAgentRPC(interface_mappings, polling_interval, root_helper) LOG.info(_("Agent initialized successfully, now running... ")) agent.daemon_loop() sys.exit(0)
def main(): common_config.init(sys.argv[1:]) common_config.setup_logging() try: interface_mappings = n_utils.parse_mappings(cfg.CONF.LINUX_BRIDGE.physical_interface_mappings) except ValueError as e: LOG.error(_LE("Parsing physical_interface_mappings failed: %s. " "Agent terminated!"), e) sys.exit(1) LOG.info(_LI("Interface mappings: %s"), interface_mappings) polling_interval = cfg.CONF.AGENT.polling_interval quitting_rpc_timeout = cfg.CONF.AGENT.quitting_rpc_timeout agent = LinuxBridgeNeutronAgentRPC(interface_mappings, polling_interval, quitting_rpc_timeout) LOG.info(_LI("Agent initialized successfully, now running... ")) launcher = service.launch(cfg.CONF, agent) launcher.wait()
def initialize(self, connection, driver_type): """Perform FDB Agent Extension initialization.""" valid_driver_types = (linux_bridge_constants.EXTENSION_DRIVER_TYPE, ovs_constants.EXTENSION_DRIVER_TYPE) if driver_type not in valid_driver_types: LOG.error(_LE('FDB extension is only supported for OVS and ' 'linux bridge agent, currently uses ' '%(driver_type)s'), {'driver_type': driver_type}) sys.exit(1) self.device_mappings = n_utils.parse_mappings( cfg.CONF.FDB.shared_physical_device_mappings, unique_keys=False) devices = self._get_devices() if not devices: LOG.error(_LE('Invalid configuration provided for FDB extension: ' 'no physical devices')) sys.exit(1) self.fdb_tracker = self.FdbTableTracker(devices)
def main(): eventlet.monkey_patch() cfg.CONF(project="neutron") logging_config.setup_logging(cfg.CONF) try: interface_mappings = q_utils.parse_mappings(cfg.CONF.LINUX_BRIDGE.physical_interface_mappings) except ValueError as e: LOG.error(_("Parsing physical_interface_mappings failed: %s." " Agent terminated!"), e) sys.exit(1) LOG.info(_("Interface mappings: %s"), interface_mappings) polling_interval = cfg.CONF.AGENT.polling_interval root_helper = cfg.CONF.AGENT.root_helper plugin = LinuxBridgeNeutronAgentRPC(interface_mappings, polling_interval, root_helper) LOG.info(_("Agent initialized successfully, now running... ")) plugin.daemon_loop() sys.exit(0)
def create_agent_config_map(config): interface_mappings = n_utils.parse_mappings(config.SDNVE.interface_mappings) controller_ips = config.SDNVE.controller_ips LOG.info(_("Controller IPs: %s"), controller_ips) controller_ip = controller_ips[0] return { "integ_br": config.SDNVE.integration_bridge, "interface_mappings": interface_mappings, "controller_ip": controller_ip, "info": config.SDNVE.info, "root_helper": config.SDNVE_AGENT.root_helper, "polling_interval": config.SDNVE_AGENT.polling_interval, "reset_br": config.SDNVE.reset_bridge, "out_of_band": config.SDNVE.out_of_band, }
def main(): common_config.init(sys.argv[1:]) common_config.setup_logging() try: interface_mappings = q_utils.parse_mappings( cfg.CONF.LINUX_BRIDGE.physical_interface_mappings) except ValueError as e: LOG.error(_LE("Parsing physical_interface_mappings failed: %s. " "Agent terminated!"), e) sys.exit(1) LOG.info(_LI("Interface mappings: %s"), interface_mappings) polling_interval = cfg.CONF.AGENT.polling_interval agent = LinuxBridgeNeutronAgentRPC(interface_mappings, polling_interval) LOG.info(_LI("Agent initialized successfully, now running... ")) agent.daemon_loop() sys.exit(0)
def create_agent_config_map(config): """Create a map of agent config parameters. :param config: an instance of cfg.CONF :returns: a map of agent configuration parameters """ try: bridge_mappings = utils.parse_mappings(config.ML2_VMWARE.network_maps) except ValueError as e: raise ValueError(_("Parsing network_maps failed: %s.") % e) kwargs = dict( vsphere_hostname=config.ML2_VMWARE.vsphere_hostname, vsphere_login=config.ML2_VMWARE.vsphere_login, vsphere_password=config.ML2_VMWARE.vsphere_password, bridge_mappings=bridge_mappings, polling_interval=config.AGENT.polling_interval, quitting_rpc_timeout=config.AGENT.quitting_rpc_timeout, ) return kwargs
def main(): common_config.init(sys.argv[1:]) common_config.setup_logging() try: interface_mappings = n_utils.parse_mappings( cfg.CONF.LINUX_BRIDGE.physical_interface_mappings) except ValueError as e: LOG.error( _LE("Parsing physical_interface_mappings failed: %s. " "Agent terminated!"), e) sys.exit(1) LOG.info(_LI("Interface mappings: %s"), interface_mappings) polling_interval = cfg.CONF.AGENT.polling_interval quitting_rpc_timeout = cfg.CONF.AGENT.quitting_rpc_timeout agent = LinuxBridgeNeutronAgentRPC(interface_mappings, polling_interval, quitting_rpc_timeout) LOG.info(_LI("Agent initialized successfully, now running... ")) launcher = service.launch(cfg.CONF, agent) launcher.wait()
def main(): cfg.CONF(project='neutron') logging_config.setup_logging(cfg.CONF) try: interface_mappings = q_utils.parse_mappings( cfg.CONF.LINUX_BRIDGE.physical_interface_mappings) except ValueError as e: LOG.error( _("Parsing physical_interface_mappings failed: %s." " Agent terminated!"), e) sys.exit(1) LOG.info(_("Interface mappings: %s"), interface_mappings) polling_interval = cfg.CONF.AGENT.polling_interval root_helper = cfg.CONF.AGENT.root_helper agent = LinuxBridgeNeutronAgentRPC(interface_mappings, polling_interval, root_helper) LOG.info(_("Agent initialized successfully, now running... ")) agent.daemon_loop() sys.exit(0)
def __init__(self): LOG.debug(_('L2HighNeutronAgent init is STARTING')) self.conf = cfg.CONF try: self.bridge_mappings = common_utils.parse_mappings( self.conf.bridge_mappings) except ValueError as e: raise ValueError(_("Parsing bridge_mappings failed: %s.") % e) self.context = context.get_admin_context_without_session() self.agent_id = 'ovs-agent-%s' % self.conf.host self.l2_plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN) self.l2_state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN) self._set_l2_rpc_consumers() self.use_call = True self.local_vlan_map = {} self.tunnel_types = [p_const.TYPE_VXLAN] self.l2_pop = self.conf.l2_population self.local_ip = self.conf.local_ip self.arp_responder_enabled = self.conf.arp_responder and self.l2_pop self.l2pop_network_types = self.conf.l2pop_network_types or self.tunnel_types self.l2_agent_state = { 'binary': 'neutron-openvswitch-agent', 'host': self.conf.host, 'topic': l3_constants.L2_AGENT_TOPIC, 'configurations': { 'bridge_mappings': self.bridge_mappings, 'tunnel_types': self.tunnel_types, 'tunneling_ip': self.local_ip.split('/')[0], 'l2_population': self.l2_pop, 'l2pop_network_types': self.l2pop_network_types, 'arp_responder_enabled': self.arp_responder_enabled, 'enable_distributed_routing': True }, 'agent_type': l3_constants.AGENT_TYPE_OVS, 'start_flag': True } LOG.debug(_('RPC l2_state_report heartbeat start'))
def parse(self, mapping_list, unique_values=True): return utils.parse_mappings(mapping_list, unique_values)
def test_device_mappings(self): cfg.CONF.set_override('physical_device_mappings', self.DEVICE_MAPPING_LIST, 'SRIOV_NIC') device_mappings = n_utils.parse_mappings( cfg.CONF.SRIOV_NIC.physical_device_mappings) self.assertEqual(self.DEVICE_MAPPING, device_mappings)
def _get_existing_device(self): device_mappings = n_utils.parse_mappings( cfg.CONF.FDB.shared_physical_device_mappings, unique_keys=False) DEVICES = six.next(six.itervalues(device_mappings)) return DEVICES[0]
def setup_dvr_flows_on_integ_tun_br(self): '''Setup up initial dvr flows into br-int and br-tun''' if not (self.enable_tunneling and self.enable_distributed_routing): return if not self.in_distributed_mode(): return LOG.info(_LI("L2 Agent operating in DVR Mode with MAC %s"), self.dvr_mac_address) # Remove existing flows in integration bridge self.int_br.remove_all_flows() # Add a canary flow to int_br to track OVS restarts self.int_br.add_flow(table=constants.CANARY_TABLE, priority=0, actions="drop") # Insert 'drop' action as the default for Table DVR_TO_SRC_MAC self.int_br.add_flow(table=constants.DVR_TO_SRC_MAC, priority=1, actions="drop") # Insert 'normal' action as the default for Table LOCAL_SWITCHING self.int_br.add_flow(table=constants.LOCAL_SWITCHING, priority=1, actions="normal") self.int_br.add_flow(table=constants.DVR_NO_FLOOD, priority=1, actions="output:%s" % self.patch_tun_ofport) try: bridge_mappings = q_utils.parse_mappings(cfg.CONF.OVS.bridge_mappings) except ValueError as e: raise ValueError(_("Parsing bridge_mappings failed: %s.") % e) for bridge_mapping in bridge_mappings.iteritems(): bridge = bridge_mapping[1] int_if_name = self.get_peer_name(constants.PEER_INTEGRATION_PREFIX, bridge) int_ofport = self.int_br.get_port_ofport(int_if_name) self.int_br.add_flow(priority=2, in_port=int_ofport, actions="drop") dvr_macs = self.plugin_rpc.get_dvr_mac_address_list(self.context) LOG.debug("L2 Agent DVR: Received these MACs: %r", dvr_macs) for mac in dvr_macs: if mac['mac_address'] == self.dvr_mac_address: continue # Table 0 (default) will now sort DVR traffic from other # traffic depending on in_port self.int_br.add_flow(table=constants.LOCAL_SWITCHING, priority=2, in_port=self.patch_tun_ofport, dl_src=mac['mac_address'], actions="resubmit(,%s)" % constants.DVR_TO_SRC_MAC) # Table DVR_NOT_LEARN ensures unique dvr macs in the cloud # are not learnt, as they may # result in flow explosions self.tun_br.add_flow(table=constants.DVR_NOT_LEARN, priority=1, dl_src=mac['mac_address'], actions="output:%s" % self.patch_int_ofport) self.registered_dvr_macs.add(mac['mac_address']) self.tun_br.add_flow(priority=1, in_port=self.patch_int_ofport, actions="resubmit(,%s)" % constants.DVR_PROCESS) # table-miss should be sent to learning table self.tun_br.add_flow(table=constants.DVR_NOT_LEARN, priority=0, actions="resubmit(,%s)" % constants.LEARN_FROM_TUN) self.tun_br.add_flow(table=constants.DVR_PROCESS, priority=0, actions="resubmit(,%s)" % constants.PATCH_LV_TO_TUN)