Petr Horáček has uploaded a new change for review. Change subject: net: native ovs: check for bond existence ......................................................................
net: native ovs: check for bond existence Network creation is not connected with bond creation in any way, created bond is available for all networks (should be divided), therefore we have to check for it's existence manually. https://bugzilla.redhat.com/1195208 Change-Id: Ife76761b5ca5a32dcff030efd6a5bef9b9c51f7b Signed-off-by: Petr Horáček <phora...@redhat.com> --- M lib/vdsm/network/ovs/switch.py M lib/vdsm/network/ovs/validator.py M tests/network/ovs_test.py 3 files changed, 30 insertions(+), 13 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/61/56461/1 diff --git a/lib/vdsm/network/ovs/switch.py b/lib/vdsm/network/ovs/switch.py index db6146d..f095277 100644 --- a/lib/vdsm/network/ovs/switch.py +++ b/lib/vdsm/network/ovs/switch.py @@ -31,12 +31,12 @@ def validate_network_setup(nets, bonds): - running_networks = RunningConfig().networks + running_config = RunningConfig() kernel_nics = CachingNetInfo().nics for net, attrs in six.iteritems(nets): validator.validate_net_configuration( - net, attrs, running_networks, kernel_nics) + net, attrs, bonds, running_config, kernel_nics) for bond, attrs in six.iteritems(bonds): validator.validate_bond_configuration(attrs, kernel_nics) diff --git a/lib/vdsm/network/ovs/validator.py b/lib/vdsm/network/ovs/validator.py index b0e43a5..4f4e75f 100644 --- a/lib/vdsm/network/ovs/validator.py +++ b/lib/vdsm/network/ovs/validator.py @@ -30,7 +30,8 @@ return None -def validate_net_configuration(net, attrs, running_networks, kernel_nics): +def validate_net_configuration(net, attrs, to_be_configured_bonds, + running_config, kernel_nics): """Test if network meets logical Vdsm requiremets. Bridgeless networks are allowed in order to support Engine requirements. @@ -45,7 +46,7 @@ if vlan is None: # TODO: We should support multiple utagged networks per hosts (probably # via multiple OVS bridges). - untagged_net = _get_untagged_net(running_networks) + untagged_net = _get_untagged_net(running_config.networks) if untagged_net not in (None, net): raise ne.ConfigNetworkError( ne.ERR_BAD_VLAN, @@ -54,6 +55,11 @@ if nic not in kernel_nics: raise ne.ConfigNetworkError( ne.ERR_BAD_NIC, 'Nic %s does not exist' % nic) + elif bond is not None: + if (bond not in running_config.bonds and + bond not in to_be_configured_bonds): + raise ne.ConfigNetworkError( + ne.ERR_BAD_BONDING, 'Bond %s does not exist' % bond) else: # We do not support ifaceless VLANs in Vdsm, because of legacy VLAN # device requires an iface to lie on. It wouldn't be a problem in OVS, diff --git a/tests/network/ovs_test.py b/tests/network/ovs_test.py index d0bc54f..c167d4e 100644 --- a/tests/network/ovs_test.py +++ b/tests/network/ovs_test.py @@ -18,6 +18,7 @@ # from __future__ import absolute_import +from vdsm.netconfpersistence import BaseConfig from vdsm.network import errors as ne from vdsm.network.ovs import switch as ovs_switch from vdsm.network.ovs import validator as ovs_validator @@ -30,37 +31,47 @@ class ValidationTests(TestCaseBase): def test_adding_a_new_single_untagged_net(self): - fake_running_networks = { - 'net1': {'nic': 'eth0', 'vlan': 10, 'switch': 'ovs'}} + fake_running_config = BaseConfig( + {'net1': {'nic': 'eth0', 'vlan': 10, 'switch': 'ovs'}}, {}) fake_kernel_nics = ['eth0'] with self.assertNotRaises(): ovs_validator.validate_net_configuration( 'net2', {'nic': 'eth0', 'switch': 'ovs'}, - fake_running_networks, fake_kernel_nics) + fake_running_config, fake_kernel_nics) def test_edit_single_untagged_net_nic(self): - fake_running_networks = {'net1': {'nic': 'eth0', 'switch': 'ovs'}} + fake_running_config = BaseConfig( + {'net1': {'nic': 'eth0', 'switch': 'ovs'}}, {}) fake_kernel_nics = ['eth0', 'eth1'] with self.assertNotRaises(): ovs_validator.validate_net_configuration( 'net1', {'nic': 'eth1', 'switch': 'ovs'}, - fake_running_networks, fake_kernel_nics) + fake_running_config, fake_kernel_nics) def test_adding_a_second_untagged_net(self): - fake_running_networks = {'net1': {'nic': 'eth0', 'switch': 'ovs'}} + fake_running_config = BaseConfig( + {'net1': {'nic': 'eth0', 'switch': 'ovs'}}, {}) fake_kernel_nics = ['eth0', 'eth1'] with self.assertRaises(ne.ConfigNetworkError): ovs_validator.validate_net_configuration( 'net2', {'nic': 'eth1', 'switch': 'ovs'}, - fake_running_networks, fake_kernel_nics) + fake_running_config, fake_kernel_nics) def test_add_network_with_non_existing_nic(self): - fake_running_networks = {} + fake_running_config = BaseConfig({}, {}) fake_kernel_nics = [] with self.assertRaises(ne.ConfigNetworkError): ovs_validator.validate_net_configuration( 'net1', {'nic': 'eth0', 'switch': 'ovs'}, - fake_running_networks, fake_kernel_nics) + fake_running_config, fake_kernel_nics) + + def test_add_network_with_non_existing_bond(self): + fake_running_config = BaseConfig({}, {}) + fake_kernel_nics = [] + with self.assertRaises(ne.ConfigNetworkError): + ovs_validator.validate_net_configuration( + 'net1', {'bonding': 'bond1', 'switch': 'ovs'}, + fake_running_config, fake_kernel_nics) def test_bond_with_no_slaves(self): fake_kernel_nics = [] -- To view, visit https://gerrit.ovirt.org/56461 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ife76761b5ca5a32dcff030efd6a5bef9b9c51f7b Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Petr Horáček <phora...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches