From dc9704255d70fb56e279c108c41d29626eb6bf89 Mon Sep 17 00:00:00 2001 From: Cedric Brandily Date: Wed, 4 Jun 2014 13:44:18 +0200 Subject: [PATCH] Allow neutron-sanity-check to check OVS patch port support 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 | 10 ++++++++++ neutron/cmd/sanity_check.py | 14 ++++++++++++++ neutron/tests/functional/sanity/test_ovs_sanity.py | 7 +++++++ 3 files changed, 31 insertions(+) diff --git a/neutron/cmd/sanity/checks.py b/neutron/cmd/sanity/checks.py index 0dc05f7d39e..970351ede70 100644 --- a/neutron/cmd/sanity/checks.py +++ b/neutron/cmd/sanity/checks.py @@ -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 diff --git a/neutron/cmd/sanity_check.py b/neutron/cmd/sanity_check.py index 715d994524e..aab8d96c07f 100644 --- a/neutron/cmd/sanity_check.py +++ b/neutron/cmd/sanity_check.py @@ -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(): diff --git a/neutron/tests/functional/sanity/test_ovs_sanity.py b/neutron/tests/functional/sanity/test_ovs_sanity.py index 8195a35d9b4..fa63300fe22 100644 --- a/neutron/tests/functional/sanity/test_ovs_sanity.py +++ b/neutron/tests/functional/sanity/test_ovs_sanity.py @@ -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)