Esempio n. 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)
Esempio n. 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)
Esempio n. 3
0
def _parse_bond_options(opts):
    if not opts:
        return {}

    opts = dict((pair.split('=', 1) for pair in opts.split()))

    mode = opts.get('mode',
                    bonding.getAllDefaultBondingOptions()['0']['mode'][-1])
    opts['mode'] = numeric_mode = bonding.numerize_bond_mode(mode)

    # Force a numeric value for an option
    for opname, opval in opts.items():
        numeric_val = bond_opts_mapper.get_bonding_option_numeric_val(
            numeric_mode, opname, opval)
        if numeric_val is not None:
            opts[opname] = numeric_val

    defaults = bonding.getDefaultBondingOptions(numeric_mode)
    return dict((k, v) for k, v in six.viewitems(opts) if v != defaults.get(k))
Esempio n. 4
0
def _parse_bond_options(opts):
    if not opts:
        return {}

    opts = dict((pair.split('=', 1) for pair in opts.split()))

    mode = opts.get('mode',
                    bonding.getAllDefaultBondingOptions()['0']['mode'][-1])
    opts['mode'] = numeric_mode = bonding.numerize_bond_mode(mode)

    # Force a numeric value for an option
    for opname, opval in opts.items():
        numeric_val = bond_opts_mapper.get_bonding_option_numeric_val(
            numeric_mode, opname, opval)
        if numeric_val is not None:
            opts[opname] = numeric_val

    defaults = bonding.getDefaultBondingOptions(numeric_mode)
    return dict(
        (k, v) for k, v in six.viewitems(opts) if v != defaults.get(k))
Esempio n. 5
0
 def _get_bonding_option_num_val(self, option_name, val_name):
     mode_num = sysfs_options.BONDING_MODES_NAME_TO_NUMBER['balance-rr']
     opt_num_val = sysfs_options_mapper.get_bonding_option_numeric_val(
         mode_num, option_name, val_name)
     return opt_num_val
Esempio n. 6
0
 def _get_bonding_option_num_val(self, option_name, val_name):
     mode_num = sysfs_options.BONDING_MODES_NAME_TO_NUMBER['balance-rr']
     opt_num_val = sysfs_options_mapper.get_bonding_option_numeric_val(
         mode_num, option_name, val_name)
     return opt_num_val