예제 #1
0
def remove_empty_bridges():
    try:
        interface_mappings = helpers.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.physical_interface_mappings)
    except ValueError as e:
        LOG.error("Parsing physical_interface_mappings failed: %s.", e)
        sys.exit(1)
    LOG.info("Interface mappings: %s.", interface_mappings)

    try:
        bridge_mappings = helpers.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.bridge_mappings)
    except ValueError as e:
        LOG.error("Parsing bridge_mappings failed: %s.", e)
        sys.exit(1)
    LOG.info("Bridge mappings: %s.", bridge_mappings)

    lb_manager = linuxbridge_neutron_agent.LinuxBridgeManager(
        bridge_mappings, interface_mappings)

    bridge_names = lb_manager.get_deletable_bridges()
    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("Linux bridge %s deleted", bridge_name)
        except RuntimeError:
            LOG.exception("Linux bridge %s delete failed", bridge_name)
    LOG.info("Linux bridge cleanup completed successfully")
def main():
    common_config.init(sys.argv[1:])

    common_config.setup_logging()
    agent_config.setup_privsep()
    try:
        interface_mappings = helpers.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)

    try:
        bridge_mappings = helpers.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.bridge_mappings)
    except ValueError as e:
        LOG.error("Parsing bridge_mappings failed: %s. "
                  "Agent terminated!", e)
        sys.exit(1)
    LOG.info("Bridge mappings: %s", bridge_mappings)

    manager = LinuxBridgeManager(bridge_mappings, interface_mappings)
    linuxbridge_capabilities.register()

    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)
    setup_profiler.setup("neutron-linuxbridge-agent", cfg.CONF.host)
    LOG.info("Agent initialized successfully, now running... ")
    launcher = service.launch(cfg.CONF, agent, restart_method='mutate')
    launcher.wait()
예제 #3
0
def remove_empty_bridges():
    try:
        interface_mappings = helpers.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.physical_interface_mappings)
    except ValueError as e:
        LOG.error("Parsing physical_interface_mappings failed: %s.", e)
        sys.exit(1)
    LOG.info("Interface mappings: %s.", interface_mappings)

    try:
        bridge_mappings = helpers.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.bridge_mappings)
    except ValueError as e:
        LOG.error("Parsing bridge_mappings failed: %s.", e)
        sys.exit(1)
    LOG.info("Bridge mappings: %s.", bridge_mappings)

    lb_manager = linuxbridge_neutron_agent.LinuxBridgeManager(
        bridge_mappings, interface_mappings)

    bridge_names = lb_manager.get_deletable_bridges()
    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("Linux bridge %s deleted", bridge_name)
        except RuntimeError:
            LOG.exception("Linux bridge %s delete failed", bridge_name)
    LOG.info("Linux bridge cleanup completed successfully")
예제 #4
0
def main():
    common_config.init(sys.argv[1:])

    common_config.setup_logging()
    try:
        interface_mappings = helpers.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)

    try:
        bridge_mappings = helpers.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.bridge_mappings)
    except ValueError as e:
        LOG.error("Parsing bridge_mappings failed: %s. "
                  "Agent terminated!", e)
        sys.exit(1)
    LOG.info("Bridge mappings: %s", bridge_mappings)

    manager = LinuxBridgeManagerBaGPipe(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,
                               n_const.AGENT_TYPE_LINUXBRIDGE,
                               LB_BAGPIPE_AGENT_BINARY)
    LOG.info("Agent initialized successfully, now running... ")
    launcher = service.launch(cfg.CONF, agent)
    launcher.wait()
예제 #5
0
def main():
    common_config.init(sys.argv[1:])

    common_config.setup_logging()
    agent_config.setup_privsep()
    try:
        interface_mappings = helpers.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 = helpers.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)
    linuxbridge_capabilities.register()

    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)
    setup_profiler.setup("neutron-linuxbridge-agent", cfg.CONF.host)
    LOG.info(_LI("Agent initialized successfully, now running... "))
    launcher = service.launch(cfg.CONF, agent)
    launcher.wait()
예제 #6
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 = helpers.parse_mappings(
         cfg.CONF.SRIOV_NIC.physical_device_mappings, unique_keys=False)
     self.assertEqual(self.DEVICE_MAPPING, device_mappings)
예제 #7
0
 def __init__(self, config):
     LOG.debug("Get OVS bridge mappings")
     mappings = helpers.parse_mappings(config.OVS.bridge_mappings)
     self.bridges = [
         ovs_lib.OVSBridge(bridge) for bridge in mappings.values()
     ]
     self.int_br = ovs_lib.OVSBridge(config.OVS.integration_bridge)
예제 #8
0
파일: checks.py 프로젝트: stackhpc/neutron
def min_tx_rate_support():
    device_mappings = helpers.parse_mappings(
        cfg.CONF.SRIOV_NIC.physical_device_mappings, unique_keys=False)
    devices_to_test = set()
    for devices_in_physnet in device_mappings.values():
        for device in devices_in_physnet:
            devices_to_test.add(device)

    # NOTE(ralonsoh): the VF used by default is 0. Each SR-IOV configured
    # NIC should have configured at least 1 VF.
    VF_NUM = 0
    devices_without_support = set()
    for device in devices_to_test:
        try:
            ip_link = ip_lib.IpLinkCommand(device)
            # NOTE(ralonsoh): to set min_tx_rate, first is needed to set
            # max_tx_rate and max_tx_rate >= min_tx_rate.
            vf_config = {'vf': VF_NUM, 'rate': {'min_tx_rate': int(400),
                                                'max_tx_rate': int(500)}}
            ip_link.set_vf_feature(vf_config)
            vf_config = {'vf': VF_NUM, 'rate': {'min_tx_rate': 0,
                                                'max_tx_rate': 0}}
            ip_link.set_vf_feature(vf_config)
        except ip_lib.InvalidArgument:
            devices_without_support.add(device)

    if devices_without_support:
        LOG.debug('The following NICs do not support "min_tx_rate": %s',
                  devices_without_support)
        return False
    return True
예제 #9
0
 def __init__(self):
     try:
         self.physnet_mtus = helpers.parse_mappings(
             cfg.CONF.ml2.physical_network_mtus, unique_values=False)
     except Exception as e:
         LOG.error("Failed to parse physical_network_mtus: %s", e)
         self.physnet_mtus = []
예제 #10
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 = helpers.parse_mappings(
         cfg.CONF.SRIOV_NIC.physical_device_mappings, unique_keys=False)
     self.assertEqual(self.DEVICE_MAPPING, device_mappings)
예제 #11
0
def main():
    register_f5_opts(cfg.CONF)
    agent_config.register_agent_state_opts_helper(cfg.CONF)
    common_config.init(sys.argv[1:])
    common_config.setup_logging()

    try:
        device_mappings = helpers.parse_mappings(
            cfg.CONF.F5.physical_device_mappings)
    except ValueError as e:
        LOG.error(
            "Parsing physical_device_mappings failed: %s. "
            "Agent terminated!", e)
        sys.exit(1)
    LOG.info("Device mappings: %s", device_mappings)

    polling_interval = cfg.CONF.AGENT.polling_interval
    quitting_rpc_timeout = cfg.CONF.AGENT.quitting_rpc_timeout
    f5manager = F5Manager(device_mappings)
    agent = ca.CommonAgentLoop(f5manager, polling_interval,
                               quitting_rpc_timeout, constants.AGENT_TYPE_F5,
                               constants.AGENT_BINARY)

    LOG.info('networking-f5-agent initialized, starting up...')
    if cfg.CONF.F5.prometheus:
        start_http_server(8000)
    service.launch(cfg.CONF, agent, restart_method='mutate').wait()
예제 #12
0
def main():
    eventlet.monkey_patch()
    common_config.init(sys.argv[1:])
    kaloom_config.register_kaloomkvs_opts()
    common_config.setup_logging()
    agent_config.setup_privsep()

    try:
        bridge_mappings = helpers.parse_mappings(
            cfg.CONF.kaloom_kvs.bridge_mappings)
    except ValueError as e:
        LOG.error("Parsing bridge_mappings failed: %s. "
                  "Agent terminated!", e)
        sys.exit(1)
    LOG.info("Bridge mappings: %s", bridge_mappings)

    try:
        vhostuser_socket_dir = cfg.CONF.kaloom_kvs.vhostuser_socket_dir
    except ValueError as e:
        LOG.error(
            "Parsing vhostuser_socket_dir failed: %s. "
            "Agent terminated!", e)
        sys.exit(1)
    LOG.info("vhostuser_socket_dir: %s", vhostuser_socket_dir)

    dir_exists = os.path.exists(vhostuser_socket_dir)
    if dir_exists is False:
        #creating the dir with right selinux context is not preferred.
        #the dir should be pre-configured.
        LOG.error(
            "vhostuser_socket_dir %s does not exists."
            "Agent terminated!", vhostuser_socket_dir)
        sys.exit(1)

    # is it compliance with permission
    status, msg = kvs_utils.check_permission(vhostuser_socket_dir)
    if status is not True:
        LOG.error("%s. Agent terminated!", msg)
        sys.exit(1)

    host = cfg.CONF.host
    kvs_id = 'kvs-agent-%s' % host

    manager = KaloomKVSManager(bridge_mappings, kvs_id, vhostuser_socket_dir)
    kaloomkvs_capabilities.register()

    polling_interval = cfg.CONF.AGENT.polling_interval
    quitting_rpc_timeout = cfg.CONF.AGENT.quitting_rpc_timeout

    LOG.info("polling_interval: %s", polling_interval)
    LOG.info("quitting_rpc_timeout: %s", quitting_rpc_timeout)

    agent = ca.CommonAgentLoop(manager, polling_interval, quitting_rpc_timeout,
                               a_const.AGENT_TYPE_KALOOM_KVS,
                               a_const.KVS_AGENT_BINARY)
    setup_profiler.setup("neutron-kaloom-agent", cfg.CONF.host)
    LOG.info("Agent initialized successfully, now running... ")
    launcher = service.launch(cfg.CONF, agent)
    launcher.wait()
예제 #13
0
 def __init__(self):
     try:
         self.physnet_mtus = helpers.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 = []
예제 #14
0
def parse_interface_mappings():
    try:
        interface_mappings = helpers.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)
예제 #15
0
    def parse(self):
        """Parses device_mappings and exclude_devices.

        Parse and validate the consistency in both mappings
        """
        self.device_mappings = helpers.parse_mappings(cfg.CONF.SRIOV_NIC.physical_device_mappings, unique_keys=False)
        self.exclude_devices = config.parse_exclude_devices(cfg.CONF.SRIOV_NIC.exclude_devices)
        self._validate()
예제 #16
0
 def _create_l2_agents(self):
     for name, host in six.iteritems(self._hosts):
         iface = self._interfaces[name]
         mappings = ['%s:%s' % (p, iface['uuid'])
                     for p in iface['providernets'].split(',')]
         mappings_dict = lib_helpers.parse_mappings(mappings,
                                                    unique_values=False)
         self._register_avs_agent(
             host=name, mappings=mappings_dict)
예제 #17
0
    def parse(self):
        """Parses device_mappings and exclude_devices.

        Parse and validate the consistency in both mappings
        """
        self.device_mappings = helpers.parse_mappings(
            cfg.CONF.SRIOV_NIC.physical_device_mappings, unique_keys=False)
        self.exclude_devices = config.parse_exclude_devices(
            cfg.CONF.SRIOV_NIC.exclude_devices)
        self._validate()
예제 #18
0
    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 = helpers.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_gateways()
예제 #19
0
def parse_interface_mappings():
    try:
        interface_mappings = helpers.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)
예제 #20
0
    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 = helpers.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()
예제 #21
0
def _parse_hypervisors(cms_options):
    for cms_option in cms_options:
        if ovn_const.RP_HYPERVISORS in cms_option:
            hypervisors = cms_option.split('=')[1]
            break
    else:
        return

    if hypervisors:
        return helpers.parse_mappings(hypervisors.split(';'),
                                      unique_values=False)
예제 #22
0
def main():
    common_config.register_common_config_options()
    common_config.init(sys.argv[1:])

    common_config.setup_logging()
    agent_config.setup_privsep()
    service_conf.register_service_opts(service_conf.RPC_EXTRA_OPTS, cfg.CONF)

    try:
        interface_mappings = helpers.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)

    try:
        bridge_mappings = helpers.parse_mappings(
            cfg.CONF.LINUX_BRIDGE.bridge_mappings)
    except ValueError as e:
        LOG.error("Parsing bridge_mappings failed: %s. "
                  "Agent terminated!", e)
        sys.exit(1)
    LOG.info("Bridge mappings: %s", bridge_mappings)

    manager = LinuxBridgeManager(bridge_mappings, interface_mappings)
    linuxbridge_capabilities.register()

    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,
                               constants.AGENT_PROCESS_LINUXBRIDGE)
    setup_profiler.setup(constants.AGENT_PROCESS_LINUXBRIDGE, cfg.CONF.host)
    LOG.info("Agent initialized successfully, now running... ")
    launcher = service.launch(cfg.CONF, agent, restart_method='mutate')
    launcher.wait()
예제 #23
0
    def parse(self):
        """Parses device_mappings and exclude_devices.

        Parse and validate the consistency in both mappings
        """
        self.device_mappings = helpers.parse_mappings(
            cfg.CONF.SRIOV_NIC.physical_device_mappings, unique_keys=False)
        self.exclude_devices = config.parse_exclude_devices(
            cfg.CONF.SRIOV_NIC.exclude_devices)
        self.rp_bandwidths = place_utils.parse_rp_bandwidths(
            cfg.CONF.SRIOV_NIC.resource_provider_bandwidths)
        self.rp_inventory_defaults = place_utils.parse_rp_inventory_defaults(
            cfg.CONF.SRIOV_NIC.resource_provider_inventory_defaults)
        self._validate()
예제 #24
0
    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 = helpers.parse_mappings(bridge_mappings.split(','),
                                                  unique_values=False)
            phy_nets = list(mapping_dict)

        self.driver.update_segment_host_mapping(host, phy_nets)
        if utils.is_ovn_l3(self.l3_plugin):
            self.l3_plugin.schedule_unhosted_gateways()

        self.handle_ha_chassis_group_changes(event, row, old)
예제 #25
0
    def parse(self):
        """Parses device_mappings and exclude_devices.

        Parse and validate the consistency in both mappings
        """
        self.device_mappings = helpers.parse_mappings(
            cfg.CONF.SRIOV_NIC.physical_device_mappings, unique_keys=False)
        self.exclude_devices = config.parse_exclude_devices(
            cfg.CONF.SRIOV_NIC.exclude_devices)
        self.rp_bandwidths = place_utils.parse_rp_bandwidths(
            cfg.CONF.SRIOV_NIC.resource_provider_bandwidths)
        self.rp_inventory_defaults = place_utils.parse_rp_inventory_defaults(
            cfg.CONF.SRIOV_NIC.resource_provider_inventory_defaults)
        self._validate()
예제 #26
0
def parse_interface_mappings():
    if not cfg.CONF.macvtap.physical_interface_mappings:
        LOG.error("No physical_interface_mappings provided, but at least "
                  "one mapping is required. Agent terminated!")
        sys.exit(1)

    try:
        interface_mappings = helpers.parse_mappings(
            cfg.CONF.macvtap.physical_interface_mappings)
        LOG.info("Interface mappings: %s", interface_mappings)
        return interface_mappings
    except ValueError as e:
        LOG.error("Parsing physical_interface_mappings failed: %s. "
                  "Agent terminated!", e)
        sys.exit(1)
예제 #27
0
def parse_interface_mappings():
    if not cfg.CONF.macvtap.physical_interface_mappings:
        LOG.error(_LE("No physical_interface_mappings provided, but at least "
                      "one mapping is required. Agent terminated!"))
        sys.exit(1)

    try:
        interface_mappings = helpers.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)
예제 #28
0
    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 = helpers.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 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 = helpers.parse_mappings(
            config.ML2_VMWARE.network_maps, unique_values=False)
    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.DVS_AGENT.polling_interval,
    )
    return kwargs
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 = helpers.parse_mappings(
            config.ML2_VMWARE.network_maps, unique_values=False)
    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.DVS_AGENT.polling_interval,
    )
    return kwargs
예제 #31
0
    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 = helpers.parse_mappings(bridge_mappings.split(','),
                                                  unique_values=False)
            phy_nets = list(mapping_dict)

        self.driver.update_segment_host_mapping(host, phy_nets)

        if utils.is_ovn_l3(self.l3_plugin):
            # If chassis lost physnet or has been
            # deleted we can limit the scope and
            # reschedule only ports from this chassis.
            # In other cases we need to reschedule all gw ports.
            kwargs = {'event_from_chassis': None}
            if event == self.ROW_DELETE:
                kwargs['event_from_chassis'] = row.name
            elif event == self.ROW_UPDATE:
                old_mappings = old.external_ids.get('ovn-bridge-mappings',
                                                    set()) or set()
                new_mappings = row.external_ids.get('ovn-bridge-mappings',
                                                    set()) or set()
                if old_mappings:
                    old_mappings = set(old_mappings.split(','))
                if new_mappings:
                    new_mappings = set(new_mappings.split(','))

                mappings_removed = old_mappings - new_mappings
                mappings_added = new_mappings - old_mappings
                if mappings_removed and not mappings_added:
                    # Mapping has been only removed. So we can
                    # limit scope of rescheduling only to impacted
                    # gateway chassis.
                    kwargs['event_from_chassis'] = row.name
            self.l3_plugin.schedule_unhosted_gateways(**kwargs)

        self.handle_ha_chassis_group_changes(event, row, old)
예제 #32
0
 def initialize(self, host, conf, agent_state):
     ovs_config = conf.OVS
     try:
         bridge_mappings = helpers.parse_mappings(
             ovs_config.bridge_mappings)
     except ValueError as e:
         raise ValueError(_("Parsing bridge_mappings failed: %s.") % e)
     self.int_br_device_count = 0
     self.int_br = ovs_lib.OVSBridge(ovs_config.integration_bridge,
         ovs_config.datapath_type)
     self.fabric_br = ovs_lib.OVSBridge(conf.OPFLEX.fabric_bridge,
         ovs_config.datapath_type)
     self.local_ip = ovs_config.local_ip
     self.setup_integration_bridge()
     agent_state['agent_type'] = ofcst.AGENT_TYPE_OPFLEX_OVS
     if 'configurations' not in agent_state:
         agent_state['configurations'] = {}
     agent_state['configurations']['bridge_mappings'] = bridge_mappings
     agent_state['configurations']['datapath_type'] = (
         ovs_config.datapath_type)
     agent_state['configurations']['vhostuser_socket_dir'] = (
         ovs_config.vhostuser_socket_dir)
     return self, agent_state
예제 #33
0
def parse_mappings(mapping_list, unique_values=True, unique_keys=True):
    return helpers.parse_mappings(mapping_list,
                                  unique_values=unique_values,
                                  unique_keys=unique_keys)
예제 #34
0
 def _get_existing_device(self):
     device_mappings = helpers.parse_mappings(
         cfg.CONF.FDB.shared_physical_device_mappings, unique_keys=False)
     DEVICES = six.next(six.itervalues(device_mappings))
     return DEVICES[0]
예제 #35
0
 def _get_chassis_physnets(self, chassis):
     bridge_mappings = chassis.external_ids.get('ovn-bridge-mappings', '')
     mapping_dict = helpers.parse_mappings(bridge_mappings.split(','),
                                           unique_values=False)
     return list(mapping_dict.keys())
예제 #36
0
 def _parse_bridge_mappings(self, bridge_mappings):
     try:
         return helpers.parse_mappings(bridge_mappings)
     except ValueError:
         LOG.exception("Failed to parse bridge mapping")
         raise
예제 #37
0
def _parse_hypervisors(cms_options):
    hyperv = _parse_placement_option(ovn_const.RP_HYPERVISORS, cms_options)
    if not hyperv:
        return {}

    return helpers.parse_mappings(hyperv.split(';'), unique_values=False)
예제 #38
0
def _parse_bridge_mappings(chassis):
    bridge_mappings = chassis.external_ids.get('ovn-bridge-mappings', '')
    bridge_mappings = helpers.parse_mappings(bridge_mappings.split(','),
                                             unique_values=False)
    return {k: [v] for k, v in bridge_mappings.items()}
예제 #39
0
 def _parse_bridge_mappings(self, bridge_mappings):
     try:
         return helpers.parse_mappings(bridge_mappings)
     except ValueError as e:
         raise ValueError(_("Parsing bridge_mappings failed: %s.") % e)
예제 #40
0
 def _get_chassis_physnets(self, chassis):
     bridge_mappings = chassis.external_ids.get('ovn-bridge-mappings', '')
     mapping_dict = helpers.parse_mappings(bridge_mappings.split(','))
     return mapping_dict.keys()
예제 #41
0
 def _get_existing_device(self):
     device_mappings = helpers.parse_mappings(
         cfg.CONF.FDB.shared_physical_device_mappings, unique_keys=False)
     DEVICES = six.next(six.itervalues(device_mappings))
     return DEVICES[0]
예제 #42
0
파일: utils.py 프로젝트: sebrandon1/neutron
def parse_mappings(mapping_list, unique_values=True, unique_keys=True):
    return helpers.parse_mappings(mapping_list, unique_values=unique_values,
                                  unique_keys=unique_keys)
예제 #43
0
 def _get_chassis_physnets(self, chassis):
     bridge_mappings = chassis.external_ids.get('ovn-bridge-mappings', '')
     mapping_dict = helpers.parse_mappings(bridge_mappings.split(','))
     return mapping_dict.keys()