Esempio n. 1
0
def _parse_bond_options(opts):
    if not opts:
        return {}

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

    # force a numeric bonding mode
    mode = opts.get('mode',
                    bonding.getAllDefaultBondingOptions()['0']['mode'][-1])
    if mode in bonding.BONDING_MODES_NUMBER_TO_NAME:
        numeric_mode = mode
    else:
        numeric_mode = bonding.BONDING_MODES_NAME_TO_NUMBER[mode]
        opts['mode'] = numeric_mode

    # Force a numeric value for an option
    for opname, opval in opts.items():
        numeric_val = bonding.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 opts.iteritems() if v != defaults.get(k))
Esempio n. 2
0
def _parse_bond_options(opts):
    if not opts:
        return {}

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

    # force a numeric bonding mode
    mode = opts.get('mode',
                    bonding.getAllDefaultBondingOptions()['0']['mode'][-1])
    if mode in bonding.BONDING_MODES_NUMBER_TO_NAME:
        numeric_mode = mode
    else:
        numeric_mode = bonding.BONDING_MODES_NAME_TO_NUMBER[mode]
        opts['mode'] = numeric_mode

    # Force a numeric value for an option
    for opname, opval in opts.items():
        numeric_val = bonding.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 opts.iteritems() if v != defaults.get(k))
Esempio n. 3
0
 def test_get_bonding_option_numeric_val_does_not_exists(self):
     mode_num = bonding.BONDING_MODES_NAME_TO_NUMBER["balance-rr"]
     self.assertEqual(
         bonding.get_bonding_option_numeric_val(mode_num,
                                                "opt_does_not_exist",
                                                "none"), None)
Esempio n. 4
0
 def test_get_bonding_option_numeric_val_exists(self):
     mode_num = bonding.BONDING_MODES_NAME_TO_NUMBER["balance-rr"]
     self.assertNotEqual(
         bonding.get_bonding_option_numeric_val(mode_num, "ad_select",
                                                "stable"), None)
Esempio n. 5
0
 def test_get_bonding_option_numeric_val_does_not_exists(self):
     mode_num = bonding.BONDING_MODES_NAME_TO_NUMBER["balance-rr"]
     self.assertEqual(bonding.get_bonding_option_numeric_val(
                      mode_num, "opt_does_not_exist", "none"),
                      None)
Esempio n. 6
0
 def test_get_bonding_option_numeric_val_exists(self):
     mode_num = bonding.BONDING_MODES_NAME_TO_NUMBER["balance-rr"]
     self.assertNotEqual(bonding.get_bonding_option_numeric_val(
                         mode_num, "ad_select", "stable"),
                         None)