From f3ee6841a7d88d23e2a80667d4b928f6abd83a32 Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Wed, 18 Mar 2015 17:13:53 -0500 Subject: [PATCH] Add sanity check for OVSDB native support 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 | 17 +++++++++++++++++ neutron/cmd/sanity_check.py | 12 ++++++++++++ neutron/tests/functional/sanity/test_sanity.py | 3 +++ 3 files changed, 32 insertions(+) diff --git a/neutron/cmd/sanity/checks.py b/neutron/cmd/sanity/checks.py index c0245bc17..5519e16d1 100644 --- a/neutron/cmd/sanity/checks.py +++ b/neutron/cmd/sanity/checks.py @@ -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 diff --git a/neutron/cmd/sanity_check.py b/neutron/cmd/sanity_check.py index 58531879a..167ec8166 100644 --- a/neutron/cmd/sanity_check.py +++ b/neutron/cmd/sanity_check.py @@ -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(): diff --git a/neutron/tests/functional/sanity/test_sanity.py b/neutron/tests/functional/sanity/test_sanity.py index 027b2bf26..570acd101 100644 --- a/neutron/tests/functional/sanity/test_sanity.py +++ b/neutron/tests/functional/sanity/test_sanity.py @@ -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() -- 2.45.2