Skip to content

Commit

Permalink
net: Drop netinfo.bonding.slaves function
Browse files Browse the repository at this point in the history
Use link.bond driver to fetch the current slaves of a bond, replacing
netinfo.bonding.

This is the first patch in a series of patches that aim to cleanup
netinfo.bonding and use the bond driver instead.

Change-Id: I14f81b0ef91756d49e0473f987732ebd1d97378a
Signed-off-by: Edward Haas <[email protected]>
  • Loading branch information
EdDev authored and dankenigsberg committed Jan 24, 2017
1 parent 337ab87 commit 09a0fae
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/vdsm/network/configurators/ifcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from vdsm.network import libvirt
from vdsm.network.ip import address
from vdsm.network.ip import dhclient
from vdsm.network.link.bond import Bond
from vdsm.network.netconfpersistence import RunningConfig, PersistentConfig
from vdsm.network.netinfo import (bonding as netinfo_bonding, mtus, nics,
vlans, misc, NET_PATH)
Expand Down Expand Up @@ -770,7 +771,7 @@ def setIfaceMtu(self, iface, newmtu):

def setBondingMtu(self, bonding, newmtu):
self.setIfaceMtu(bonding, newmtu)
slaves = netinfo_bonding.slaves(bonding)
slaves = Bond(bonding).slaves
for slave in slaves:
self.setIfaceMtu(slave, newmtu)

Expand Down
3 changes: 2 additions & 1 deletion lib/vdsm/network/configurators/iproute2.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from vdsm.network.ip import dhclient
from vdsm.network.ipwrapper import (routeAdd, routeDel, ruleAdd, ruleDel,
IPRoute2Error)
from vdsm.network.link.bond import Bond
from vdsm.network.netinfo import bonding, vlans, bridges, mtus
from vdsm.network.netinfo.cache import ifaceUsed
from vdsm.constants import EXT_BRCTL
Expand Down Expand Up @@ -98,7 +99,7 @@ def configureBond(self, bond, **opts):
self.configApplier.ifdown(bond)
self.configApplier.addBondOptions(bond)
for slave in bond.slaves:
if slave.name not in bonding.slaves(bond.name):
if slave.name not in Bond(bond.name).slaves:
self.configApplier.addBondSlave(bond, slave)
slave.configure(**opts)
if bond.ipv4.bootproto == 'dhcp':
Expand Down
3 changes: 2 additions & 1 deletion lib/vdsm/network/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import six
import re

from vdsm.network.link import bond as link_bond
from vdsm.network.netinfo import bonding, mtus, nics
from vdsm.network.netinfo.cache import ifaceUsed, CachingNetInfo
from vdsm.network.ip.address import IPv4, IPv6
Expand Down Expand Up @@ -237,7 +238,7 @@ def configure(self, **opts):
self.mtu <= mtus.getMtu(self.name) and
self.areOptionsApplied() and
frozenset(slave.name for slave in self.slaves) ==
frozenset(bonding.slaves(self.name))):
frozenset(link_bond.Bond(self.name).slaves)):
return

self.configurator.configureBond(self, **opts)
Expand Down
9 changes: 3 additions & 6 deletions lib/vdsm/network/netinfo/bonding.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
from .misc import visible_devs
from . import nics

from vdsm.network.link.bond import Bond

# In order to limit the scope of change, this module is now acting as a proxy
# to the link.bond.sysfs_options module.
from vdsm.network.link.bond.sysfs_options import _bond_opts_read_elements
Expand Down Expand Up @@ -66,11 +68,6 @@
bondings = partial(visible_devs, Link.isBOND)


def slaves(bond_name):
with open(BONDING_SLAVES % bond_name) as f:
return f.readline().split()


def _file_value(path):
if os.path.exists(path):
with open(path, 'r') as f:
Expand All @@ -94,7 +91,7 @@ def get_bond_agg_info(bond_name):


def info(link):
return {'hwaddr': link.address, 'slaves': slaves(link.name),
return {'hwaddr': link.address, 'slaves': list(Bond(link.name).slaves),
'active_slave': _active_slave(link.name),
'opts': _getBondingOptions(link.name)}

Expand Down
4 changes: 2 additions & 2 deletions vdsm_hooks/ethtool_options/ethtool_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import hooking
import traceback

from vdsm.network.netinfo import bonding
from vdsm.network.link.bond import Bond
from vdsm.utils import CommandPath

ETHTOOL_BINARY = CommandPath(
Expand Down Expand Up @@ -119,7 +119,7 @@ def _process_network(network, attrs):

def _net_nics(attrs):
if 'bonding' in attrs:
return bonding.slaves(attrs['bonding'])
return Bond(attrs['bonding']).slaves
else:
return [attrs.pop('nic')] if 'nic' in attrs else ()

Expand Down

0 comments on commit 09a0fae

Please sign in to comment.