From c292db34e96903925fe3bf835eb731869a4da599 Mon Sep 17 00:00:00 2001 From: Kyle Mestery Date: Thu, 27 Jun 2013 11:28:51 +0000 Subject: [PATCH] Deprecate enable_tunneling in the OVS agent This patch properly deprecates the 'enable_tunneling' option in the OVS agent. It does this be ignoring it if 'tunnel_types' is set, and if 'enable_tunneling' is set, it defaults 'tunnel_types' to only GRE. Fixes bug 1195374 Change-Id: I27fe6b930541a514fc51d3a6669347e52db8cb46 --- .../plugins/openvswitch/ovs_quantum_plugin.ini | 4 ++++ .../openvswitch/agent/ovs_quantum_agent.py | 4 ++++ .../unit/openvswitch/test_ovs_quantum_agent.py | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini b/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini index b18da65a094..1660a7b34ac 100644 --- a/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini +++ b/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini @@ -26,6 +26,10 @@ # for GRE or VXLAN networks. Requires kernel support for OVS patch ports and # GRE or VXLAN tunneling. # +# WARNING: This option will be deprecated in the Icehouse release, and will +# be replaced by specifying one or more 'tunnel_types' in the +# "agent" section of the configuration file below. +# # enable_tunneling = False # (ListOpt) Comma-separated list of : tuples diff --git a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py index 05750e44576..377b4440889 100644 --- a/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py +++ b/quantum/plugins/openvswitch/agent/ovs_quantum_agent.py @@ -810,6 +810,10 @@ def create_agent_config_map(config): tunnel_type=config.AGENT.tunnel_type, ) + # If enable_tunneling is TRUE, set tunnel_type to default to GRE + if config.OVS.enable_tunneling and not kwargs['tunnel_type']: + kwargs['tunnel_type'] = constants.TYPE_GRE + if kwargs['tunnel_type'] in constants.TUNNEL_NETWORK_TYPES: if not kwargs['local_ip']: msg = _('Tunneling cannot be enabled without a valid local_ip.') diff --git a/quantum/tests/unit/openvswitch/test_ovs_quantum_agent.py b/quantum/tests/unit/openvswitch/test_ovs_quantum_agent.py index 938794476ed..6d1a995ba7c 100644 --- a/quantum/tests/unit/openvswitch/test_ovs_quantum_agent.py +++ b/quantum/tests/unit/openvswitch/test_ovs_quantum_agent.py @@ -39,10 +39,26 @@ class CreateAgentConfigMap(base.BaseTestCase): self.assertTrue(ovs_quantum_agent.create_agent_config_map(cfg.CONF)) def test_create_agent_config_map_fails_for_invalid_tunnel_config(self): + self.addCleanup(cfg.CONF.reset) + # An ip address is required for tunneling but there is no default + cfg.CONF.set_override('tunnel_type', constants.TYPE_GRE, + group='AGENT') + with testtools.ExpectedException(ValueError): + ovs_quantum_agent.create_agent_config_map(cfg.CONF) + + def test_create_agent_config_map_enable_tunneling(self): + self.addCleanup(cfg.CONF.reset) + # Verify setting only enable_tunneling will default tunnel_type to GRE + cfg.CONF.set_override('tunnel_type', None, group='AGENT') + cfg.CONF.set_override('enable_tunneling', True, group='OVS') + cfg.CONF.set_override('local_ip', '10.10.10.10', group='OVS') + cfgmap = ovs_quantum_agent.create_agent_config_map(cfg.CONF) + self.assertEqual(cfgmap['tunnel_type'], constants.TYPE_GRE) + + def test_create_agent_config_map_fails_no_local_ip(self): self.addCleanup(cfg.CONF.reset) # An ip address is required for tunneling but there is no default cfg.CONF.set_override('enable_tunneling', True, group='OVS') - cfg.CONF.set_override('tunnel_type', 'gre', group='AGENT') with testtools.ExpectedException(ValueError): ovs_quantum_agent.create_agent_config_map(cfg.CONF)