From 0fb65a38b966649bc60359daa3fabd0639e5af2f Mon Sep 17 00:00:00 2001 From: Adam Gandelman Date: Fri, 11 Oct 2013 14:46:05 -0700 Subject: [PATCH] Also update local package determination to include headers. --- hooks/quantum_utils.py | 9 ++++++++- unit_tests/test_quantum_utils.py | 12 +++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/hooks/quantum_utils.py b/hooks/quantum_utils.py index 007f7826..bedb9992 100644 --- a/hooks/quantum_utils.py +++ b/hooks/quantum_utils.py @@ -15,8 +15,10 @@ from charmhelpers.contrib.openstack.utils import ( get_os_codename_install_source, get_os_codename_package ) + import charmhelpers.contrib.openstack.context as context import charmhelpers.contrib.openstack.templating as templating +from charmhelpers.contrib.openstack.neutron import headers_package from quantum_contexts import ( CORE_PLUGIN, OVS, NVP, NEUTRON, QUANTUM, @@ -97,10 +99,15 @@ EARLY_PACKAGES = { def get_early_packages(): '''Return a list of package for pre-install based on configured plugin''' if config('plugin') in EARLY_PACKAGES: - return EARLY_PACKAGES[config('plugin')] + pkgs = EARLY_PACKAGES[config('plugin')] else: return [] + # ensure headers are installed build any required dkms packages + if [p for p in pkgs if 'dkms' in p]: + return pkgs + [headers_package()] + return pkgs + def get_packages(): '''Return a list of packages for install based on the configured plugin''' diff --git a/unit_tests/test_quantum_utils.py b/unit_tests/test_quantum_utils.py index 4fa11aff..fb1a21d9 100644 --- a/unit_tests/test_quantum_utils.py +++ b/unit_tests/test_quantum_utils.py @@ -1,6 +1,9 @@ from mock import MagicMock, call + import charmhelpers.contrib.openstack.templating as templating + templating.OSConfigRenderer = MagicMock() + import quantum_utils from test_utils import ( @@ -19,7 +22,8 @@ TO_PATCH = [ 'log', 'add_bridge', 'add_bridge_port', - 'networking_name' + 'networking_name', + 'headers_package', ] @@ -27,6 +31,7 @@ class TestQuantumUtils(CharmTestCase): def setUp(self): super(TestQuantumUtils, self).setUp(quantum_utils, TO_PATCH) self.networking_name.return_value = 'neutron' + self.headers_package.return_value = 'linux-headers-2.6.18' def tearDown(self): # Reset cached cache @@ -44,8 +49,9 @@ class TestQuantumUtils(CharmTestCase): def test_get_early_packages_ovs(self): self.config.return_value = 'ovs' - self.assertEquals(quantum_utils.get_early_packages(), - ['openvswitch-datapath-dkms']) + self.assertEquals( + quantum_utils.get_early_packages(), + ['openvswitch-datapath-dkms', 'linux-headers-2.6.18']) def test_get_early_packages_nvp(self): self.config.return_value = 'nvp'