Merge lp:~gnuoy/charms/trusty/nova-compute/dvr-support into lp:~openstack-charmers-archive/charms/trusty/nova-compute/next
- Trusty Tahr (14.04)
- dvr-support
- Merge into next
Proposed by
Liam Young
Status: | Merged |
---|---|
Merged at revision: | 111 |
Proposed branch: | lp:~gnuoy/charms/trusty/nova-compute/dvr-support |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/nova-compute/next |
Diff against target: |
257 lines (+107/-4) 7 files modified
hooks/nova_compute_context.py (+13/-0) hooks/nova_compute_hooks.py (+13/-0) hooks/nova_compute_utils.py (+11/-0) templates/juno/nova.conf (+5/-0) unit_tests/test_nova_compute_contexts.py (+8/-0) unit_tests/test_nova_compute_hooks.py (+9/-0) unit_tests/test_nova_compute_utils.py (+48/-4) |
To merge this branch: | bzr merge lp:~gnuoy/charms/trusty/nova-compute/dvr-support |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenStack Charmers | Pending | ||
Review via email: mp+254423@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #2710 nova-compute-next for gnuoy mp254423
UNIT OK: passed
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'hooks/nova_compute_context.py' | |||
2 | --- hooks/nova_compute_context.py 2015-03-12 10:07:02 +0000 | |||
3 | +++ hooks/nova_compute_context.py 2015-03-27 16:21:32 +0000 | |||
4 | @@ -390,6 +390,19 @@ | |||
5 | 390 | return ctxt | 390 | return ctxt |
6 | 391 | 391 | ||
7 | 392 | 392 | ||
8 | 393 | class MetadataServiceContext(context.OSContextGenerator): | ||
9 | 394 | |||
10 | 395 | def __call__(self): | ||
11 | 396 | ctxt = {} | ||
12 | 397 | for rid in relation_ids('neutron-plugin'): | ||
13 | 398 | for unit in related_units(rid): | ||
14 | 399 | rdata = relation_get(rid=rid, unit=unit) | ||
15 | 400 | if 'metadata-shared-secret' in rdata: | ||
16 | 401 | ctxt['metadata_shared_secret'] = \ | ||
17 | 402 | rdata['metadata-shared-secret'] | ||
18 | 403 | return ctxt | ||
19 | 404 | |||
20 | 405 | |||
21 | 393 | class NeutronComputeContext(context.NeutronContext): | 406 | class NeutronComputeContext(context.NeutronContext): |
22 | 394 | interfaces = [] | 407 | interfaces = [] |
23 | 395 | 408 | ||
24 | 396 | 409 | ||
25 | === modified file 'hooks/nova_compute_hooks.py' | |||
26 | --- hooks/nova_compute_hooks.py 2015-02-24 11:33:01 +0000 | |||
27 | +++ hooks/nova_compute_hooks.py 2015-03-27 16:21:32 +0000 | |||
28 | @@ -21,6 +21,7 @@ | |||
29 | 21 | 21 | ||
30 | 22 | from charmhelpers.fetch import ( | 22 | from charmhelpers.fetch import ( |
31 | 23 | apt_install, | 23 | apt_install, |
32 | 24 | apt_purge, | ||
33 | 24 | apt_update, | 25 | apt_update, |
34 | 25 | filter_installed_packages, | 26 | filter_installed_packages, |
35 | 26 | ) | 27 | ) |
36 | @@ -324,6 +325,18 @@ | |||
37 | 324 | nrpe_setup.write() | 325 | nrpe_setup.write() |
38 | 325 | 326 | ||
39 | 326 | 327 | ||
40 | 328 | @hooks.hook('neutron-plugin-relation-changed') | ||
41 | 329 | @restart_on_change(restart_map()) | ||
42 | 330 | def neutron_plugin_changed(): | ||
43 | 331 | settings = relation_get() | ||
44 | 332 | if 'metadata-shared-secret' in settings: | ||
45 | 333 | apt_update() | ||
46 | 334 | apt_install('nova-api-metadata', fatal=True) | ||
47 | 335 | else: | ||
48 | 336 | apt_purge('nova-api-metadata', fatal=True) | ||
49 | 337 | CONFIGS.write(NOVA_CONF) | ||
50 | 338 | |||
51 | 339 | |||
52 | 327 | def main(): | 340 | def main(): |
53 | 328 | try: | 341 | try: |
54 | 329 | hooks.execute(sys.argv) | 342 | hooks.execute(sys.argv) |
55 | 330 | 343 | ||
56 | === modified file 'hooks/nova_compute_utils.py' | |||
57 | --- hooks/nova_compute_utils.py 2015-03-12 10:07:02 +0000 | |||
58 | +++ hooks/nova_compute_utils.py 2015-03-27 16:21:32 +0000 | |||
59 | @@ -39,6 +39,7 @@ | |||
60 | 39 | 39 | ||
61 | 40 | from nova_compute_context import ( | 40 | from nova_compute_context import ( |
62 | 41 | CloudComputeContext, | 41 | CloudComputeContext, |
63 | 42 | MetadataServiceContext, | ||
64 | 42 | NovaComputeLibvirtContext, | 43 | NovaComputeLibvirtContext, |
65 | 43 | NovaComputeCephContext, | 44 | NovaComputeCephContext, |
66 | 44 | NeutronComputeContext, | 45 | NeutronComputeContext, |
67 | @@ -94,6 +95,7 @@ | |||
68 | 94 | service='nova', | 95 | service='nova', |
69 | 95 | config_file=NOVA_CONF), | 96 | config_file=NOVA_CONF), |
70 | 96 | InstanceConsoleContext(), | 97 | InstanceConsoleContext(), |
71 | 98 | MetadataServiceContext(), | ||
72 | 97 | HostIPContext()], | 99 | HostIPContext()], |
73 | 98 | }, | 100 | }, |
74 | 99 | } | 101 | } |
75 | @@ -203,6 +205,8 @@ | |||
76 | 203 | } | 205 | } |
77 | 204 | resource_map.update(CEPH_RESOURCES) | 206 | resource_map.update(CEPH_RESOURCES) |
78 | 205 | 207 | ||
79 | 208 | if enable_nova_metadata(): | ||
80 | 209 | resource_map[NOVA_CONF]['services'].append('nova-api-metadata') | ||
81 | 206 | return resource_map | 210 | return resource_map |
82 | 207 | 211 | ||
83 | 208 | 212 | ||
84 | @@ -271,6 +275,8 @@ | |||
85 | 271 | except KeyError: | 275 | except KeyError: |
86 | 272 | log('Unsupported virt-type configured: %s' % virt_type) | 276 | log('Unsupported virt-type configured: %s' % virt_type) |
87 | 273 | raise | 277 | raise |
88 | 278 | if enable_nova_metadata(): | ||
89 | 279 | packages.append('nova-api-metadata') | ||
90 | 274 | 280 | ||
91 | 275 | return packages | 281 | return packages |
92 | 276 | 282 | ||
93 | @@ -488,3 +494,8 @@ | |||
94 | 488 | if lsb_release()['DISTRIB_CODENAME'].lower() < "trusty": | 494 | if lsb_release()['DISTRIB_CODENAME'].lower() < "trusty": |
95 | 489 | raise Exception("IPv6 is not supported in the charms for Ubuntu " | 495 | raise Exception("IPv6 is not supported in the charms for Ubuntu " |
96 | 490 | "versions less than Trusty 14.04") | 496 | "versions less than Trusty 14.04") |
97 | 497 | |||
98 | 498 | |||
99 | 499 | def enable_nova_metadata(): | ||
100 | 500 | ctxt = MetadataServiceContext()() | ||
101 | 501 | return 'metadata_shared_secret' in ctxt | ||
102 | 491 | 502 | ||
103 | === modified file 'templates/juno/nova.conf' | |||
104 | --- templates/juno/nova.conf 2014-12-15 10:28:47 +0000 | |||
105 | +++ templates/juno/nova.conf 2015-03-27 16:21:32 +0000 | |||
106 | @@ -31,6 +31,11 @@ | |||
107 | 31 | glance_api_servers = {{ glance_api_servers }} | 31 | glance_api_servers = {{ glance_api_servers }} |
108 | 32 | {% endif -%} | 32 | {% endif -%} |
109 | 33 | 33 | ||
110 | 34 | {% if metadata_shared_secret -%} | ||
111 | 35 | neutron_metadata_proxy_shared_secret = {{ metadata_shared_secret }} | ||
112 | 36 | service_neutron_metadata_proxy=True | ||
113 | 37 | {% endif -%} | ||
114 | 38 | |||
115 | 34 | {% if console_vnc_type -%} | 39 | {% if console_vnc_type -%} |
116 | 35 | vnc_enabled = True | 40 | vnc_enabled = True |
117 | 36 | novnc_enabled = True | 41 | novnc_enabled = True |
118 | 37 | 42 | ||
119 | === modified file 'unit_tests/test_nova_compute_contexts.py' | |||
120 | --- unit_tests/test_nova_compute_contexts.py 2015-02-16 09:53:45 +0000 | |||
121 | +++ unit_tests/test_nova_compute_contexts.py 2015-03-27 16:21:32 +0000 | |||
122 | @@ -228,3 +228,11 @@ | |||
123 | 228 | self.assertEquals( | 228 | self.assertEquals( |
124 | 229 | {'host_ip': '172.24.0.79'}, host_ip()) | 229 | {'host_ip': '172.24.0.79'}, host_ip()) |
125 | 230 | self.unit_get.assert_called_with('private-address') | 230 | self.unit_get.assert_called_with('private-address') |
126 | 231 | |||
127 | 232 | def test_metadata_service_ctxt(self): | ||
128 | 233 | self.relation_ids.return_value = 'neutron-plugin:0' | ||
129 | 234 | self.related_units.return_value = 'neutron-openvswitch/0' | ||
130 | 235 | self.test_relation.set({'metadata-shared-secret': 'shared_secret'}) | ||
131 | 236 | metadatactxt = context.MetadataServiceContext() | ||
132 | 237 | self.assertEqual(metadatactxt(), {'metadata_shared_secret': | ||
133 | 238 | 'shared_secret'}) | ||
134 | 231 | 239 | ||
135 | === modified file 'unit_tests/test_nova_compute_hooks.py' | |||
136 | --- unit_tests/test_nova_compute_hooks.py 2015-02-09 21:30:33 +0000 | |||
137 | +++ unit_tests/test_nova_compute_hooks.py 2015-03-27 16:21:32 +0000 | |||
138 | @@ -378,3 +378,12 @@ | |||
139 | 378 | call('/etc/nova/nova.conf'), | 378 | call('/etc/nova/nova.conf'), |
140 | 379 | ] | 379 | ] |
141 | 380 | self.assertEquals(ex, configs.write.call_args_list) | 380 | self.assertEquals(ex, configs.write.call_args_list) |
142 | 381 | |||
143 | 382 | @patch.object(hooks, 'CONFIGS') | ||
144 | 383 | def test_neutron_plugin_changed(self, configs): | ||
145 | 384 | self.relation_get.return_value = {'metadata-shared-secret': | ||
146 | 385 | 'sharedsecret'} | ||
147 | 386 | hooks.neutron_plugin_changed() | ||
148 | 387 | self.assertTrue(self.apt_update.called) | ||
149 | 388 | self.apt_install.assert_called_with('nova-api-metadata', fatal=True) | ||
150 | 389 | configs.write.assert_called_with('/etc/nova/nova.conf') | ||
151 | 381 | 390 | ||
152 | === modified file 'unit_tests/test_nova_compute_utils.py' | |||
153 | --- unit_tests/test_nova_compute_utils.py 2015-02-06 18:09:18 +0000 | |||
154 | +++ unit_tests/test_nova_compute_utils.py 2015-03-27 16:21:32 +0000 | |||
155 | @@ -24,7 +24,8 @@ | |||
156 | 24 | 'relation_ids', | 24 | 'relation_ids', |
157 | 25 | 'relation_get', | 25 | 'relation_get', |
158 | 26 | 'mkdir', | 26 | 'mkdir', |
160 | 27 | 'install_alternative' | 27 | 'install_alternative', |
161 | 28 | 'MetadataServiceContext', | ||
162 | 28 | ] | 29 | ] |
163 | 29 | 30 | ||
164 | 30 | OVS_PKGS = [ | 31 | OVS_PKGS = [ |
165 | @@ -41,8 +42,10 @@ | |||
166 | 41 | super(NovaComputeUtilsTests, self).setUp(utils, TO_PATCH) | 42 | super(NovaComputeUtilsTests, self).setUp(utils, TO_PATCH) |
167 | 42 | self.config.side_effect = self.test_config.get | 43 | self.config.side_effect = self.test_config.get |
168 | 43 | 44 | ||
169 | 45 | @patch.object(utils, 'enable_nova_metadata') | ||
170 | 44 | @patch.object(utils, 'network_manager') | 46 | @patch.object(utils, 'network_manager') |
172 | 45 | def test_determine_packages_nova_network(self, net_man): | 47 | def test_determine_packages_nova_network(self, net_man, en_meta): |
173 | 48 | en_meta.return_value = False | ||
174 | 46 | net_man.return_value = 'flatdhcpmanager' | 49 | net_man.return_value = 'flatdhcpmanager' |
175 | 47 | self.relation_ids.return_value = [] | 50 | self.relation_ids.return_value = [] |
176 | 48 | result = utils.determine_packages() | 51 | result = utils.determine_packages() |
177 | @@ -53,9 +56,11 @@ | |||
178 | 53 | ] | 56 | ] |
179 | 54 | self.assertEquals(ex, result) | 57 | self.assertEquals(ex, result) |
180 | 55 | 58 | ||
181 | 59 | @patch.object(utils, 'enable_nova_metadata') | ||
182 | 56 | @patch.object(utils, 'neutron_plugin') | 60 | @patch.object(utils, 'neutron_plugin') |
183 | 57 | @patch.object(utils, 'network_manager') | 61 | @patch.object(utils, 'network_manager') |
185 | 58 | def test_determine_packages_quantum(self, net_man, n_plugin): | 62 | def test_determine_packages_quantum(self, net_man, n_plugin, en_meta): |
186 | 63 | en_meta.return_value = False | ||
187 | 59 | self.neutron_plugin_attribute.return_value = OVS_PKGS | 64 | self.neutron_plugin_attribute.return_value = OVS_PKGS |
188 | 60 | net_man.return_value = 'quantum' | 65 | net_man.return_value = 'quantum' |
189 | 61 | n_plugin.return_value = 'ovs' | 66 | n_plugin.return_value = 'ovs' |
190 | @@ -64,9 +69,11 @@ | |||
191 | 64 | ex = utils.BASE_PACKAGES + OVS_PKGS_FLAT + ['nova-compute-kvm'] | 69 | ex = utils.BASE_PACKAGES + OVS_PKGS_FLAT + ['nova-compute-kvm'] |
192 | 65 | self.assertEquals(ex, result) | 70 | self.assertEquals(ex, result) |
193 | 66 | 71 | ||
194 | 72 | @patch.object(utils, 'enable_nova_metadata') | ||
195 | 67 | @patch.object(utils, 'neutron_plugin') | 73 | @patch.object(utils, 'neutron_plugin') |
196 | 68 | @patch.object(utils, 'network_manager') | 74 | @patch.object(utils, 'network_manager') |
198 | 69 | def test_determine_packages_quantum_ceph(self, net_man, n_plugin): | 75 | def test_determine_packages_quantum_ceph(self, net_man, n_plugin, en_meta): |
199 | 76 | en_meta.return_value = False | ||
200 | 70 | self.neutron_plugin_attribute.return_value = OVS_PKGS | 77 | self.neutron_plugin_attribute.return_value = OVS_PKGS |
201 | 71 | net_man.return_value = 'quantum' | 78 | net_man.return_value = 'quantum' |
202 | 72 | n_plugin.return_value = 'ovs' | 79 | n_plugin.return_value = 'ovs' |
203 | @@ -76,6 +83,18 @@ | |||
204 | 76 | ['ceph-common', 'nova-compute-kvm']) | 83 | ['ceph-common', 'nova-compute-kvm']) |
205 | 77 | self.assertEquals(ex, result) | 84 | self.assertEquals(ex, result) |
206 | 78 | 85 | ||
207 | 86 | @patch.object(utils, 'enable_nova_metadata') | ||
208 | 87 | @patch.object(utils, 'neutron_plugin') | ||
209 | 88 | @patch.object(utils, 'network_manager') | ||
210 | 89 | def test_determine_packages_metadata(self, net_man, n_plugin, en_meta): | ||
211 | 90 | en_meta.return_value = True | ||
212 | 91 | self.neutron_plugin_attribute.return_value = OVS_PKGS | ||
213 | 92 | net_man.return_value = 'bob' | ||
214 | 93 | n_plugin.return_value = 'ovs' | ||
215 | 94 | self.relation_ids.return_value = [] | ||
216 | 95 | result = utils.determine_packages() | ||
217 | 96 | self.assertTrue('nova-api-metadata' in result) | ||
218 | 97 | |||
219 | 79 | @patch.object(utils, 'network_manager') | 98 | @patch.object(utils, 'network_manager') |
220 | 80 | def test_resource_map_nova_network_no_multihost(self, net_man): | 99 | def test_resource_map_nova_network_no_multihost(self, net_man): |
221 | 81 | self.skipTest('skipped until contexts are properly mocked') | 100 | self.skipTest('skipped until contexts are properly mocked') |
222 | @@ -172,6 +191,17 @@ | |||
223 | 172 | result = utils.resource_map() | 191 | result = utils.resource_map() |
224 | 173 | self.assertTrue('/etc/neutron/neutron.conf' not in result) | 192 | self.assertTrue('/etc/neutron/neutron.conf' not in result) |
225 | 174 | 193 | ||
226 | 194 | @patch.object(utils, 'enable_nova_metadata') | ||
227 | 195 | @patch.object(utils, 'neutron_plugin') | ||
228 | 196 | @patch.object(utils, 'network_manager') | ||
229 | 197 | def test_resource_map_metadata(self, net_man, _plugin, _metadata): | ||
230 | 198 | _metadata.return_value = True | ||
231 | 199 | net_man.return_value = 'bob' | ||
232 | 200 | _plugin.return_value = 'ovs' | ||
233 | 201 | self.relation_ids.return_value = [] | ||
234 | 202 | result = utils.resource_map()['/etc/nova/nova.conf']['services'] | ||
235 | 203 | self.assertTrue('nova-api-metadata' in result) | ||
236 | 204 | |||
237 | 175 | def fake_user(self, username='foo'): | 205 | def fake_user(self, username='foo'): |
238 | 176 | user = MagicMock() | 206 | user = MagicMock() |
239 | 177 | user.pw_dir = '/home/' + username | 207 | user.pw_dir = '/home/' + username |
240 | @@ -375,3 +405,17 @@ | |||
241 | 375 | 'secret-set-value', '--secret', | 405 | 'secret-set-value', '--secret', |
242 | 376 | compute_context.CEPH_SECRET_UUID, | 406 | compute_context.CEPH_SECRET_UUID, |
243 | 377 | '--base64', key]) | 407 | '--base64', key]) |
244 | 408 | |||
245 | 409 | def test_enable_nova_metadata(self): | ||
246 | 410 | class DummyContext(): | ||
247 | 411 | |||
248 | 412 | def __init__(self, return_value): | ||
249 | 413 | self.return_value = return_value | ||
250 | 414 | |||
251 | 415 | def __call__(self): | ||
252 | 416 | return self.return_value | ||
253 | 417 | |||
254 | 418 | self.MetadataServiceContext.return_value = \ | ||
255 | 419 | DummyContext(return_value={'metadata_shared_secret': | ||
256 | 420 | 'sharedsecret'}) | ||
257 | 421 | self.assertEqual(utils.enable_nova_metadata(), True) |
charm_lint_check #2919 nova-compute-next for gnuoy mp254423
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/2919/