Example #1
0
def _numerize_bond_options(opts):
    optmap = dict((pair.split('=', 1) for pair in opts.split()))

    mode = optmap.get('mode')
    if not mode:
        return opts

    optmap['mode'] = numeric_mode = bond_options.numerize_bond_mode(mode)
    for opname, opval in six.viewitems(optmap):
        numeric_val = bond_opts_mapper.get_bonding_option_numeric_val(
            numeric_mode, opname, opval)
        if numeric_val is not None:
            optmap[opname] = numeric_val

    return _normalize_bond_opts(optmap)
Example #2
0
def _numerize_bond_options(opts):
    optmap = dict((pair.split('=', 1) for pair in opts.split()))

    mode = optmap.get('mode')
    if not mode:
        return opts

    optmap['mode'] = numeric_mode = bond_options.numerize_bond_mode(mode)
    for opname, opval in six.viewitems(optmap):
        numeric_val = bond_opts_mapper.get_bonding_option_numeric_val(
            numeric_mode, opname, opval)
        if numeric_val is not None:
            optmap[opname] = numeric_val

    return _normalize_bond_opts(optmap)
Example #3
0
def _validate_bond_options(bond_options):
    mode = 'balance-rr'
    try:
        for option in bond_options.split():
            key, value = option.split('=', 1)
            if key == 'mode':
                mode = value
    except ValueError:
        raise ne.ConfigNetworkError(
            ne.ERR_BAD_BONDING,
            'Error parsing bonding options: %r' % bond_options)

    mode = sysfs_options.numerize_bond_mode(mode)
    defaults = sysfs_options.getDefaultBondingOptions(mode)

    for option in bond_options.split():
        key, _ = option.split('=', 1)
        if key not in defaults:
            raise ne.ConfigNetworkError(
                ne.ERR_BAD_BONDING, '%r is not a valid bonding option' % key)
Example #4
0
def _validate_bond_options(bond_options):
    mode = 'balance-rr'
    try:
        for option in bond_options.split():
            key, value = option.split('=', 1)
            if key == 'mode':
                mode = value
    except ValueError:
        raise ne.ConfigNetworkError(
            ne.ERR_BAD_BONDING,
            'Error parsing bonding options: %r' % bond_options
        )

    mode = sysfs_options.numerize_bond_mode(mode)
    defaults = sysfs_options.getDefaultBondingOptions(mode)

    for option in bond_options.split():
        key, _ = option.split('=', 1)
        if key not in defaults and key != 'custom':
            raise ne.ConfigNetworkError(
                ne.ERR_BAD_BONDING, '%r is not a valid bonding option' % key)
Example #5
0
def numerize_bond_mode(mode):
    return sysfs_options.numerize_bond_mode(mode)
Example #6
0
 def _get_bond_mode(bond):
     for option in bond.options.split():
         key, value = option.split('=', 1)
         if key == 'mode':
             return numerize_bond_mode(value)
     return '0'
Example #7
0
File: bonding.py Project: nirs/vdsm
def numerize_bond_mode(mode):
    return sysfs_options.numerize_bond_mode(mode)
Example #8
0
File: ifcfg.py Project: oVirt/vdsm
 def _get_bond_mode(bond):
     for option in bond.options.split():
         key, value = option.split('=', 1)
         if key == 'mode':
             return numerize_bond_mode(value)
     return '0'