Merge lp:~gandelman-a/charms/precise/quantum-gateway/headers_fix into lp:~openstack-charmers/charms/precise/quantum-gateway/python-redux

Proposed by Adam Gandelman
Status: Merged
Merged at revision: 63
Proposed branch: lp:~gandelman-a/charms/precise/quantum-gateway/headers_fix
Merge into: lp:~openstack-charmers/charms/precise/quantum-gateway/python-redux
Diff against target: 181 lines (+49/-11)
3 files modified
hooks/charmhelpers/contrib/openstack/neutron.py (+15/-6)
hooks/quantum_utils.py (+13/-2)
unit_tests/test_quantum_utils.py (+21/-3)
To merge this branch: bzr merge lp:~gandelman-a/charms/precise/quantum-gateway/headers_fix
Reviewer Review Type Date Requested Status
James Page Approve
Review via email: mp+190844@code.launchpad.net

Description of the change

Minor fixes that fix some issues I had running /w curtin installer.

* Installs the running kernel's headers package along with any DKMS package.

* Ensures the openvswitch-switch service is running prior to doing any OVS configuration. This was failing to start for reasons unrelated to the charm, but rather than the hook error'ing it just spins indefinitely waiting for a socket connection. At least try to start the service and catch any errors there before attempting config, to produce a noticeable hook error.

To post a comment you must log in.
Revision history for this message
James Page (james-page) wrote :

I think this generally looks OK; I have a concern as to why you are getting a running system without the associated kernel-headers; I've never hit this to-date so this might be covering up an bug in curtin.

I guess its also possible that the running kernels headers are no longer in the -updates pocket; but that is unlikely.

This reminds me that we need to update the force-restart helper for ovs to deal with the version in Saucy and Havana CA to use the new upstart configuration.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/charmhelpers/contrib/openstack/neutron.py'
--- hooks/charmhelpers/contrib/openstack/neutron.py 2013-09-25 16:37:11 +0000
+++ hooks/charmhelpers/contrib/openstack/neutron.py 2013-10-13 22:56:13 +0000
@@ -1,5 +1,7 @@
1# Various utilies for dealing with Neutron and the renaming from Quantum.1# Various utilies for dealing with Neutron and the renaming from Quantum.
22
3from subprocess import check_output
4
3from charmhelpers.core.hookenv import (5from charmhelpers.core.hookenv import (
4 config,6 config,
5 log,7 log,
@@ -9,6 +11,13 @@
9from charmhelpers.contrib.openstack.utils import os_release11from charmhelpers.contrib.openstack.utils import os_release
1012
1113
14def headers_package():
15 """Ensures correct linux-headers for running kernel are installed,
16 for building DKMS package"""
17 kver = check_output(['uname', '-r']).strip()
18 return 'linux-headers-%s' % kver
19
20
12# legacy21# legacy
13def quantum_plugins():22def quantum_plugins():
14 from charmhelpers.contrib.openstack import context23 from charmhelpers.contrib.openstack import context
@@ -23,15 +32,15 @@
23 database=config('neutron-database'),32 database=config('neutron-database'),
24 relation_prefix='neutron')],33 relation_prefix='neutron')],
25 'services': ['quantum-plugin-openvswitch-agent'],34 'services': ['quantum-plugin-openvswitch-agent'],
26 'packages': ['quantum-plugin-openvswitch-agent',35 'packages': [['openvswitch-datapath-dkms', headers_package()],
27 'openvswitch-datapath-dkms'],36 ['quantum-plugin-openvswitch-agent']],
28 },37 },
29 'nvp': {38 'nvp': {
30 'config': '/etc/quantum/plugins/nicira/nvp.ini',39 'config': '/etc/quantum/plugins/nicira/nvp.ini',
31 'driver': 'quantum.plugins.nicira.nicira_nvp_plugin.'40 'driver': 'quantum.plugins.nicira.nicira_nvp_plugin.'
32 'QuantumPlugin.NvpPluginV2',41 'QuantumPlugin.NvpPluginV2',
33 'services': [],42 'services': [],
34 'packages': ['quantum-plugin-nicira'],43 'packages': [],
35 }44 }
36 }45 }
3746
@@ -49,15 +58,15 @@
49 database=config('neutron-database'),58 database=config('neutron-database'),
50 relation_prefix='neutron')],59 relation_prefix='neutron')],
51 'services': ['neutron-plugin-openvswitch-agent'],60 'services': ['neutron-plugin-openvswitch-agent'],
52 'packages': ['neutron-plugin-openvswitch-agent',61 'packages': [['openvswitch-datapath-dkms', headers_package()],
53 'openvswitch-datapath-dkms'],62 ['quantum-plugin-openvswitch-agent']],
54 },63 },
55 'nvp': {64 'nvp': {
56 'config': '/etc/neutron/plugins/nicira/nvp.ini',65 'config': '/etc/neutron/plugins/nicira/nvp.ini',
57 'driver': 'neutron.plugins.nicira.nicira_nvp_plugin.'66 'driver': 'neutron.plugins.nicira.nicira_nvp_plugin.'
58 'NeutronPlugin.NvpPluginV2',67 'NeutronPlugin.NvpPluginV2',
59 'services': [],68 'services': [],
60 'packages': ['neutron-plugin-nicira'],69 'packages': [],
61 }70 }
62 }71 }
6372
6473
=== modified file 'hooks/quantum_utils.py'
--- hooks/quantum_utils.py 2013-09-04 11:56:18 +0000
+++ hooks/quantum_utils.py 2013-10-13 22:56:13 +0000
@@ -1,3 +1,4 @@
1from charmhelpers.core.host import service_running
1from charmhelpers.core.hookenv import (2from charmhelpers.core.hookenv import (
2 log,3 log,
3 config,4 config,
@@ -8,15 +9,18 @@
8)9)
9from charmhelpers.contrib.network.ovs import (10from charmhelpers.contrib.network.ovs import (
10 add_bridge,11 add_bridge,
11 add_bridge_port12 add_bridge_port,
13 full_restart,
12)14)
13from charmhelpers.contrib.openstack.utils import (15from charmhelpers.contrib.openstack.utils import (
14 configure_installation_source,16 configure_installation_source,
15 get_os_codename_install_source,17 get_os_codename_install_source,
16 get_os_codename_package18 get_os_codename_package
17)19)
20
18import charmhelpers.contrib.openstack.context as context21import charmhelpers.contrib.openstack.context as context
19import charmhelpers.contrib.openstack.templating as templating22import charmhelpers.contrib.openstack.templating as templating
23from charmhelpers.contrib.openstack.neutron import headers_package
20from quantum_contexts import (24from quantum_contexts import (
21 CORE_PLUGIN, OVS, NVP,25 CORE_PLUGIN, OVS, NVP,
22 NEUTRON, QUANTUM,26 NEUTRON, QUANTUM,
@@ -97,10 +101,15 @@
97def get_early_packages():101def get_early_packages():
98 '''Return a list of package for pre-install based on configured plugin'''102 '''Return a list of package for pre-install based on configured plugin'''
99 if config('plugin') in EARLY_PACKAGES:103 if config('plugin') in EARLY_PACKAGES:
100 return EARLY_PACKAGES[config('plugin')]104 pkgs = EARLY_PACKAGES[config('plugin')]
101 else:105 else:
102 return []106 return []
103107
108 # ensure headers are installed build any required dkms packages
109 if [p for p in pkgs if 'dkms' in p]:
110 return pkgs + [headers_package()]
111 return pkgs
112
104113
105def get_packages():114def get_packages():
106 '''Return a list of packages for install based on the configured plugin'''115 '''Return a list of packages for install based on the configured plugin'''
@@ -384,6 +393,8 @@
384393
385394
386def configure_ovs():395def configure_ovs():
396 if not service_running('openvswitch-switch'):
397 full_restart()
387 if config('plugin') == OVS:398 if config('plugin') == OVS:
388 add_bridge(INT_BRIDGE)399 add_bridge(INT_BRIDGE)
389 add_bridge(EXT_BRIDGE)400 add_bridge(EXT_BRIDGE)
390401
=== modified file 'unit_tests/test_quantum_utils.py'
--- unit_tests/test_quantum_utils.py 2013-09-04 10:57:52 +0000
+++ unit_tests/test_quantum_utils.py 2013-10-13 22:56:13 +0000
@@ -1,6 +1,9 @@
1from mock import MagicMock, call1from mock import MagicMock, call
2
2import charmhelpers.contrib.openstack.templating as templating3import charmhelpers.contrib.openstack.templating as templating
4
3templating.OSConfigRenderer = MagicMock()5templating.OSConfigRenderer = MagicMock()
6
4import quantum_utils7import quantum_utils
58
6from test_utils import (9from test_utils import (
@@ -19,7 +22,10 @@
19 'log',22 'log',
20 'add_bridge',23 'add_bridge',
21 'add_bridge_port',24 'add_bridge_port',
22 'networking_name'25 'networking_name',
26 'headers_package',
27 'full_restart',
28 'service_running',
23]29]
2430
2531
@@ -27,6 +33,7 @@
27 def setUp(self):33 def setUp(self):
28 super(TestQuantumUtils, self).setUp(quantum_utils, TO_PATCH)34 super(TestQuantumUtils, self).setUp(quantum_utils, TO_PATCH)
29 self.networking_name.return_value = 'neutron'35 self.networking_name.return_value = 'neutron'
36 self.headers_package.return_value = 'linux-headers-2.6.18'
3037
31 def tearDown(self):38 def tearDown(self):
32 # Reset cached cache39 # Reset cached cache
@@ -44,8 +51,9 @@
4451
45 def test_get_early_packages_ovs(self):52 def test_get_early_packages_ovs(self):
46 self.config.return_value = 'ovs'53 self.config.return_value = 'ovs'
47 self.assertEquals(quantum_utils.get_early_packages(),54 self.assertEquals(
48 ['openvswitch-datapath-dkms'])55 quantum_utils.get_early_packages(),
56 ['openvswitch-datapath-dkms', 'linux-headers-2.6.18'])
4957
50 def test_get_early_packages_nvp(self):58 def test_get_early_packages_nvp(self):
51 self.config.return_value = 'nvp'59 self.config.return_value = 'nvp'
@@ -56,6 +64,16 @@
56 self.config.return_value = 'ovs'64 self.config.return_value = 'ovs'
57 self.assertNotEqual(quantum_utils.get_packages(), [])65 self.assertNotEqual(quantum_utils.get_packages(), [])
5866
67 def test_configure_ovs_starts_service_if_required(self):
68 self.service_running.return_value = False
69 quantum_utils.configure_ovs()
70 self.assertTrue(self.full_restart.called)
71
72 def test_configure_ovs_doesnt_restart_service(self):
73 self.service_running.return_value = True
74 quantum_utils.configure_ovs()
75 self.assertFalse(self.full_restart.called)
76
59 def test_configure_ovs_ovs_ext_port(self):77 def test_configure_ovs_ovs_ext_port(self):
60 self.config.side_effect = self.test_config.get78 self.config.side_effect = self.test_config.get
61 self.test_config.set('plugin', 'ovs')79 self.test_config.set('plugin', 'ovs')

Subscribers

People subscribed via source and target branches