From 1665848c82738d7e9e4e85f483dcdcef32065cdc Mon Sep 17 00:00:00 2001 From: James Page Date: Fri, 19 Sep 2014 10:18:01 +0100 Subject: [PATCH] Deal with drop of openswan in utopic --- hooks/quantum_utils.py | 9 ++++++--- unit_tests/test_quantum_utils.py | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/hooks/quantum_utils.py b/hooks/quantum_utils.py index 57ec670e..7bc3a439 100644 --- a/hooks/quantum_utils.py +++ b/hooks/quantum_utils.py @@ -1,7 +1,8 @@ from charmhelpers.core.host import ( service_running, service_stop, - service_restart + service_restart, + lsb_release ) from charmhelpers.core.hookenv import ( log, @@ -112,7 +113,6 @@ NEUTRON_GATEWAY_PKGS = { "nova-api-metadata", "neutron-plugin-metering-agent", "neutron-lbaas-agent", - "openswan" ], NVP: [ "neutron-dhcp-agent", @@ -148,10 +148,13 @@ def get_packages(): plugin = remap_plugin(config('plugin')) packages = deepcopy(GATEWAY_PKGS[networking_name()][plugin]) if (get_os_codename_install_source(config('openstack-origin')) - >= 'icehouse' and plugin == 'ovs'): + >= 'icehouse' and plugin == 'ovs' + and lsb_release()['DISTRIB_CODENAME'] < 'utopic'): # NOTE(jamespage) neutron-vpn-agent supercedes l3-agent for icehouse + # but openswan was removed in utopic. packages.remove('neutron-l3-agent') packages.append('neutron-vpn-agent') + packages.append('openswan') return packages diff --git a/unit_tests/test_quantum_utils.py b/unit_tests/test_quantum_utils.py index 078f6a54..88697c44 100644 --- a/unit_tests/test_quantum_utils.py +++ b/unit_tests/test_quantum_utils.py @@ -43,6 +43,7 @@ TO_PATCH = [ 'service_restart', 'remap_plugin', 'is_relation_made', + 'lsb_release' ] @@ -62,6 +63,7 @@ class TestQuantumUtils(CharmTestCase): super(TestQuantumUtils, self).setUp(quantum_utils, TO_PATCH) self.networking_name.return_value = 'neutron' self.headers_package.return_value = 'linux-headers-2.6.18' + self._set_distrib_codename('trusty') def noop(value): return value @@ -71,6 +73,9 @@ class TestQuantumUtils(CharmTestCase): # Reset cached cache hookenv.cache = {} + def _set_distrib_codename(self, newcodename): + self.lsb_release.return_value = {'DISTRIB_CODENAME': newcodename} + def test_valid_plugin(self): self.config.return_value = 'ovs' self.assertTrue(quantum_utils.valid_plugin()) @@ -113,6 +118,19 @@ class TestQuantumUtils(CharmTestCase): self.assertTrue('neutron-vpn-agent' in quantum_utils.get_packages()) self.assertFalse('neutron-l3-agent' in quantum_utils.get_packages()) + def test_get_packages_ovs_juno_utopic(self): + self.config.return_value = 'ovs' + self.get_os_codename_install_source.return_value = 'juno' + self._set_distrib_codename('utopic') + self.assertFalse('neutron-vpn-agent' in quantum_utils.get_packages()) + self.assertTrue('neutron-l3-agent' in quantum_utils.get_packages()) + + def test_get_packages_ovs_juno_trusty(self): + self.config.return_value = 'ovs' + self.get_os_codename_install_source.return_value = 'juno' + self.assertTrue('neutron-vpn-agent' in quantum_utils.get_packages()) + self.assertFalse('neutron-l3-agent' in quantum_utils.get_packages()) + def test_configure_ovs_starts_service_if_required(self): self.config.return_value = 'ovs' self.service_running.return_value = False