]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Allow neutron-sanity-check to check OVS patch port support
authorCedric Brandily <zzelle@gmail.com>
Wed, 4 Jun 2014 11:44:18 +0000 (13:44 +0200)
committerCedric Brandily <zzelle@gmail.com>
Wed, 4 Jun 2014 14:43:25 +0000 (14:43 +0000)
This patch allows to check OVS patch port support using:

  neutron-sanity-check --ovs_patch

or pass in the deployed configuration files with a non-empty
AGENT/tunnel_types (indeed patch ports are used to interconnect
br-int and br-tun):

  neutron-sanity-check --config-file ml2.conf.ini

DocImpact
Related-Bug: #1285335
Change-Id: Ic7bfabd1f4b85bfa490dd06c70eb5682ee42a681

neutron/cmd/sanity/checks.py
neutron/cmd/sanity_check.py
neutron/tests/functional/sanity/test_ovs_sanity.py

index 0dc05f7d39e93623198fc51beab77457758f8b7d..970351ede70916f9ec1348204a2c542b6159ab32 100644 (file)
@@ -26,3 +26,13 @@ def vxlan_supported(root_helper, from_ip='192.0.2.1', to_ip='192.0.2.2'):
     with ovs_lib.OVSBridge(name, root_helper) as br:
         port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_VXLAN)
         return port != ovs_const.INVALID_OFPORT
+
+
+def patch_supported(root_helper):
+    seed = utils.get_random_string(6)
+    name = "patchtest-" + seed
+    peer_name = "peertest0-" + seed
+    patch_name = "peertest1-" + seed
+    with ovs_lib.OVSBridge(name, root_helper) as br:
+        port = br.add_patch_port(patch_name, peer_name)
+        return port != ovs_const.INVALID_OFPORT
index 715d994524e61816d85e6d32b79344e181a42534..aab8d96c07f396af45624807e161dc6e313d1052 100644 (file)
@@ -42,10 +42,22 @@ def check_ovs_vxlan():
     return result
 
 
+def check_ovs_patch():
+    result = checks.patch_supported(root_helper=cfg.CONF.AGENT.root_helper)
+    if not result:
+        LOG.error(_('Check for Open vSwitch patch port support failed. '
+                    'Please ensure that the version of openvswitch '
+                    'being used has patch port support or disable features '
+                    'requiring patch ports (gre/vxlan, etc.).'))
+    return result
+
+
 # Define CLI opts to test specific features, with a calback for the test
 OPTS = [
     BoolOptCallback('ovs_vxlan', check_ovs_vxlan, default=False,
                     help=_('Check for vxlan support')),
+    BoolOptCallback('ovs_patch', check_ovs_patch, default=False,
+                    help=_('Check for patch port support')),
 ]
 
 
@@ -57,6 +69,8 @@ def enable_tests_from_config():
 
     if 'vxlan' in cfg.CONF.AGENT.tunnel_types:
         cfg.CONF.set_override('ovs_vxlan', True)
+    if cfg.CONF.AGENT.tunnel_types:
+        cfg.CONF.set_override('ovs_patch', True)
 
 
 def all_tests_passed():
index 8195a35d9b4541ff537ffcdb04636a257e2f8c6e..fa63300fe22b5ab35f82918c5d21b15eee3add78 100644 (file)
@@ -37,3 +37,10 @@ class OVSSanityTestCase(base.BaseTestCase):
         """
         self.check_sudo_enabled()
         checks.vxlan_supported(self.root_helper)
+
+    def test_ovs_patch_support_runs(self):
+        """This test just ensures that the test in neutron-sanity-check
+            can run through without error, without mocking anything out
+        """
+        self.check_sudo_enabled()
+        checks.patch_supported(self.root_helper)