]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
moving vxlan module check to sanity checks and making practical
authorMatthew Thode <mthode@mthode.org>
Wed, 10 Dec 2014 21:12:25 +0000 (15:12 -0600)
committerMatthew Thode <mthode@mthode.org>
Tue, 6 Jan 2015 20:42:38 +0000 (14:42 -0600)
Instead of checking via modinfo (which only checks if a module is
available) this checks actual usage, which is a more reliable way of
testing real world problems.

Change-Id: Ida78652ed50e2cb16fa0ab7194d8468714b99d61
Closes-Bug: 1339197

neutron/cmd/sanity/checks.py
neutron/cmd/sanity_check.py
neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py
neutron/tests/functional/sanity/test_sanity.py
neutron/tests/unit/linuxbridge/test_lb_neutron_agent.py

index de7de5482f03445b6e2abf9825071e2196d678b7..c0c971b25b0bd4f8208b67fd6473d973aaa2a1ba 100644 (file)
@@ -29,13 +29,21 @@ from neutron.plugins.openvswitch.common import constants as ovs_const
 LOG = logging.getLogger(__name__)
 
 
-def vxlan_supported(root_helper, from_ip='192.0.2.1', to_ip='192.0.2.2'):
+def ovs_vxlan_supported(root_helper, from_ip='192.0.2.1', to_ip='192.0.2.2'):
     name = "vxlantest-" + utils.get_random_string(6)
     with ovs_lib.OVSBridge(name, root_helper) as br:
         port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_VXLAN)
         return port != ovs_lib.INVALID_OFPORT
 
 
+def iproute2_vxlan_supported(root_helper):
+    ip = ip_lib.IPWrapper(root_helper)
+    name = "vxlantest-" + utils.get_random_string(4)
+    port = ip.add_vxlan(name, 3000)
+    ip.del_veth(name)
+    return name == port.name
+
+
 def patch_supported(root_helper):
     seed = utils.get_random_string(6)
     name = "patchtest-" + seed
index 76bb46b801bb929f591b45865d5c37135aa59a21..2686f1a89852ca339996faa0c4fe71359dbc339b 100644 (file)
@@ -25,6 +25,8 @@ from oslo.config import cfg
 LOG = logging.getLogger(__name__)
 cfg.CONF.import_group('AGENT', 'neutron.plugins.openvswitch.common.config')
 cfg.CONF.import_group('OVS', 'neutron.plugins.openvswitch.common.config')
+cfg.CONF.import_group('VXLAN', 'neutron.plugins.linuxbridge.common.config')
+cfg.CONF.import_group('ml2', 'neutron.plugins.ml2.config')
 cfg.CONF.import_group('ml2_sriov',
                       'neutron.plugins.ml2.drivers.mech_sriov.mech_driver')
 
@@ -38,7 +40,7 @@ class BoolOptCallback(cfg.BoolOpt):
 
 
 def check_ovs_vxlan():
-    result = checks.vxlan_supported(root_helper=cfg.CONF.AGENT.root_helper)
+    result = checks.ovs_vxlan_supported(root_helper=cfg.CONF.AGENT.root_helper)
     if not result:
         LOG.error(_LE('Check for Open vSwitch VXLAN support failed. '
                       'Please ensure that the version of openvswitch '
@@ -46,6 +48,15 @@ def check_ovs_vxlan():
     return result
 
 
+def check_iproute2_vxlan():
+    result = checks.iproute2_vxlan_supported(
+                root_helper=cfg.CONF.AGENT.root_helper)
+    if not result:
+        LOG.error(_LE('Check for iproute2 VXLAN support failed. Please ensure '
+                      'that the iproute2 has VXLAN support.'))
+    return result
+
+
 def check_ovs_patch():
     result = checks.patch_supported(root_helper=cfg.CONF.AGENT.root_helper)
     if not result:
@@ -108,9 +119,11 @@ def check_vf_management():
 
 # Define CLI opts to test specific features, with a calback for the test
 OPTS = [
-    BoolOptCallback('ovs_vxlan', check_ovs_vxlan,
-                    help=_('Check for vxlan support')),
-    BoolOptCallback('ovs_patch', check_ovs_patch,
+    BoolOptCallback('ovs_vxlan', check_ovs_vxlan, default=False,
+                    help=_('Check for OVS vxlan support')),
+    BoolOptCallback('iproute2_vxlan', check_iproute2_vxlan, default=False,
+                    help=_('Check for iproute2 vxlan support')),
+    BoolOptCallback('ovs_patch', check_ovs_patch, default=False,
                     help=_('Check for patch port support')),
     BoolOptCallback('nova_notify', check_nova_notify,
                     help=_('Check for nova notification support')),
@@ -131,6 +144,9 @@ def enable_tests_from_config():
 
     if 'vxlan' in cfg.CONF.AGENT.tunnel_types:
         cfg.CONF.set_override('ovs_vxlan', True)
+    if ('vxlan' in cfg.CONF.ml2.type_drivers or
+            cfg.CONF.VXLAN.enable_vxlan):
+        cfg.CONF.set_override('iproute2_vxlan', True)
     if cfg.CONF.AGENT.tunnel_types:
         cfg.CONF.set_override('ovs_patch', True)
     if not cfg.CONF.OVS.use_veth_interconnection:
index 7507d404c0ffeff040078a96777722b673191bbd..b302e199eefe0fc7b73933188d377f8b0968c7db 100755 (executable)
@@ -562,19 +562,8 @@ class LinuxBridgeManager:
             return False
         return True
 
-    def vxlan_module_supported(self):
-        try:
-            utils.execute(cmd=['modinfo', 'vxlan'], log_fail_as_error=False)
-            return True
-        except RuntimeError:
-            return False
-
     def check_vxlan_support(self):
         self.vxlan_mode = lconst.VXLAN_NONE
-        if not self.vxlan_module_supported():
-            LOG.error(_LE('Linux kernel vxlan module and iproute2 3.8 or '
-                          'above are required to enable VXLAN.'))
-            raise exceptions.VxlanNetworkUnsupported()
 
         if self.vxlan_ucast_supported():
             self.vxlan_mode = lconst.VXLAN_UCAST
index 3006ffa5e33150f273a4316c70a8073b3f22d618..87703114eb3848e89a129456e5b72a9dc1df7ae6 100644 (file)
@@ -45,7 +45,10 @@ class SanityTestCaseRoot(functional_base.BaseSudoTestCase):
         self.check_sudo_enabled()
 
     def test_ovs_vxlan_support_runs(self):
-        checks.vxlan_supported(self.root_helper)
+        checks.ovs_vxlan_supported(self.root_helper)
+
+    def test_iproute2_vxlan_support_runs(self):
+        checks.iproute2_vxlan_supported(self.root_helper)
 
     def test_ovs_patch_support_runs(self):
         checks.patch_supported(self.root_helper)
index 1a2bbc4d2e408e42e94db8b32f2a249151225b3e..09a5d78cf85c090478e9a95fbfd463959079a6dd 100644 (file)
@@ -829,11 +829,9 @@ class TestLinuxBridgeManager(base.BaseTestCase):
             self.lbm.delete_vlan("eth1.1")
             self.assertTrue(exec_fn.called)
 
-    def _check_vxlan_support(self, expected, vxlan_module_supported,
-                             vxlan_ucast_supported, vxlan_mcast_supported):
+    def _check_vxlan_support(self, expected, vxlan_ucast_supported,
+                             vxlan_mcast_supported):
         with contextlib.nested(
-            mock.patch.object(self.lbm, 'vxlan_module_supported',
-                              return_value=vxlan_module_supported),
             mock.patch.object(self.lbm, 'vxlan_ucast_supported',
                               return_value=vxlan_ucast_supported),
             mock.patch.object(self.lbm, 'vxlan_mcast_supported',
@@ -848,37 +846,19 @@ class TestLinuxBridgeManager(base.BaseTestCase):
 
     def test_check_vxlan_support(self):
         self._check_vxlan_support(expected=lconst.VXLAN_UCAST,
-                                  vxlan_module_supported=True,
                                   vxlan_ucast_supported=True,
                                   vxlan_mcast_supported=True)
         self._check_vxlan_support(expected=lconst.VXLAN_MCAST,
-                                  vxlan_module_supported=True,
                                   vxlan_ucast_supported=False,
                                   vxlan_mcast_supported=True)
 
         self._check_vxlan_support(expected=lconst.VXLAN_NONE,
-                                  vxlan_module_supported=False,
                                   vxlan_ucast_supported=False,
                                   vxlan_mcast_supported=False)
         self._check_vxlan_support(expected=lconst.VXLAN_NONE,
-                                  vxlan_module_supported=True,
                                   vxlan_ucast_supported=False,
                                   vxlan_mcast_supported=False)
 
-    def _check_vxlan_module_supported(self, expected, execute_side_effect):
-        with mock.patch.object(
-                utils, 'execute',
-                side_effect=execute_side_effect):
-            self.assertEqual(expected, self.lbm.vxlan_module_supported())
-
-    def test_vxlan_module_supported(self):
-        self._check_vxlan_module_supported(
-            expected=True,
-            execute_side_effect=None)
-        self._check_vxlan_module_supported(
-            expected=False,
-            execute_side_effect=RuntimeError())
-
     def _check_vxlan_ucast_supported(
             self, expected, l2_population, iproute_arg_supported, fdb_append):
         cfg.CONF.set_override('l2_population', l2_population, 'VXLAN')