From b404c18a506c4dcb0967b85cbafb0d238bc3f773 Mon Sep 17 00:00:00 2001 From: David Ames Date: Fri, 16 Nov 2018 08:55:26 -0800 Subject: [PATCH] Explicitly install dependencies for DVR The DVR package neutron-l3-agent depends on python-neutron-fwaas or python3-neutron-fwaas. On Rocky without being explicit it will incorrectly install the python2 version which in turn installs many python2 dependencies. This change explicitly adds python3-neutron-fwaas as a dependency on Rocky and updates python-neutron-fwaas as a purge package. Change-Id: Idb537df84b044e8ea92527a5f56ab06a37b9ffad Closes-Bug: #1803744 --- hooks/neutron_ovs_utils.py | 4 ++++ unit_tests/test_neutron_ovs_utils.py | 34 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/hooks/neutron_ovs_utils.py b/hooks/neutron_ovs_utils.py index 24113a61..db58eb47 100644 --- a/hooks/neutron_ovs_utils.py +++ b/hooks/neutron_ovs_utils.py @@ -116,6 +116,7 @@ PY3_PACKAGES = [ PURGE_PACKAGES = [ 'python-neutron', + 'python-neutron-fwaas', ] PHY_NIC_MTU_CONF = '/etc/init/os-charm-phy-nic-mtu.conf' @@ -268,11 +269,13 @@ def purge_packages(pkg_list): def determine_packages(): pkgs = [] + py3_pkgs = [] plugin_pkgs = neutron_plugin_attribute('ovs', 'packages', 'neutron') for plugin_pkg in plugin_pkgs: pkgs.extend(plugin_pkg) if use_dvr(): pkgs.extend(DVR_PACKAGES) + py3_pkgs.append('python3-neutron-fwaas') if enable_local_dhcp(): pkgs.extend(DHCP_PACKAGES) pkgs.extend(METADATA_PACKAGES) @@ -296,6 +299,7 @@ def determine_packages(): if cmp_release >= 'rocky': pkgs = [p for p in pkgs if not p.startswith('python-')] pkgs.extend(PY3_PACKAGES) + pkgs.extend(py3_pkgs) return pkgs diff --git a/unit_tests/test_neutron_ovs_utils.py b/unit_tests/test_neutron_ovs_utils.py index 03e45328..1ffd9549 100644 --- a/unit_tests/test_neutron_ovs_utils.py +++ b/unit_tests/test_neutron_ovs_utils.py @@ -185,6 +185,40 @@ class TestNeutronOVSUtils(CharmTestCase): ] self.assertEqual(pkg_list, expect) + @patch.object(nutils, 'use_dvr') + @patch.object(charmhelpers.contrib.openstack.neutron, 'os_release') + @patch.object(charmhelpers.contrib.openstack.neutron, 'headers_package') + def test_determine_packages_dvr(self, _head_pkgs, _os_rel, _use_dvr): + _use_dvr.return_value = True + _os_rel.return_value = 'icehouse' + self.os_release.return_value = 'icehouse' + _head_pkgs.return_value = head_pkg + pkg_list = nutils.determine_packages() + expect = [ + head_pkg, + 'neutron-plugin-openvswitch-agent', + 'neutron-l3-agent', + ] + self.assertEqual(pkg_list, expect) + + @patch.object(nutils, 'use_dvr') + @patch.object(charmhelpers.contrib.openstack.neutron, 'os_release') + @patch.object(charmhelpers.contrib.openstack.neutron, 'headers_package') + def test_determine_packages_dvr_rocky(self, _head_pkgs, _os_rel, _use_dvr): + _use_dvr.return_value = True + _os_rel.return_value = 'rocky' + self.os_release.return_value = 'rocky' + _head_pkgs.return_value = head_pkg + pkg_list = nutils.determine_packages() + expect = [ + head_pkg, + 'neutron-l3-agent', + 'neutron-openvswitch-agent', + 'python3-neutron', + 'python3-neutron-fwaas', + ] + self.assertEqual(pkg_list, expect) + @patch.object(nutils, 'use_dvr') @patch.object(charmhelpers.contrib.openstack.neutron, 'os_release') @patch.object(charmhelpers.contrib.openstack.neutron, 'headers_package')