Change in vdsm[master]: netinfo: Rename and export only one bondOpts() function
osvoboda at redhat.com
osvoboda at redhat.com
Tue Nov 18 18:17:31 UTC 2014
Ondřej Svoboda has uploaded a new change for review.
Change subject: netinfo: Rename and export only one bondOpts() function
......................................................................
netinfo: Rename and export only one bondOpts() function
_bondOpts(), originally without _, now serves as a low-level reader of all
bonding properties. The public bondOpts() never returns read-only values
and special options such as 'slaves'.
Change-Id: I1ca8be461cfefcb3cebb6cb1c1bcf27f1d94c4b1
Signed-off-by: Ondřej Svoboda <osvoboda at redhat.com>
---
M lib/vdsm/netinfo.py
M lib/vdsm/tool/dump_bonding_defaults.py
2 files changed, 8 insertions(+), 9 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/98/35298/1
diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py
index 10bbecb..2a42af8 100644
--- a/lib/vdsm/netinfo.py
+++ b/lib/vdsm/netinfo.py
@@ -130,7 +130,7 @@
return f.readline().split()
-def bondOpts(bond, keys=None):
+def _bondOpts(bond, keys=None):
""" Returns a dictionary of bond option name and a values iterable. E.g.,
{'mode': ('balance-rr', '0'), 'xmit_hash_policy': ('layer2', '0')}
"""
@@ -146,12 +146,12 @@
return opts
-def realBondOpts(bond):
+def bondOpts(bond, keys=None):
"""
- Return a dictionary in the same format as bondOpts(). Exclude entries that
+ Return a dictionary in the same format as _bondOpts(). Exclude entries that
are not bonding options, e.g. 'ad_num_ports' or 'slaves'.
"""
- return dict(((opt, val) for (opt, val) in bondOpts(bond).iteritems()
+ return dict(((opt, val) for (opt, val) in _bondOpts(bond, keys).iteritems()
if opt not in _EXCLUDED_BONDING_ENTRIES))
@@ -270,7 +270,7 @@
def bondSpeed(bondName):
"""Returns the bond speed if bondName refers to a bond, 0 otherwise."""
- opts = bondOpts(bondName, keys=['slaves', 'active_slave', 'mode'])
+ opts = _bondOpts(bondName, keys=['slaves', 'active_slave', 'mode'])
try:
if opts['slaves']:
if opts['mode'][1] in _BONDING_FAILOVER_MODES:
@@ -422,7 +422,7 @@
Return non-empty options differing from defaults, excluding not actual or
not applicable options, e.g. 'ad_num_ports' or 'slaves'.
"""
- opts = realBondOpts(bond)
+ opts = bondOpts(bond)
mode = opts['mode'][-1] if 'mode' in opts else None
defaults = _getDefaultBondingOptions(mode)
diff --git a/lib/vdsm/tool/dump_bonding_defaults.py b/lib/vdsm/tool/dump_bonding_defaults.py
index 09bb82d..51453f2 100644
--- a/lib/vdsm/tool/dump_bonding_defaults.py
+++ b/lib/vdsm/tool/dump_bonding_defaults.py
@@ -22,8 +22,7 @@
import random
import string
-from ..netinfo import (BONDING_MASTERS, BONDING_OPT, BONDING_DEFAULTS,
- bondOpts, realBondOpts)
+from ..netinfo import BONDING_MASTERS, BONDING_OPT, BONDING_DEFAULTS, bondOpts
from . import expose, ExtraArgsError
@@ -57,7 +56,7 @@
# only read non-empty options
opts[mode] = dict(((opt, val) for (opt, val) in
- realBondOpts(bond_name).iteritems() if val))
+ bondOpts(bond_name).iteritems() if val))
opts[mode]['mode'] = default_mode
finally:
--
To view, visit http://gerrit.ovirt.org/35298
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ca8be461cfefcb3cebb6cb1c1bcf27f1d94c4b1
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ondřej Svoboda <osvoboda at redhat.com>
More information about the vdsm-patches
mailing list