Hello Dan Kenigsberg, Edward Haas,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/60869

to review the following change.

Change subject: net: use netinfo for OVS validation
......................................................................

net: use netinfo for OVS validation

Use real running netinfo configuration for OVS validation instead
of running config.

Change-Id: Ic75a6c52fd4f944daba50a3442a4756268998b22
Bug-Url: https://bugzilla.redhat.com/1195208
Signed-off-by: Petr Horáček <phora...@redhat.com>
Reviewed-on: https://gerrit.ovirt.org/57444
Reviewed-by: Edward Haas <edwa...@redhat.com>
Continuous-Integration: Jenkins CI
Reviewed-by: Dan Kenigsberg <dan...@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, 21 insertions(+), 25 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/69/60869/1

diff --git a/lib/vdsm/network/ovs/switch.py b/lib/vdsm/network/ovs/switch.py
index 7318a25..086fbd1 100644
--- a/lib/vdsm/network/ovs/switch.py
+++ b/lib/vdsm/network/ovs/switch.py
@@ -23,20 +23,20 @@
 import six
 
 from vdsm.network.netconfpersistence import RunningConfig
-from vdsm.network.netinfo.cache import CachingNetInfo
+from vdsm.network.netinfo.nics import nics
 
+from . import info
 from . import validator
 
 SWITCH_TYPE = 'ovs'
 
 
 def validate_network_setup(nets, bonds):
-    running_config = RunningConfig()
-    kernel_nics = CachingNetInfo().nics
-
+    running_bonds = info.get_netinfo()['bondings']
+    kernel_nics = nics()
     for net, attrs in six.iteritems(nets):
         validator.validate_net_configuration(
-            net, attrs, bonds, running_config, kernel_nics)
+            net, attrs, bonds, running_bonds, 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 f1ebc88..f1b2066 100644
--- a/lib/vdsm/network/ovs/validator.py
+++ b/lib/vdsm/network/ovs/validator.py
@@ -22,7 +22,7 @@
 
 
 def validate_net_configuration(net, attrs, to_be_configured_bonds,
-                               running_config, kernel_nics):
+                               running_bonds, kernel_nics):
     """Test if network meets logical Vdsm requiremets.
 
     Bridgeless networks are allowed in order to support Engine requirements.
@@ -38,7 +38,7 @@
         if nic and nic not in kernel_nics:
             raise ne.ConfigNetworkError(
                 ne.ERR_BAD_NIC, 'Nic %s does not exist' % nic)
-        if bond and (bond not in running_config.bonds and
+        if bond and (bond not in running_bonds and
                      bond not in to_be_configured_bonds):
             raise ne.ConfigNetworkError(
                 ne.ERR_BAD_BONDING, 'Bond %s does not exist' % bond)
diff --git a/tests/network/ovs_test.py b/tests/network/ovs_test.py
index bfa9e5a..0d546f3 100644
--- a/tests/network/ovs_test.py
+++ b/tests/network/ovs_test.py
@@ -18,7 +18,6 @@
 #
 from __future__ import absolute_import
 
-from vdsm.network.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
@@ -31,72 +30,69 @@
 class ValidationTests(TestCaseBase):
 
     def test_adding_a_new_single_untagged_net(self):
-        fake_running_config = BaseConfig(
-            {'net1': {'nic': 'eth0', 'vlan': 10, 'switch': 'ovs'}}, {})
+        fake_running_bonds = {}
         fake_to_be_added_bonds = {}
         fake_kernel_nics = ['eth0']
         with self.assertNotRaises():
             ovs_validator.validate_net_configuration(
                 'net2', {'nic': 'eth0', 'switch': 'ovs'},
-                fake_to_be_added_bonds, fake_running_config, fake_kernel_nics)
+                fake_to_be_added_bonds, fake_running_bonds, fake_kernel_nics)
 
     def test_edit_single_untagged_net_nic(self):
-        fake_running_config = BaseConfig(
-            {'net1': {'nic': 'eth0', 'switch': 'ovs'}}, {})
+        fake_running_bonds = {}
         fake_to_be_added_bonds = {}
         fake_kernel_nics = ['eth0', 'eth1']
         with self.assertNotRaises():
             ovs_validator.validate_net_configuration(
                 'net1', {'nic': 'eth1', 'switch': 'ovs'},
-                fake_to_be_added_bonds, fake_running_config, fake_kernel_nics)
+                fake_to_be_added_bonds, fake_running_bonds, fake_kernel_nics)
 
     def test_adding_a_second_untagged_net(self):
-        fake_running_config = BaseConfig(
-            {'net1': {'nic': 'eth0', 'switch': 'ovs'}}, {})
+        fake_running_bonds = {}
         fake_to_be_added_bonds = {}
         fake_kernel_nics = ['eth0', 'eth1']
         with self.assertNotRaises():
             ovs_validator.validate_net_configuration(
                 'net2', {'nic': 'eth1', 'switch': 'ovs'},
-                fake_to_be_added_bonds, fake_running_config, fake_kernel_nics)
+                fake_to_be_added_bonds, fake_running_bonds, fake_kernel_nics)
 
     def test_add_network_with_non_existing_nic(self):
-        fake_running_config = BaseConfig({}, {})
+        fake_running_bonds = {}
         fake_to_be_added_bonds = {}
         fake_kernel_nics = []
         with self.assertRaises(ne.ConfigNetworkError) as e:
             ovs_validator.validate_net_configuration(
                 'net1', {'nic': 'eth0', 'switch': 'ovs'},
-                fake_to_be_added_bonds, fake_running_config, fake_kernel_nics)
+                fake_to_be_added_bonds, fake_running_bonds, fake_kernel_nics)
         self.assertEquals(e.exception[0], ne.ERR_BAD_NIC)
 
     def test_add_network_with_non_existing_bond(self):
-        fake_running_config = BaseConfig({}, {})
+        fake_running_bonds = {}
         fake_to_be_added_bonds = {}
         fake_kernel_nics = []
         with self.assertRaises(ne.ConfigNetworkError) as e:
             ovs_validator.validate_net_configuration(
                 'net1', {'bonding': 'bond1', 'switch': 'ovs'},
-                fake_to_be_added_bonds, fake_running_config, fake_kernel_nics)
+                fake_to_be_added_bonds, fake_running_bonds, fake_kernel_nics)
         self.assertEquals(e.exception[0], ne.ERR_BAD_BONDING)
 
     def test_add_network_with_to_be_added_bond(self):
-        fake_running_config = BaseConfig({}, {})
+        fake_running_bonds = {}
         fake_to_be_added_bonds = {'bond1': {}}
         fake_kernel_nics = []
         with self.assertNotRaises():
             ovs_validator.validate_net_configuration(
                 'net1', {'bonding': 'bond1', 'switch': 'ovs'},
-                fake_to_be_added_bonds, fake_running_config, fake_kernel_nics)
+                fake_to_be_added_bonds, fake_running_bonds, fake_kernel_nics)
 
     def test_add_network_with_running_bond(self):
-        fake_running_config = BaseConfig({}, {'bond1': {}})
+        fake_running_bonds = {'bond1': {}}
         fake_to_be_added_bonds = {}
         fake_kernel_nics = []
         with self.assertNotRaises():
             ovs_validator.validate_net_configuration(
                 'net1', {'bonding': 'bond1', 'switch': 'ovs'},
-                fake_to_be_added_bonds, fake_running_config, fake_kernel_nics)
+                fake_to_be_added_bonds, fake_running_bonds, fake_kernel_nics)
 
     def test_bond_with_no_slaves(self):
         fake_kernel_nics = []


-- 
To view, visit https://gerrit.ovirt.org/60869
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic75a6c52fd4f944daba50a3442a4756268998b22
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Petr Horáček <phora...@redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <dan...@redhat.com>
Gerrit-Reviewer: Edward Haas <edwa...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org

Reply via email to