Change in vdsm[ovirt-3.6]: Always propagate bonding mode to engine
sshnaidm at redhat.com
sshnaidm at redhat.com
Mon Dec 21 10:44:01 UTC 2015
Sagi Shnaidman has uploaded a new change for review.
Change subject: Always propagate bonding mode to engine
......................................................................
Always propagate bonding mode to engine
Without this patch the bond mode is not propagated
if it's not equal to 0 (default) although
engine expect it to be always propagated
Change-Id: I4883022420092d822419fa3b7b9fae50741dd360
Bug-Url: https://bugzilla.redhat.com/1276445
Signed-off-by: Sagi Shnaidman <sshnaidm at redhat.com>
---
M lib/vdsm/netconfpersistence.py
M lib/vdsm/netinfo.py
M tests/functional/networkTests.py
3 files changed, 32 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/50793/1
diff --git a/lib/vdsm/netconfpersistence.py b/lib/vdsm/netconfpersistence.py
index b5c3f14..a0af856 100644
--- a/lib/vdsm/netconfpersistence.py
+++ b/lib/vdsm/netconfpersistence.py
@@ -369,6 +369,8 @@
# TODO: globalize default bond options from Bond in models.py
normalized_opts = self._parse_bond_options(
bond_attr.get('options'))
+ if "mode" not in normalized_opts:
+ normalized_opts["mode"] = '0'
bond_attr['options'] = self._netinfo.bondOptsForIfcfg(
normalized_opts)
# before d18e2f10 bondingOptions were also part of networks, so in case
diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py
index fd5b209..ad35072 100644
--- a/lib/vdsm/netinfo.py
+++ b/lib/vdsm/netinfo.py
@@ -427,14 +427,15 @@
def _getBondingOptions(bond):
"""
Return non-empty options differing from defaults, excluding not actual or
- not applicable options, e.g. 'ad_num_ports' or 'slaves'.
+ not applicable options, e.g. 'ad_num_ports' or 'slaves' and always return
+ bonding mode even if it's default, e.g. 'mode=0'
"""
opts = bondOpts(bond)
mode = opts['mode'][-1] if 'mode' in opts else None
defaults = getDefaultBondingOptions(mode)
return dict(((opt, val[-1]) for (opt, val) in opts.iteritems()
- if val and val != defaults.get(opt)))
+ if val and (val != defaults.get(opt) or opt == "mode")))
def _bondOptsForIfcfg(opts):
diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
index 7bff125..5ab22d1 100644
--- a/tests/functional/networkTests.py
+++ b/tests/functional/networkTests.py
@@ -270,8 +270,8 @@
# TODO: we should try and call this logic always during
# TODO: assertBondExists and be stricter. Will probably need to fix a
# TODO: few tests
- self.assertEqual(set(self._get_active_bond_opts(bond)),
- set(opts))
+ self.assertEqual(set(self._get_active_bond_opts(bond))-set(["mode=0"]),
+ set(opts)-set(["mode=0"]))
def _get_active_bond_opts(self, bondName):
netinfo = self.vdsm_net.netinfo
@@ -2745,3 +2745,28 @@
{}, {BONDING_NAME: {'remove': True}}, NOCHK)
self.assertEqual(status, SUCCESS, msg)
self.assertBondDoesntExist(BONDING_NAME, nics)
+
+ @permutations([[{}], [{'options': 'mode=1'}], [{'options': 'mode=0'}]])
+ @cleanupNet
+ @ValidateRunningAsRoot
+ def test_bondmode_in_capabilities(self, mode_arg):
+ with dummyIf(2) as nics:
+ if mode_arg:
+ origin_mode = mode_arg.get("options").split("=")[1]
+ else:
+ origin_mode = '0'
+ bonding = {'nics': nics}
+ bonding.update(mode_arg)
+ status, msg = self.setupNetworks(
+ {},
+ {BONDING_NAME: bonding},
+ NOCHK)
+ self.assertEqual(status, SUCCESS, msg)
+ self.assertBondExists(BONDING_NAME, nics)
+ status, msg, info = self.vdsm_net.getVdsCapabilities()
+ mode = info['bondings'][BONDING_NAME]['opts'].get('mode')
+ self.assertEqual(mode, origin_mode)
+ status, msg = self.setupNetworks(
+ {}, {BONDING_NAME: {'remove': True}}, NOCHK)
+ self.assertEqual(status, SUCCESS, msg)
+ self.assertBondDoesntExist(BONDING_NAME, nics)
--
To view, visit https://gerrit.ovirt.org/50793
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4883022420092d822419fa3b7b9fae50741dd360
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Sagi Shnaidman <sshnaidm at redhat.com>
More information about the vdsm-patches
mailing list