Пример #1
0
def bondings_caps(running_config):
    ovs_bonding_caps = {}
    routes = netinfo_routes.get_routes()
    for bonding, attrs in iter_ovs_bonds(running_config.bonds):
        options = get_bond_options(attrs.get('options'), keep_custom=True)
        net_info = _get_net_info(bonding, routes)
        net_info['slaves'] = attrs.get('nics')
        net_info['active_slave'] = _get_active_slave(bonding)
        net_info['opts'] = options
        ovs_bonding_caps[bonding] = net_info
    return ovs_bonding_caps
Пример #2
0
def bondings_caps(running_config):
    ovs_bonding_caps = {}
    dhcpv4ifaces, dhcpv6ifaces = netinfo._get_dhclient_ifaces()
    routes = netinfo._get_routes()
    for bonding, attrs in iter_ovs_bonds(running_config.bonds):
        options = get_bond_options(attrs.get('options'), keep_custom=True)
        net_info = _get_net_info(attrs, bonding, dhcpv4ifaces, dhcpv6ifaces,
                                 routes)
        net_info['slaves'] = attrs.get('nics')
        net_info['active_slave'] = _get_active_slave(bonding)
        net_info['opts'] = options
        ovs_bonding_caps[bonding] = net_info
    return ovs_bonding_caps
Пример #3
0
def bondings_caps(running_config):
    ovs_bonding_caps = {}
    dhcpv4ifaces, dhcpv6ifaces = netinfo._get_dhclient_ifaces()
    routes = netinfo._get_routes()
    for bonding, attrs in running_config.bonds.items():
        if is_ovs_bond(attrs):
            options = get_bond_options(attrs.get("options"), keep_custom=True)
            net_info = _get_net_info(attrs, bonding, dhcpv4ifaces, dhcpv6ifaces, routes)
            net_info["slaves"] = attrs.get("nics")
            net_info["active_slave"] = _get_active_slave(bonding)
            net_info["opts"] = options
            ovs_bonding_caps[bonding] = net_info
    return ovs_bonding_caps
Пример #4
0
def _setup_ovs_bond(bond, attrs, running_config):
    """ Add OVS bonding and set it requested mode and lacp options.
    As we use custom entry, these values are not validated in network api,
    so we check correct values here.
    """
    commands = []
    commands.extend(['--', '--fake-iface', '--may-exist', 'add-bond',
                     BRIDGE_NAME, bond] + attrs.get('nics'))

    bond_options = get_bond_options(attrs.get('options'))
    mode = rget(bond_options, ('custom', 'ovs_mode')) or 'active-backup'
    lacp = rget(bond_options, ('custom', 'ovs_lacp')) or 'off'
    commands.extend(['--', 'set', 'port', bond, 'bond_mode=%s' % mode])
    commands.extend(['--', 'set', 'port', bond, 'lacp=%s' % lacp])

    running_config.setBonding(bond, {'nics': attrs.get('nics'),
                                     'options': attrs.get('options')})
    return commands
def _setup_ovs_bond(bond, attrs, running_config):
    """ Add OVS bonding and set it requested mode and lacp options.
    As we use custom entry, these values are not validated in network api,
    so we check correct values here.
    """
    commands = []
    commands.extend(['--', '--fake-iface', '--may-exist', 'add-bond',
                     BRIDGE_NAME, bond] + attrs.get('nics'))

    bond_options = get_bond_options(attrs.get('options'))
    mode = rget(bond_options, ('custom', 'ovs_mode')) or 'active-backup'
    lacp = rget(bond_options, ('custom', 'ovs_lacp')) or 'off'
    commands.extend(['--', 'set', 'port', bond, 'bond_mode=%s' % mode])
    commands.extend(['--', 'set', 'port', bond, 'lacp=%s' % lacp])

    running_config.setBonding(bond, {'nics': attrs.get('nics'),
                                     'options': attrs.get('options')})
    return commands
Пример #6
0
def _validate_bond_configuration(attrs, netinfo):
    nics = attrs.get('nics')
    bond_options = get_bond_options(attrs.get('options'))

    if nics is None or len(attrs.get('nics')) < 2:
        raise Exception('You have to define at least 2 slaves for '
                        'OVS bonding')
    for nic in nics:
        if nic not in netinfo.nics:
            raise Exception('Nic %s does not exist' % nic)

    mode = rget(bond_options, ('custom', 'ovs_mode')) or 'active-backup'
    lacp = rget(bond_options, ('custom', 'ovs_lacp')) or 'off'
    if mode:
        if mode not in VALID_MODES:
            raise Exception('%s is not valid ovs bond mode' % mode)
    if lacp:
        if lacp not in VALID_LACP:
            raise Exception('%s is not valid ovs lacp value' % lacp)
def _validate_bond_configuration(attrs, netinfo):
    nics = attrs.get('nics')
    bond_options = get_bond_options(attrs.get('options'))

    if nics is None or len(attrs.get('nics')) < 2:
        raise Exception('You have to define at least 2 slaves for '
                        'OVS bonding')
    for nic in nics:
        if nic not in netinfo.nics:
            raise Exception('Nic %s does not exist' % nic)

    mode = rget(bond_options, ('custom', 'ovs_mode')) or 'active-backup'
    lacp = rget(bond_options, ('custom', 'ovs_lacp')) or 'off'
    if mode:
        if mode not in VALID_MODES:
            raise Exception('%s is not valid ovs bond mode' % mode)
    if lacp:
        if lacp not in VALID_LACP:
            raise Exception('%s is not valid ovs lacp value' % lacp)