Merge lp:~gnuoy/charms/trusty/nova-compute/legacy_mode into lp:~openstack-charmers-archive/charms/trusty/nova-compute/next

Proposed by Liam Young
Status: Merged
Merged at revision: 114
Proposed branch: lp:~gnuoy/charms/trusty/nova-compute/legacy_mode
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-compute/next
Diff against target: 201 lines (+92/-14)
5 files modified
config.yaml (+8/-0)
hooks/nova_compute_hooks.py (+5/-5)
hooks/nova_compute_utils.py (+16/-2)
unit_tests/test_nova_compute_hooks.py (+2/-2)
unit_tests/test_nova_compute_utils.py (+61/-5)
To merge this branch: bzr merge lp:~gnuoy/charms/trusty/nova-compute/legacy_mode
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+254721@code.launchpad.net
To post a comment you must log in.
112. By Liam Young <email address hidden>

Merged next in

113. By Liam Young <email address hidden>

Check neutron_plugin_legacy_mode when compiling list of packages

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2015-03-31 08:46:52 +0000
3+++ config.yaml 2015-03-31 10:52:38 +0000
4@@ -196,3 +196,11 @@
5 description: |
6 YAML formatted associative array of sysctl values, e.g.:
7 '{ kernel.pid_max : 4194303 }'
8+ manage-neutron-plugin-legacy-mode:
9+ type: boolean
10+ default: True
11+ description: |
12+ If True nova-compute will install neutron packages for the plugin
13+ stipulated by nova-cloud-controller. The option is only available for
14+ backward compatibility for deployments which do not use the neutron-api
15+ charm. Please do not enable this on new deployments.
16
17=== modified file 'hooks/nova_compute_hooks.py'
18--- hooks/nova_compute_hooks.py 2015-03-31 08:49:33 +0000
19+++ hooks/nova_compute_hooks.py 2015-03-31 10:52:38 +0000
20@@ -47,7 +47,6 @@
21 initialize_ssh_keys,
22 migration_enabled,
23 network_manager,
24- neutron_plugin,
25 do_openstack_upgrade,
26 public_ssh_key,
27 restart_map,
28@@ -58,7 +57,8 @@
29 ceph_config_file, CEPH_SECRET,
30 enable_shell, disable_shell,
31 fix_path_ownership,
32- assert_charm_supports_ipv6
33+ assert_charm_supports_ipv6,
34+ manage_ovs,
35 )
36
37 from charmhelpers.contrib.network.ip import (
38@@ -140,10 +140,10 @@
39 return
40 CONFIGS.write(NOVA_CONF)
41 # No need to write NEUTRON_CONF if neutron-plugin is managing it
42- if not relation_ids('neutron-plugin'):
43- if network_manager() == 'quantum' and neutron_plugin() == 'ovs':
44+ if manage_ovs():
45+ if network_manager() == 'quantum':
46 CONFIGS.write(QUANTUM_CONF)
47- if network_manager() == 'neutron' and neutron_plugin() == 'ovs':
48+ if network_manager() == 'neutron':
49 CONFIGS.write(NEUTRON_CONF)
50
51
52
53=== modified file 'hooks/nova_compute_utils.py'
54--- hooks/nova_compute_utils.py 2015-03-31 08:46:52 +0000
55+++ hooks/nova_compute_utils.py 2015-03-31 10:52:38 +0000
56@@ -177,7 +177,7 @@
57 if net_manager in ['neutron', 'quantum']:
58 # This stanza supports the legacy case of ovs supported within
59 # compute charm code (now moved to neutron-openvswitch subordinate)
60- if not relation_ids('neutron-plugin') and plugin == 'ovs':
61+ if manage_ovs():
62 if net_manager == 'quantum':
63 nm_rsc = QUANTUM_RESOURCES
64 if net_manager == 'neutron':
65@@ -260,7 +260,8 @@
66 if (net_manager in ['flatmanager', 'flatdhcpmanager'] and
67 config('multi-host').lower() == 'yes'):
68 packages.extend(['nova-api', 'nova-network'])
69- elif net_manager in ['quantum', 'neutron']:
70+ elif (net_manager in ['quantum', 'neutron']
71+ and neutron_plugin_legacy_mode()):
72 plugin = neutron_plugin()
73 pkg_lists = neutron_plugin_attribute(plugin, 'packages', net_manager)
74 for pkg_list in pkg_lists:
75@@ -499,3 +500,16 @@
76 def enable_nova_metadata():
77 ctxt = MetadataServiceContext()()
78 return 'metadata_shared_secret' in ctxt
79+
80+
81+def neutron_plugin_legacy_mode():
82+ # If a charm is attatched to the neutron-plugin relation then its managing
83+ # neutron
84+ if relation_ids('neutron-plugin'):
85+ return False
86+ else:
87+ return config('manage-neutron-plugin-legacy-mode')
88+
89+
90+def manage_ovs():
91+ return neutron_plugin_legacy_mode() and neutron_plugin() == 'ovs'
92
93=== modified file 'unit_tests/test_nova_compute_hooks.py'
94--- unit_tests/test_nova_compute_hooks.py 2015-03-31 08:49:33 +0000
95+++ unit_tests/test_nova_compute_hooks.py 2015-03-31 10:52:38 +0000
96@@ -42,7 +42,7 @@
97 'migration_enabled',
98 'do_openstack_upgrade',
99 'network_manager',
100- 'neutron_plugin',
101+ 'manage_ovs',
102 'public_ssh_key',
103 'register_configs',
104 'disable_shell',
105@@ -164,7 +164,6 @@
106 configs.write = MagicMock()
107 if quantum:
108 self.network_manager.return_value = 'quantum'
109- self.neutron_plugin.return_value = 'ovs'
110 hooks.amqp_changed()
111
112 @patch.object(hooks, 'CONFIGS')
113@@ -183,6 +182,7 @@
114
115 @patch.object(hooks, 'CONFIGS')
116 def test_amqp_changed_with_data_and_quantum_api(self, configs):
117+ self.manage_ovs.return_value = False
118 self.relation_ids.return_value = ['neutron-plugin:0']
119 self._amqp_test(configs, quantum=True)
120 self.assertEquals([call('/etc/nova/nova.conf')],
121
122=== modified file 'unit_tests/test_nova_compute_utils.py'
123--- unit_tests/test_nova_compute_utils.py 2015-02-25 15:02:09 +0000
124+++ unit_tests/test_nova_compute_utils.py 2015-03-31 10:52:38 +0000
125@@ -69,11 +69,30 @@
126 ex = utils.BASE_PACKAGES + OVS_PKGS_FLAT + ['nova-compute-kvm']
127 self.assertEquals(ex, result)
128
129- @patch.object(utils, 'enable_nova_metadata')
130- @patch.object(utils, 'neutron_plugin')
131- @patch.object(utils, 'network_manager')
132- def test_determine_packages_quantum_ceph(self, net_man, n_plugin, en_meta):
133- en_meta.return_value = False
134+ @patch.object(utils, 'neutron_plugin_legacy_mode')
135+ @patch.object(utils, 'enable_nova_metadata')
136+ @patch.object(utils, 'neutron_plugin')
137+ @patch.object(utils, 'network_manager')
138+ def test_determine_packages_quantum_legacy_off(self, net_man, n_plugin,
139+ en_meta, leg_mode):
140+ en_meta.return_value = False
141+ leg_mode.return_value = False
142+ self.neutron_plugin_attribute.return_value = OVS_PKGS
143+ net_man.return_value = 'quantum'
144+ n_plugin.return_value = 'ovs'
145+ self.relation_ids.return_value = []
146+ result = utils.determine_packages()
147+ ex = utils.BASE_PACKAGES + ['nova-compute-kvm']
148+ self.assertEquals(ex, result)
149+
150+ @patch.object(utils, 'neutron_plugin_legacy_mode')
151+ @patch.object(utils, 'enable_nova_metadata')
152+ @patch.object(utils, 'neutron_plugin')
153+ @patch.object(utils, 'network_manager')
154+ def test_determine_packages_quantum_ceph(self, net_man, n_plugin, en_meta,
155+ leg_mode):
156+ en_meta.return_value = False
157+ leg_mode.return_value = True
158 self.neutron_plugin_attribute.return_value = OVS_PKGS
159 net_man.return_value = 'quantum'
160 n_plugin.return_value = 'ovs'
161@@ -419,3 +438,40 @@
162 DummyContext(return_value={'metadata_shared_secret':
163 'sharedsecret'})
164 self.assertEqual(utils.enable_nova_metadata(), True)
165+
166+ def test_neutron_plugin_legacy_mode_plugin(self):
167+ self.relation_ids.return_value = ['neutron-plugin:0']
168+ self.assertFalse(utils.neutron_plugin_legacy_mode())
169+
170+ def test_neutron_plugin_legacy_mode_legacy_off(self):
171+ self.relation_ids.return_value = []
172+ self.test_config.set('manage-neutron-plugin-legacy-mode', False)
173+ self.assertFalse(utils.neutron_plugin_legacy_mode())
174+
175+ def test_neutron_plugin_legacy_mode_legacy_on(self):
176+ self.relation_ids.return_value = []
177+ self.test_config.set('manage-neutron-plugin-legacy-mode', True)
178+ self.assertTrue(utils.neutron_plugin_legacy_mode())
179+
180+ @patch.object(utils, 'neutron_plugin_legacy_mode')
181+ def test_manage_ovs_legacy_mode_legacy_off(self,
182+ _neutron_plugin_legacy_mode):
183+ _neutron_plugin_legacy_mode.return_value = False
184+ self.assertFalse(utils.manage_ovs())
185+
186+ @patch.object(utils, 'neutron_plugin')
187+ @patch.object(utils, 'neutron_plugin_legacy_mode')
188+ def test_manage_ovs_legacy_mode_legacy_on(self,
189+ _neutron_plugin_legacy_mode,
190+ _neutron_plugin):
191+ _neutron_plugin_legacy_mode.return_value = True
192+ _neutron_plugin.return_value = 'ovs'
193+ self.assertTrue(utils.manage_ovs())
194+
195+ @patch.object(utils, 'neutron_plugin')
196+ @patch.object(utils, 'neutron_plugin_legacy_mode')
197+ def test_manage_ovs_legacy_mode_not_ovs(self, _neutron_plugin_legacy_mode,
198+ _neutron_plugin):
199+ _neutron_plugin_legacy_mode.return_value = True
200+ _neutron_plugin.return_value = 'bobvs'
201+ self.assertFalse(utils.manage_ovs())

Subscribers

People subscribed via source and target branches