]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Add sanity check for OVSDB native support
authorTerry Wilson <twilson@redhat.com>
Wed, 18 Mar 2015 22:13:53 +0000 (17:13 -0500)
committerTerry Wilson <twilson@redhat.com>
Wed, 18 Mar 2015 22:52:06 +0000 (17:52 -0500)
This check has specific warnings about the need to install the
python-openvswitch package to use OVSDB native. If an unknown
Exception is thrown when doing a simple get_bridges() call, it will
also fail, logging the exception.

Partially-Implements: blueprint vsctl-to-ovsdb
Change-Id: Ibd2dac02c5a93bb391b620cc27bc46a6cdf6d817

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

index c0245bc17b51700612398027891f6d5e31a82103..5519e16d10a248e3407324cb94f7248b29508b7d 100644 (file)
@@ -17,6 +17,7 @@ import re
 
 import netaddr
 from oslo_log import log as logging
+import six
 
 from neutron.agent.linux import ip_lib
 from neutron.agent.linux import ip_link_support
@@ -152,3 +153,19 @@ def dnsmasq_version_supported():
                   "Exception: %s", e)
         return False
     return True
+
+
+def ovsdb_native_supported():
+    # Running the test should ensure we are configured for OVSDB native
+    try:
+        ovs = ovs_lib.BaseOVS()
+        ovs.get_bridges()
+        return True
+    except ImportError as ex:
+        LOG.error(_LE("Failed to import required modules. Ensure that the "
+                      "python-openvswitch package is installed. Error: %s"),
+                  ex.message)
+    except Exception as ex:
+        LOG.exception(six.text_type(ex))
+
+    return False
index 58531879a71efc05689ad165496e66b1db25ed5f..167ec8166112c2f376b1c93437a3ae8035a2815b 100644 (file)
@@ -129,6 +129,14 @@ def check_vf_management():
     return result
 
 
+def check_ovsdb_native():
+    cfg.CONF.set_override('ovsdb_interface', 'native', group='OVS')
+    result = checks.ovsdb_native_supported()
+    if not result:
+        LOG.error(_LE('Check for native OVSDB support failed.'))
+    return result
+
+
 # Define CLI opts to test specific features, with a calback for the test
 OPTS = [
     BoolOptCallback('ovs_vxlan', check_ovs_vxlan, default=False,
@@ -147,6 +155,8 @@ OPTS = [
                     help=_('Check netns permission settings')),
     BoolOptCallback('dnsmasq_version', check_dnsmasq_version,
                     help=_('Check minimal dnsmasq version')),
+    BoolOptCallback('ovsdb_native', check_ovsdb_native,
+                    help=_('Check ovsdb native interface support')),
 ]
 
 
@@ -176,6 +186,8 @@ def enable_tests_from_config():
         cfg.CONF.set_override('read_netns', True)
     if cfg.CONF.dhcp_driver == 'neutron.agent.linux.dhcp.Dnsmasq':
         cfg.CONF.set_override('dnsmasq_version', True)
+    if cfg.CONF.OVS.ovsdb_interface == 'native':
+        cfg.CONF.set_override('ovsdb_native', True)
 
 
 def all_tests_passed():
index 027b2bf26c6d1a4cddb5e8786d1e368098152bf9..570acd101d6f350bc421d9efbb54594e7cf7002d 100644 (file)
@@ -61,3 +61,6 @@ class SanityTestCaseRoot(functional_base.BaseSudoTestCase):
 
     def test_namespace_root_read_detection_runs(self):
         checks.netns_read_requires_helper()
+
+    def test_ovsdb_native_supported_runs(self):
+        checks.ovsdb_native_supported()