def validateOptions(cls, bondingOptions): 'Example: BONDING_OPTS="mode=802.3ad miimon=150"' mode = 'balance-rr' try: for option in bondingOptions.split(): key, value = option.split('=', 1) if key == 'mode': mode = value except ValueError: raise ConfigNetworkError( ne.ERR_BAD_BONDING, 'Error parsing ' 'bonding options: %r' % bondingOptions, ) mode = bonding.numerize_bond_mode(mode) defaults = bonding.getDefaultBondingOptions(mode) for option in bondingOptions.split(): key, _ = option.split('=', 1) if key not in defaults: raise ConfigNetworkError( ne.ERR_BAD_BONDING, '%r is not a ' 'valid bonding option' % key, )
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))
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))
def validateOptions(cls, bondingOptions): 'Example: BONDING_OPTS="mode=802.3ad miimon=150"' mode = 'balance-rr' try: for option in bondingOptions.split(): key, value = option.split('=', 1) if key == 'mode': mode = value except ValueError: raise ConfigNetworkError(ne.ERR_BAD_BONDING, 'Error parsing ' 'bonding options: %r' % bondingOptions) mode = bonding.numerize_bond_mode(mode) defaults = bonding.getDefaultBondingOptions(mode) for option in bondingOptions.split(): key, _ = option.split('=', 1) if key not in defaults and key != 'custom': raise ConfigNetworkError(ne.ERR_BAD_BONDING, '%r is not a ' 'valid bonding option' % key)