Petr Horáček has uploaded a new change for review.
Change subject: network: allow custom bondOption ......................................................................
network: allow custom bondOption
Allow 'custom' in bond options. This value will be accepted by Bond.validateOptions method but it will not be passed to configurator.
Thanks to this patch, users will be allowed to pass custom properties to setupNetworks hooks.
This path was reverted in past because of malfunction, now it should work, there is a new test for sure.
Change-Id: I9ace532d959bc3195a8a92b4536bdc0062bc7d1d Signed-off-by: Petr Horáček phoracek@redhat.com --- M lib/vdsm/netinfo.py M tests/functional/networkTests.py M vdsm/network/models.py 3 files changed, 44 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/82/40882/1
diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py index e7563d6..3a2aa8e 100644 --- a/lib/vdsm/netinfo.py +++ b/lib/vdsm/netinfo.py @@ -70,8 +70,9 @@ _BONDING_FAILOVER_MODES = frozenset(('1', '3')) _BONDING_LOADBALANCE_MODES = frozenset(('0', '2', '4', '5', '6')) _EXCLUDED_BONDING_ENTRIES = frozenset(( - 'slaves', 'active_slave', 'mii_status', 'queue_id', 'ad_aggregator', - 'ad_num_ports', 'ad_actor_key', 'ad_partner_key', 'ad_partner_mac' + 'slaves', 'active_slave', 'mii_status', 'queue_id', 'ad_aggregator', + 'ad_num_ports', 'ad_actor_key', 'ad_partner_key', 'ad_partner_mac', + 'custom' )) _IFCFG_ZERO_SUFFIXED = frozenset( ('IPADDR0', 'GATEWAY0', 'PREFIX0', 'NETMASK0')) diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py index 0bfda68..1328783 100644 --- a/tests/functional/networkTests.py +++ b/tests/functional/networkTests.py @@ -1848,7 +1848,7 @@ else: network_params.update( {'ipaddr': IP_ADDRESS_IN_NETWORK, 'netmask': IP_MASK, - 'gateway': IP_GATEWAY}) + 'gateway': IP_GATEWAY})
status, msg = self.vdsm_net.setupNetworks( {NETWORK_NAME: network_params}, {}, NOCHK) @@ -2387,3 +2387,25 @@ self.assertNetworkDoesntExist(NETWORK_NAME) self.assertBondDoesntExist(BONDING_NAME, [nic]) self.vdsm_net.save_config() + + @cleanupNet + @ValidateRunningAsRoot + def test_setupNetworks_bond_with_custom_option(self): + with dummyIf(1) as nics: + status, msg = self.vdsm_net.setupNetworks( + {}, + {BONDING_NAME: {'nics': nics, + 'options': 'custom=foo mode=balance-rr'}}, + NOCHK) + self.assertEqual(status, SUCCESS, msg) + self.assertBondExists(BONDING_NAME, nics) + with open(NET_CONF_PREF + BONDING_NAME) as f: + for l in f: + if 'BONDING_OPTS' in l: + self.assertNotIn('custom=foo', l) + self.assertIn('mode=balance-rr', l) + + status, msg = self.vdsm_net.setupNetworks( + {}, {BONDING_NAME: {'remove': True}}, NOCHK) + self.assertEqual(status, SUCCESS, msg) + self.assertBondDoesntExist(BONDING_NAME, nics) diff --git a/vdsm/network/models.py b/vdsm/network/models.py index 708bad8..9526b99 100644 --- a/vdsm/network/models.py +++ b/vdsm/network/models.py @@ -276,9 +276,25 @@ _netinfo=_netinfo)) return slaves
+ @staticmethod + def remove_custom_option(options): + """ 'custom' property should not be exposed to configurator, it is + only for purpose of hooks """ + d_opts = dict(opt.split('=', 1) for opt in options.split()) + try: + d_opts.pop('custom') + d_opts = ['%s=%s' % (key, value) for key, value in d_opts.items()] + return ' '.join(d_opts) + except KeyError: + return options + @classmethod def objectivize(cls, name, configurator, options, nics, mtu, _netinfo, destroyOnMasterRemoval=None): + + if options: + options = cls.remove_custom_option(options) + if nics: # New bonding or edit bonding. slaves = cls._objectivizeSlaves(name, configurator, _nicSort(nics), mtu, _netinfo) @@ -318,8 +334,8 @@ try: for option in bondingOptions.split(): key, _ = option.split('=') - if not os.path.exists('/sys/class/net/%s/bonding/%s' % - (bond, key)): + if key != 'custom' and not os.path.exists( + '/sys/class/net/%s/bonding/%s' % (bond, key)): raise ConfigNetworkError(ne.ERR_BAD_BONDING, '%r is ' 'not a valid bonding option' % key)
automation@ovirt.org has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Dan Kenigsberg has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 1: Code-Review-1
(1 comment)
https://gerrit.ovirt.org/#/c/40882/1/tests/functional/networkTests.py File tests/functional/networkTests.py:
Line 2398: 'options': 'custom=foo mode=balance-rr'}}, Line 2399: NOCHK) Line 2400: self.assertEqual(status, SUCCESS, msg) Line 2401: self.assertBondExists(BONDING_NAME, nics) Line 2402: with open(NET_CONF_PREF + BONDING_NAME) as f: this is terribly specific to the ifcfg configurator. I think that passing the expected option to assertBondExists() does what we need. Line 2403: for l in f: Line 2404: if 'BONDING_OPTS' in l: Line 2405: self.assertNotIn('custom=foo', l) Line 2406: self.assertIn('mode=balance-rr', l)
Petr Horáček has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 1:
(1 comment)
https://gerrit.ovirt.org/#/c/40882/1/tests/functional/networkTests.py File tests/functional/networkTests.py:
Line 2398: 'options': 'custom=foo mode=balance-rr'}}, Line 2399: NOCHK) Line 2400: self.assertEqual(status, SUCCESS, msg) Line 2401: self.assertBondExists(BONDING_NAME, nics) Line 2402: with open(NET_CONF_PREF + BONDING_NAME) as f:
this is terribly specific to the ifcfg configurator. I think that passing t
it check if passed options are subset of real bond options, but i agree, we just have to change it a bit Line 2403: for l in f: Line 2404: if 'BONDING_OPTS' in l: Line 2405: self.assertNotIn('custom=foo', l) Line 2406: self.assertIn('mode=balance-rr', l)
automation@ovirt.org has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 2:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Dan Kenigsberg has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 2: Code-Review-1
(1 comment)
https://gerrit.ovirt.org/#/c/40882/2/vdsm/network/models.py File vdsm/network/models.py:
Line 282: only for purpose of hooks """ Line 283: d_opts = dict(opt.split('=', 1) for opt in options.split()) Line 284: try: Line 285: d_opts.pop('custom') Line 286: d_opts = ['%s=%s' % (key, value) for key, value in d_opts.items()] d_opts was a dictionary, let us not overwrite it with a list (which can be completely replace by a generator expression)
Also, this code is not expected to raise KeyError, and thus should live in the "else" clause of this try-block.
alternatively, use
if d_opts.pop('custom', None) is not None:
which I find simpler. Line 287: return ' '.join(d_opts) Line 288: except KeyError: Line 289: return options Line 290:
automation@ovirt.org has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 3:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 4:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 5:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 6:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 7:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Dan Kenigsberg has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 7: Code-Review-1
(2 comments)
https://gerrit.ovirt.org/#/c/40882/7/tests/functional/networkTests.py File tests/functional/networkTests.py:
Line 2367: Line 2368: @cleanupNet Line 2369: @ValidateRunningAsRoot Line 2370: def test_setupNetworks_bond_with_custom_option(self): Line 2371: with dummyIf(1) as nics: OVS loves two ifaces Line 2372: status, msg = self.vdsm_net.setupNetworks( Line 2373: {}, Line 2374: {BONDING_NAME: {'nics': nics, Line 2375: 'options': 'custom=foo mode=balance-rr'}},
Line 2368: @cleanupNet Line 2369: @ValidateRunningAsRoot Line 2370: def test_setupNetworks_bond_with_custom_option(self): Line 2371: with dummyIf(1) as nics: Line 2372: status, msg = self.vdsm_net.setupNetworks( needs a rebase for vdsm_net removal Line 2373: {}, Line 2374: {BONDING_NAME: {'nics': nics, Line 2375: 'options': 'custom=foo mode=balance-rr'}}, Line 2376: NOCHK)
automation@ovirt.org has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 8:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 9:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Dan Kenigsberg has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 9: Code-Review+2
automation@ovirt.org has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 10:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Petr Horáček has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 10: Verified+1
Passes functional network tests and net* unit tests without a regression.
automation@ovirt.org has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 11:
* Update tracker::#1234867::OK * Check Bug-Url::OK * Check Public Bug::#1234867::OK, public bug * Check Product::#1234867::OK, Correct product oVirt * Check TR::SKIP, not in a monitored branch (ovirt-3.5 ovirt-3.4 ovirt-3.3 ovirt-3.2) * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Dan Kenigsberg has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 11: Code-Review+2 Continuous-Integration+1
CI failed on unrelated
gerrit.ovirt.org[0: 107.22.212.69]: errno=Connection timed out
Dan Kenigsberg has submitted this change and it was merged.
Change subject: network: allow custom bondOption ......................................................................
network: allow custom bondOption
Allow 'custom' in bond options. This value will be accepted by Bond.validateOptions method but it will not be passed to configurator.
Thanks to this patch, users will be allowed to pass custom properties to setupNetworks hooks.
This path was reverted in past because of malfunction, now it should work, there is a new test for sure.
Change-Id: I9ace532d959bc3195a8a92b4536bdc0062bc7d1d Signed-off-by: Petr Horáček phoracek@redhat.com Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1234867 Reviewed-on: https://gerrit.ovirt.org/40882 Reviewed-by: Dan Kenigsberg danken@redhat.com Continuous-Integration: Dan Kenigsberg danken@redhat.com --- M lib/vdsm/netinfo.py M tests/functional/networkTests.py M vdsm/network/models.py 3 files changed, 37 insertions(+), 3 deletions(-)
Approvals: Petr Horáček: Verified Dan Kenigsberg: Looks good to me, approved; Passed CI tests
automation@ovirt.org has posted comments on this change.
Change subject: network: allow custom bondOption ......................................................................
Patch Set 12:
* update_tracker: OK * Check TR::#1234867::ERROR, 3.5.5 should not match .*
vdsm-patches@lists.fedorahosted.org