Change in vdsm[ovirt-3.6]: hooks: ovs: show vlan in caps ports

phoracek at redhat.com phoracek at redhat.com
Wed Dec 23 14:12:39 UTC 2015


Petr Horáček has uploaded a new change for review.

Change subject: hooks: ovs: show vlan in caps ports
......................................................................

hooks: ovs: show vlan in caps ports

Until now, when we set up a tagged network we reported only
directly attached nics and bonds. To be compatible with VDSM
we have to report attached vlan (in its iface.id format) too.

Change-Id: Ica2082907035c22e72115a684f358fcbe8a8056e
Signed-off-by: Petr Horáček <phoracek at redhat.com>
Bug-Url: https://bugzilla.redhat.com/1234867
---
M tests/functional/networkTests.py
M vdsm_hooks/ovs/ovs_after_get_caps.py
2 files changed, 21 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/82/50982/1

diff --git a/tests/functional/networkTests.py b/tests/functional/networkTests.py
index 6172243..15eb6dc 100644
--- a/tests/functional/networkTests.py
+++ b/tests/functional/networkTests.py
@@ -214,19 +214,20 @@
         netinfo = self.vdsm_net.netinfo
         config = self.vdsm_net.config
         network_config = config.networks[networkName]
+        network_netinfo = netinfo.networks[networkName]
         self.assertIn(networkName, netinfo.networks)
         if bridged is not None:
-            self.assertEqual(bridged, netinfo.networks[networkName]['bridged'])
+            self.assertEqual(bridged, network_netinfo['bridged'])
             if bridged:
                 self.assertIn(networkName, netinfo.bridges)
             else:
                 self.assertNotIn(networkName, netinfo.bridges)
-        if bridgeOpts is not None and netinfo.networks[networkName]['bridged']:
+        if bridgeOpts is not None and network_netinfo['bridged']:
             appliedOpts = netinfo.bridges[networkName]['opts']
             for opt, value in bridgeOpts.iteritems():
                 self.assertEqual(value, appliedOpts[opt])
         if hostQos is not None:
-            reported_qos = netinfo.networks[networkName]['hostQos']
+            reported_qos = network_netinfo['hostQos']
             _cleanup_qos_definition(reported_qos)
             self.assertEqual(reported_qos, hostQos)
         if assert_in_running_conf and config is not None:
diff --git a/vdsm_hooks/ovs/ovs_after_get_caps.py b/vdsm_hooks/ovs/ovs_after_get_caps.py
index 7b6f397..bbb8735 100755
--- a/vdsm_hooks/ovs/ovs_after_get_caps.py
+++ b/vdsm_hooks/ovs/ovs_after_get_caps.py
@@ -73,6 +73,21 @@
         'cfg': {'BOOTPROTO': 'dhcp' if dhcpv4 else 'none'}}
 
 
+def _get_ports(network, attrs):
+    """Return network's ports. Such ports consist of a port explicitly assigned
+    during network setup (nic/bond/vlan) and ports attached by libvirt.
+    Network's nics and bonds are listed by ovs-vsctl list-ports command.
+    However, if assigned port is a vlan, it is not listed and it has to be
+    added explicitly."""
+    top_device = network if 'vlan' in attrs else BRIDGE_NAME
+    ports = _list_ports(top_device)
+    if 'vlan' in attrs:
+        assigned_vlan = '%s.%s' % (attrs.get('bonding') or attrs.get('nic'),
+                                   attrs.get('vlan'))
+        ports.append(assigned_vlan)
+    return ports
+
+
 def networks_caps(running_config):
     ovs_networks_caps = {}
     dhcpv4ifaces, dhcpv6ifaces = netinfo._get_dhclient_ifaces()
@@ -83,7 +98,7 @@
                                  routes)
         net_info['iface'] = network
         net_info['bridged'] = True
-        net_info['ports'] = _list_ports(interface)
+        net_info['ports'] = _get_ports(network, attrs)
         net_info['stp'] = _get_stp(interface)
         ovs_networks_caps[network] = net_info
     return ovs_networks_caps
@@ -98,7 +113,7 @@
         net_info = _get_net_info(attrs, interface, dhcpv4ifaces, dhcpv6ifaces,
                                  routes)
         net_info['bridged'] = True
-        net_info['ports'] = _list_ports(interface)
+        net_info['ports'] = _get_ports(network, attrs)
         # TODO netinfo._bridge_options does not work here
         net_info['opts'] = {}
         net_info['stp'] = _get_stp(interface)


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica2082907035c22e72115a684f358fcbe8a8056e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Petr Horáček <phoracek at redhat.com>


More information about the vdsm-patches mailing list