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
This commit is contained in:
Cedric Brandily 2014-06-04 13:44:18 +02:00
parent ab4dc5261e
commit dc9704255d
3 changed files with 31 additions and 0 deletions

View 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

View 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():

View 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)