Beispiel #1
0
 def test_bond_properties_with_filter_out(self):
     with bond_device() as bond:
         properties = sysfs_options.properties(
             bond.master, filter_out_properties=('mode',)
         )
         self.assertTrue('mode' not in properties)
         self.assertGreater(len(properties), 1)
Beispiel #2
0
 def test_bond_properties_with_filter(self):
     with bond_device() as bond:
         properties = sysfs_options.properties(
             bond.master, filter_properties=('mode',)
         )
         self.assertTrue('mode' in properties)
         self.assertEqual(1, len(properties))
Beispiel #3
0
    def areOptionsApplied(self):
        # TODO: this method returns True iff self.options are a subset of the
        # TODO: current bonding options. VDSM should probably compute if the
        # TODO: non-default settings are equal to the non-default state.
        options = self.options
        if options == '':
            return True
        confOpts = [option.split('=', 1) for option in options.split(' ')]
        activeOpts = bond_options.properties(
            self.name, filter_properties=(name for name, _ in confOpts))

        return all(value in activeOpts[name] for name, value in confOpts)
Beispiel #4
0
    def areOptionsApplied(self):
        # TODO: this method returns True iff self.options are a subset of the
        # TODO: current bonding options. VDSM should probably compute if the
        # TODO: non-default settings are equal to the non-default state.
        # 'custom' is not a real bond option, it just piggybacks custom values
        options = remove_custom_bond_option(self.options)
        if options == '':
            return True
        confOpts = [option.split('=', 1) for option in options.split(' ')]
        activeOpts = bond_options.properties(
            self.name, filter_properties=(name for name, _ in confOpts))

        return all(value in activeOpts[name] for name, value in confOpts)
Beispiel #5
0
def _get_default_bonding_options():
    """
    Return default options per mode, in a dictionary of dictionaries. All keys
    are strings.
    """
    bond_name = random_iface_name('bondscan-')
    with _bond_device(bond_name):
        default_mode = sysfs_options.properties(bond_name, ('mode',))['mode']

    # read default values for all modes
    opts = {}
    for mode in range(_MAX_BONDING_MODES + 1):
        mode = str(mode)
        # The bond is created per mode to resolve an EBUSY error
        # that appears randomly when changing bond mode and modifying its
        # attributes. (Seen only on CI runs)
        with _bond_device(bond_name, mode):
            opts[mode] = sysfs_options.properties(
                bond_name,
                filter_out_properties=sysfs_options.EXCLUDED_BONDING_ENTRIES)
            opts[mode]['mode'] = default_mode

    return opts
Beispiel #6
0
def _get_default_bonding_options():
    """
    Return default options per mode, in a dictionary of dictionaries. All keys
    are strings.
    """
    bond_name = random_iface_name()
    with _bond_device(bond_name):
        default_mode = sysfs_options.properties(bond_name, ('mode',))['mode']

    # read default values for all modes
    opts = {}
    for mode in range(_MAX_BONDING_MODES + 1):
        mode = str(mode)
        # The bond is created per mode to resolve an EBUSY error
        # that appears randomly when changing bond mode and modifying its
        # attributes. (Seen only on CI runs)
        with _bond_device(bond_name, mode):
            opts[mode] = sysfs_options.properties(
                bond_name,
                filter_out_properties=sysfs_options.EXCLUDED_BONDING_ENTRIES)
            opts[mode]['mode'] = default_mode

    return opts
Beispiel #7
0
def speed(bond_name):
    """Returns the bond speed if bondName refers to a bond, 0 otherwise."""
    opts = properties(bond_name,
                      filter_properties=('slaves', 'active_slave', 'mode'))
    try:
        if opts['slaves']:
            if opts['mode'][1] in BONDING_FAILOVER_MODES:
                active_slave = opts['active_slave']
                s = nics.speed(active_slave[0]) if active_slave else 0
            elif opts['mode'][1] in BONDING_LOADBALANCE_MODES:
                s = sum(nics.speed(slave) for slave in opts['slaves'])
            return s
    except Exception:
        logging.exception('cannot read %s speed', bond_name)
    return 0
Beispiel #8
0
 def test_bond_properties_with_filter_out(self, bond0):
     properties = sysfs_options.properties(bond0.master,
                                           filter_out_properties=('mode', ))
     assert 'mode' not in properties
     assert len(properties) > 1
Beispiel #9
0
 def test_bond_properties_with_filter_out(self):
     with bond_device() as bond:
         properties = sysfs_options.properties(
             bond.master, filter_out_properties=('mode',))
         self.assertTrue('mode' not in properties)
         self.assertGreater(len(properties), 1)
Beispiel #10
0
 def test_bond_properties_with_filter(self):
     with bond_device() as bond:
         properties = sysfs_options.properties(
             bond.master, filter_properties=('mode',))
         self.assertTrue('mode' in properties)
         self.assertEqual(1, len(properties))