Merge lp:~james-page/charms/trusty/neutron-openvswitch/lp1515008-stable into lp:~openstack-charmers-archive/charms/trusty/neutron-openvswitch/trunk

Proposed by James Page
Status: Merged
Merged at revision: 73
Proposed branch: lp:~james-page/charms/trusty/neutron-openvswitch/lp1515008-stable
Merge into: lp:~openstack-charmers-archive/charms/trusty/neutron-openvswitch/trunk
Diff against target: 131 lines (+63/-13)
3 files modified
hooks/neutron_ovs_hooks.py (+10/-1)
hooks/neutron_ovs_utils.py (+3/-1)
unit_tests/test_neutron_ovs_hooks.py (+50/-11)
To merge this branch: bzr merge lp:~james-page/charms/trusty/neutron-openvswitch/lp1515008-stable
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+277337@code.launchpad.net

Description of the change

Fixup handling of dvr and local dhcp configurations

To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #13483 neutron-openvswitch for james-page mp277337
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/13483/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #12614 neutron-openvswitch for james-page mp277337
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/12614/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #7844 neutron-openvswitch for james-page mp277337
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/7844/

Revision history for this message
Liam Young (gnuoy) wrote :

Approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/neutron_ovs_hooks.py'
2--- hooks/neutron_ovs_hooks.py 2015-10-22 13:22:05 +0000
3+++ hooks/neutron_ovs_hooks.py 2015-11-12 11:46:32 +0000
4@@ -2,6 +2,8 @@
5
6 import sys
7
8+from copy import deepcopy
9+
10 from charmhelpers.contrib.openstack.utils import (
11 config_value_changed,
12 git_install_requested,
13@@ -28,6 +30,7 @@
14 from neutron_ovs_utils import (
15 DHCP_PACKAGES,
16 DVR_PACKAGES,
17+ METADATA_PACKAGES,
18 configure_ovs,
19 git_install,
20 get_topics,
21@@ -89,7 +92,13 @@
22 if enable_local_dhcp():
23 install_packages()
24 else:
25- purge_packages(DHCP_PACKAGES)
26+ pkgs = deepcopy(DHCP_PACKAGES)
27+ # NOTE: only purge metadata packages if dvr is not
28+ # in use as this will remove the l3 agent
29+ # see https://pad.lv/1515008
30+ if not use_dvr():
31+ pkgs.extend(METADATA_PACKAGES)
32+ purge_packages(pkgs)
33 secret = get_shared_secret() if enable_nova_metadata() else None
34 rel_data = {
35 'metadata-shared-secret': secret,
36
37=== modified file 'hooks/neutron_ovs_utils.py'
38--- hooks/neutron_ovs_utils.py 2015-10-22 13:22:05 +0000
39+++ hooks/neutron_ovs_utils.py 2015-11-12 11:46:32 +0000
40@@ -97,7 +97,8 @@
41 EXT_PORT_CONF = '/etc/init/ext-port.conf'
42 NEUTRON_METADATA_AGENT_CONF = "/etc/neutron/metadata_agent.ini"
43 DVR_PACKAGES = ['neutron-l3-agent']
44-DHCP_PACKAGES = ['neutron-metadata-agent', 'neutron-dhcp-agent']
45+DHCP_PACKAGES = ['neutron-dhcp-agent']
46+METADATA_PACKAGES = ['neutron-metadata-agent']
47 PHY_NIC_MTU_CONF = '/etc/init/os-charm-phy-nic-mtu.conf'
48 TEMPLATES = 'templates/'
49
50@@ -183,6 +184,7 @@
51 pkgs.extend(DVR_PACKAGES)
52 if enable_local_dhcp():
53 pkgs.extend(DHCP_PACKAGES)
54+ pkgs.extend(METADATA_PACKAGES)
55
56 if git_install_requested():
57 pkgs.extend(BASE_GIT_PACKAGES)
58
59=== modified file 'unit_tests/test_neutron_ovs_hooks.py'
60--- unit_tests/test_neutron_ovs_hooks.py 2015-10-22 13:22:05 +0000
61+++ unit_tests/test_neutron_ovs_hooks.py 2015-11-12 11:46:32 +0000
62@@ -140,19 +140,58 @@
63 self.purge_packages.assert_called_with(['neutron-l3-agent'])
64
65 @patch.object(hooks, 'git_install_requested')
66- def test_neutron_plugin_joined(self, git_requested):
67+ def test_neutron_plugin_joined_dvr_dhcp(self, git_requested):
68 self.enable_nova_metadata.return_value = True
69 self.enable_local_dhcp.return_value = True
70- git_requested.return_value = False
71- self.get_shared_secret.return_value = 'secret'
72- self._call_hook('neutron-plugin-relation-joined')
73- rel_data = {
74- 'metadata-shared-secret': 'secret',
75- }
76- self.relation_set.assert_called_with(
77- relation_id=None,
78- **rel_data
79- )
80+ self.use_dvr.return_value = True
81+ git_requested.return_value = False
82+ self.get_shared_secret.return_value = 'secret'
83+ self._call_hook('neutron-plugin-relation-joined')
84+ rel_data = {
85+ 'metadata-shared-secret': 'secret',
86+ }
87+ self.relation_set.assert_called_with(
88+ relation_id=None,
89+ **rel_data
90+ )
91+ self.assertTrue(self.install_packages.called)
92+
93+ @patch.object(hooks, 'git_install_requested')
94+ def test_neutron_plugin_joined_dvr_nodhcp(self, git_requested):
95+ self.enable_nova_metadata.return_value = True
96+ self.enable_local_dhcp.return_value = False
97+ self.use_dvr.return_value = True
98+ git_requested.return_value = False
99+ self.get_shared_secret.return_value = 'secret'
100+ self._call_hook('neutron-plugin-relation-joined')
101+ rel_data = {
102+ 'metadata-shared-secret': 'secret',
103+ }
104+ self.relation_set.assert_called_with(
105+ relation_id=None,
106+ **rel_data
107+ )
108+ self.purge_packages.assert_called_with(['neutron-dhcp-agent'])
109+ self.assertFalse(self.install_packages.called)
110+
111+ @patch.object(hooks, 'git_install_requested')
112+ def test_neutron_plugin_joined_nodvr_nodhcp(self, git_requested):
113+ self.enable_nova_metadata.return_value = False
114+ self.enable_local_dhcp.return_value = False
115+ self.use_dvr.return_value = False
116+ git_requested.return_value = False
117+ self.get_shared_secret.return_value = 'secret'
118+ self._call_hook('neutron-plugin-relation-joined')
119+ rel_data = {
120+ 'metadata-shared-secret': None,
121+ }
122+ self.relation_set.assert_called_with(
123+ relation_id=None,
124+ **rel_data
125+ )
126+ self.purge_packages.assert_called_with(['neutron-dhcp-agent',
127+ 'neutron-metadata-agent'])
128+ self.assertFalse(self.install_packages.called)
129
130 def test_amqp_joined(self):
131 self._call_hook('amqp-relation-joined')

Subscribers

People subscribed via source and target branches