From 65fcc942cb3781b7eb5d042a833c88fbea0d809d Mon Sep 17 00:00:00 2001 From: James Page Date: Wed, 6 May 2015 11:46:22 +0100 Subject: [PATCH] Expand dvr overlay network support for >= kilo --- config.yaml | 2 +- hooks/neutron_api_context.py | 21 ++++++++++++--------- unit_tests/test_neutron_api_context.py | 26 ++++++++++++++++++-------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/config.yaml b/config.yaml index 212c9ced..1cf8c620 100644 --- a/config.yaml +++ b/config.yaml @@ -87,7 +87,7 @@ options: Overlay network type to use choose one of: . gre - vxlan + vxlan . flat-network-providers: type: string diff --git a/hooks/neutron_api_context.py b/hooks/neutron_api_context.py index 1ef76218..c9ed70f1 100644 --- a/hooks/neutron_api_context.py +++ b/hooks/neutron_api_context.py @@ -14,6 +14,12 @@ from charmhelpers.contrib.openstack.utils import ( os_release, ) +VLAN = 'vlan' +VXLAN = 'vxlan' +GRE = 'gre' + +OVERLAY_NET_TYPES = [VXLAN, GRE] + def get_l2population(): plugin = config('neutron-plugin') @@ -22,7 +28,7 @@ def get_l2population(): def get_overlay_network_type(): overlay_net = config('overlay-network-type') - if overlay_net not in ['vxlan', 'gre']: + if overlay_net not in OVERLAY_NET_TYPES: raise Exception('Unsupported overlay-network-type') return overlay_net @@ -32,10 +38,6 @@ def get_l3ha(): if os_release('neutron-server') < 'juno': log('Disabling L3 HA, enable-l3ha is not valid before Juno') return False - if config('overlay-network-type') not in ['vlan', 'gre', 'vxlan']: - log('Disabling L3 HA, enable-l3ha requires the use of the vxlan, ' - 'vlan or gre overlay network') - return False if get_l2population(): log('Disabling L3 HA, l2-population must be disabled with L3 HA') return False @@ -49,10 +51,11 @@ def get_dvr(): if os_release('neutron-server') < 'juno': log('Disabling DVR, enable-dvr is not valid before Juno') return False - if config('overlay-network-type') != 'vxlan': - log('Disabling DVR, enable-dvr requires the use of the vxlan ' - 'overlay network') - return False + if os_release('neutron-server') == 'juno': + if config('overlay-network-type') != VXLAN: + log('Disabling DVR, enable-dvr requires the use of the vxlan ' + 'overlay network for OpenStack Juno') + return False if get_l3ha(): log('Disabling DVR, enable-l3ha must be disabled with dvr') return False diff --git a/unit_tests/test_neutron_api_context.py b/unit_tests/test_neutron_api_context.py index 32a1a810..03a7cb67 100644 --- a/unit_tests/test_neutron_api_context.py +++ b/unit_tests/test_neutron_api_context.py @@ -65,14 +65,6 @@ class GeneralTests(CharmTestCase): self.os_release.return_value = 'juno' self.assertEquals(context.get_l3ha(), False) - def test_get_l3ha_badoverlay(self): - self.test_config.set('enable-l3ha', True) - self.test_config.set('overlay-network-type', 'tokenring') - self.test_config.set('neutron-plugin', 'ovs') - self.test_config.set('l2-population', False) - self.os_release.return_value = 'juno' - self.assertEquals(context.get_l3ha(), False) - def test_get_dvr(self): self.test_config.set('enable-dvr', True) self.test_config.set('enable-l3ha', False) @@ -109,6 +101,24 @@ class GeneralTests(CharmTestCase): self.os_release.return_value = 'juno' self.assertEquals(context.get_dvr(), False) + def test_get_dvr_gre_kilo(self): + self.test_config.set('enable-dvr', True) + self.test_config.set('enable-l3ha', False) + self.test_config.set('overlay-network-type', 'gre') + self.test_config.set('neutron-plugin', 'ovs') + self.test_config.set('l2-population', True) + self.os_release.return_value = 'kilo' + self.assertEquals(context.get_dvr(), True) + + def test_get_dvr_vxlan_kilo(self): + self.test_config.set('enable-dvr', True) + self.test_config.set('enable-l3ha', False) + self.test_config.set('overlay-network-type', 'vxlan') + self.test_config.set('neutron-plugin', 'ovs') + self.test_config.set('l2-population', True) + self.os_release.return_value = 'kilo' + self.assertEquals(context.get_dvr(), True) + def test_get_dvr_l3ha_on(self): self.test_config.set('enable-dvr', True) self.test_config.set('enable-l3ha', True)