Skip to content

Commit

Permalink
network: remove masking import for sysfs_options
Browse files Browse the repository at this point in the history
The masking import add no value, but interfere with the structure of the
code and its readability.

Change-Id: I263aaec49a05205002649bf454034911cfc74610
Signed-off-by: Eitan Raviv <eraviv@redhat.com>
  • Loading branch information
erav authored and almusil committed Sep 26, 2022
1 parent b5585fb commit d900923
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
9 changes: 5 additions & 4 deletions lib/vdsm/network/kernelconfig.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2015-2020 Red Hat, Inc.
# Copyright 2015-2022 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -23,6 +23,7 @@
import copy
import six

from vdsm.network.link.bond import sysfs_options
from vdsm.network.link.bond import sysfs_options_mapper as bond_opts_mapper
from vdsm.network.netinfo import bonding
from vdsm.network.netinfo import bridges
Expand Down Expand Up @@ -224,9 +225,9 @@ def _parse_bond_options(opts):
opts = dict((pair.split('=', 1) for pair in opts.split()))

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

# Force a numeric value for an option
for opname, opval in opts.items():
Expand All @@ -236,5 +237,5 @@ def _parse_bond_options(opts):
if numeric_val is not None:
opts[opname] = numeric_val

defaults = bonding.getDefaultBondingOptions(numeric_mode)
defaults = sysfs_options.getDefaultBondingOptions(numeric_mode)
return dict((k, v) for k, v in six.viewitems(opts) if v != defaults.get(k))
11 changes: 0 additions & 11 deletions lib/vdsm/network/netinfo/bonding.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,8 @@

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 import sysfs_options
from vdsm.network.link.bond.sysfs_options import getDefaultBondingOptions
from vdsm.network.link.bond.sysfs_options import getAllDefaultBondingOptions
from vdsm.network.link.setup import parse_bond_options

getDefaultBondingOptions
getAllDefaultBondingOptions
parse_bond_options

BONDING_ACTIVE_SLAVE = '/sys/class/net/%s/bonding/active_slave'
Expand Down Expand Up @@ -98,7 +91,3 @@ def permanent_address():
len('Permanent HW addr: ') : -1 # noqa: E203
]
return paddr


def numerize_bond_mode(mode):
return sysfs_options.numerize_bond_mode(mode)
9 changes: 5 additions & 4 deletions tests/network/functional/netfunctestlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
from vdsm.network.dhcp_monitor import MonitoredItemPool
from vdsm.network.ip.address import ipv6_supported, prefix2netmask
from vdsm.network.link.iface import iface
from vdsm.network.link.bond import sysfs_options as bond_options
from vdsm.network.link.bond import sysfs_options
from vdsm.network.link.bond import sysfs_options_mapper as bond_opts_mapper
from vdsm.network.link.bond.sysfs_options import getDefaultBondingOptions
from vdsm.network.netconfpersistence import RunningConfig
from vdsm.network.netinfo import bridges
from vdsm.network.netinfo.cache import CachingNetInfo
Expand Down Expand Up @@ -888,7 +887,9 @@ def wait_bonds_lp_interval():
LACP_BOND_MODE = '4'

default_lp_interval = int(
getDefaultBondingOptions(LACP_BOND_MODE)['lp_interval'][0]
sysfs_options.getDefaultBondingOptions(LACP_BOND_MODE)['lp_interval'][
0
]
)
time.sleep(default_lp_interval + GRACE_PERIOD)

Expand Down Expand Up @@ -953,7 +954,7 @@ def _numerize_bond_options(opts):
if not mode:
return opts

optmap['mode'] = numeric_mode = bond_options.numerize_bond_mode(mode)
optmap['mode'] = numeric_mode = sysfs_options.numerize_bond_mode(mode)
for opname, opval in optmap.items():
numeric_val = bond_opts_mapper.get_bonding_option_numeric_val(
numeric_mode, opname, opval
Expand Down

0 comments on commit d900923

Please sign in to comment.