From d900923b167508e9d12120d3f0374d2320e4f4bb Mon Sep 17 00:00:00 2001 From: Eitan Raviv Date: Sun, 17 Jul 2022 21:12:08 +0300 Subject: [PATCH] network: remove masking import for sysfs_options 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 --- lib/vdsm/network/kernelconfig.py | 9 +++++---- lib/vdsm/network/netinfo/bonding.py | 11 ----------- tests/network/functional/netfunctestlib.py | 9 +++++---- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/lib/vdsm/network/kernelconfig.py b/lib/vdsm/network/kernelconfig.py index f9d280dafe..0dd9898a43 100644 --- a/lib/vdsm/network/kernelconfig.py +++ b/lib/vdsm/network/kernelconfig.py @@ -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 @@ -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 @@ -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(): @@ -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)) diff --git a/lib/vdsm/network/netinfo/bonding.py b/lib/vdsm/network/netinfo/bonding.py index 27df57302e..5d77a01f1b 100644 --- a/lib/vdsm/network/netinfo/bonding.py +++ b/lib/vdsm/network/netinfo/bonding.py @@ -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' @@ -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) diff --git a/tests/network/functional/netfunctestlib.py b/tests/network/functional/netfunctestlib.py index 8ad9ef14d2..109576d573 100644 --- a/tests/network/functional/netfunctestlib.py +++ b/tests/network/functional/netfunctestlib.py @@ -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 @@ -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) @@ -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