Merge lp:~openstack-charmers/charms/trusty/neutron-api/vpp into lp:~openstack-charmers-archive/charms/trusty/neutron-api/next
- Trusty Tahr (14.04)
- vpp
- Merge into next
Status: | Merged |
---|---|
Merged at revision: | 132 |
Proposed branch: | lp:~openstack-charmers/charms/trusty/neutron-api/vpp |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/neutron-api/next |
Diff against target: |
499 lines (+305/-25) 10 files modified
config.yaml (+6/-0) hooks/neutron_api_context.py (+60/-0) hooks/neutron_api_hooks.py (+2/-1) hooks/neutron_api_utils.py (+34/-22) metadata.yaml (+3/-0) templates/icehouse/neutron.conf (+10/-0) templates/juno/neutron.conf (+6/-0) templates/kilo/neutron.conf (+10/-0) unit_tests/test_neutron_api_context.py (+133/-0) unit_tests/test_neutron_api_utils.py (+41/-2) |
To merge this branch: | bzr merge lp:~openstack-charmers/charms/trusty/neutron-api/vpp |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Page | Approve | ||
Review via email: mp+263224@code.launchpad.net |
Commit message
Description of the change
James Page (james-page) : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #7341 neutron-api-next for gnuoy mp263224
UNIT OK: passed
James Page (james-page) : | # |
- 134. By Liam Young
-
Fix kilo template ordering
- 135. By Liam Young
-
Fix lint and remove pointless comment from template
James Page (james-page) : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #5764 neutron-api-next for gnuoy mp263224
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
- 136. By Liam Young
-
Fix unit test
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #7924 neutron-api-next for gnuoy mp263224
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #7342 neutron-api-next for gnuoy mp263224
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #5765 neutron-api-next for gnuoy mp263224
AMULET FAIL: amulet-test failed
AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.
Full amulet test output: http://
Build: http://
Preview Diff
1 | === modified file 'config.yaml' | |||
2 | --- config.yaml 2015-07-10 14:14:33 +0000 | |||
3 | +++ config.yaml 2015-08-12 10:36:14 +0000 | |||
4 | @@ -368,3 +368,9 @@ | |||
5 | 368 | description: | | 368 | description: | |
6 | 369 | A comma-separated list of nagios servicegroups. | 369 | A comma-separated list of nagios servicegroups. |
7 | 370 | If left empty, the nagios_context will be used as the servicegroup | 370 | If left empty, the nagios_context will be used as the servicegroup |
8 | 371 | manage-neutron-plugin-legacy-mode: | ||
9 | 372 | type: boolean | ||
10 | 373 | default: True | ||
11 | 374 | description: | | ||
12 | 375 | If True neutron-server will install neutron packages for the plugin | ||
13 | 376 | configured. | ||
14 | 371 | 377 | ||
15 | === added symlink 'hooks/neutron-plugin-api-subordinate-relation-changed' | |||
16 | === target is u'neutron_api_hooks.py' | |||
17 | === added symlink 'hooks/neutron-plugin-api-subordinate-relation-departed' | |||
18 | === target is u'neutron_api_hooks.py' | |||
19 | === added symlink 'hooks/neutron-plugin-api-subordinate-relation-joined' | |||
20 | === target is u'neutron_api_hooks.py' | |||
21 | === modified file 'hooks/neutron_api_context.py' | |||
22 | --- hooks/neutron_api_context.py 2015-05-06 11:40:21 +0000 | |||
23 | +++ hooks/neutron_api_context.py 2015-08-12 10:36:14 +0000 | |||
24 | @@ -234,3 +234,63 @@ | |||
25 | 234 | # for haproxy.conf | 234 | # for haproxy.conf |
26 | 235 | ctxt['service_ports'] = port_mapping | 235 | ctxt['service_ports'] = port_mapping |
27 | 236 | return ctxt | 236 | return ctxt |
28 | 237 | |||
29 | 238 | |||
30 | 239 | class NeutronApiSDNContext(context.SubordinateConfigContext): | ||
31 | 240 | interfaces = 'neutron-plugin-api-subordinate' | ||
32 | 241 | |||
33 | 242 | def __init__(self): | ||
34 | 243 | super(NeutronApiSDNContext, self).__init__( | ||
35 | 244 | interface='neutron-plugin-api-subordinate', | ||
36 | 245 | service='neutron-api', | ||
37 | 246 | config_file='/etc/neutron/neutron.conf') | ||
38 | 247 | |||
39 | 248 | def __call__(self): | ||
40 | 249 | ctxt = super(NeutronApiSDNContext, self).__call__() | ||
41 | 250 | defaults = { | ||
42 | 251 | 'core-plugin': { | ||
43 | 252 | 'templ_key': 'core_plugin', | ||
44 | 253 | 'value': 'neutron.plugins.ml2.plugin.Ml2Plugin', | ||
45 | 254 | }, | ||
46 | 255 | 'neutron-plugin-config': { | ||
47 | 256 | 'templ_key': 'neutron_plugin_config', | ||
48 | 257 | 'value': '/etc/neutron/plugins/ml2/ml2_conf.ini', | ||
49 | 258 | }, | ||
50 | 259 | 'service-plugins': { | ||
51 | 260 | 'templ_key': 'service_plugins', | ||
52 | 261 | 'value': 'router,firewall,lbaas,vpnaas,metering', | ||
53 | 262 | }, | ||
54 | 263 | 'restart-trigger': { | ||
55 | 264 | 'templ_key': 'restart_trigger', | ||
56 | 265 | 'value': '', | ||
57 | 266 | }, | ||
58 | 267 | } | ||
59 | 268 | for rid in relation_ids('neutron-plugin-api-subordinate'): | ||
60 | 269 | for unit in related_units(rid): | ||
61 | 270 | rdata = relation_get(rid=rid, unit=unit) | ||
62 | 271 | plugin = rdata.get('neutron-plugin') | ||
63 | 272 | if not plugin: | ||
64 | 273 | continue | ||
65 | 274 | ctxt['neutron_plugin'] = plugin | ||
66 | 275 | for key in defaults.keys(): | ||
67 | 276 | remote_value = rdata.get(key) | ||
68 | 277 | ctxt_key = defaults[key]['templ_key'] | ||
69 | 278 | if remote_value: | ||
70 | 279 | ctxt[ctxt_key] = remote_value | ||
71 | 280 | else: | ||
72 | 281 | ctxt[ctxt_key] = defaults[key]['value'] | ||
73 | 282 | return ctxt | ||
74 | 283 | return ctxt | ||
75 | 284 | |||
76 | 285 | |||
77 | 286 | class NeutronApiSDNConfigFileContext(context.OSContextGenerator): | ||
78 | 287 | interfaces = ['neutron-plugin-api-subordinate'] | ||
79 | 288 | |||
80 | 289 | def __call__(self): | ||
81 | 290 | for rid in relation_ids('neutron-plugin-api-subordinate'): | ||
82 | 291 | for unit in related_units(rid): | ||
83 | 292 | rdata = relation_get(rid=rid, unit=unit) | ||
84 | 293 | neutron_server_plugin_conf = rdata.get('neutron-plugin-config') | ||
85 | 294 | if neutron_server_plugin_conf: | ||
86 | 295 | return {'config': neutron_server_plugin_conf} | ||
87 | 296 | return {'config': '/etc/neutron/plugins/ml2/ml2_conf.ini'} | ||
88 | 237 | 297 | ||
89 | === modified file 'hooks/neutron_api_hooks.py' | |||
90 | --- hooks/neutron_api_hooks.py 2015-04-23 08:49:03 +0000 | |||
91 | +++ hooks/neutron_api_hooks.py 2015-08-12 10:36:14 +0000 | |||
92 | @@ -479,7 +479,8 @@ | |||
93 | 479 | users="neutron") | 479 | users="neutron") |
94 | 480 | 480 | ||
95 | 481 | 481 | ||
97 | 482 | @hooks.hook('zeromq-configuration-relation-changed') | 482 | @hooks.hook('zeromq-configuration-relation-changed', |
98 | 483 | 'neutron-plugin-api-subordinate-relation-changed') | ||
99 | 483 | @restart_on_change(restart_map(), stopstart=True) | 484 | @restart_on_change(restart_map(), stopstart=True) |
100 | 484 | def zeromq_configuration_relation_changed(): | 485 | def zeromq_configuration_relation_changed(): |
101 | 485 | CONFIGS.write_all() | 486 | CONFIGS.write_all() |
102 | 486 | 487 | ||
103 | === modified file 'hooks/neutron_api_utils.py' | |||
104 | --- hooks/neutron_api_utils.py 2015-07-13 19:07:37 +0000 | |||
105 | +++ hooks/neutron_api_utils.py 2015-08-12 10:36:14 +0000 | |||
106 | @@ -160,16 +160,21 @@ | |||
107 | 160 | return API_PORTS[service] | 160 | return API_PORTS[service] |
108 | 161 | 161 | ||
109 | 162 | 162 | ||
110 | 163 | def manage_plugin(): | ||
111 | 164 | return config('manage-neutron-plugin-legacy-mode') | ||
112 | 165 | |||
113 | 166 | |||
114 | 163 | def determine_packages(source=None): | 167 | def determine_packages(source=None): |
115 | 164 | # currently all packages match service names | 168 | # currently all packages match service names |
116 | 165 | packages = [] + BASE_PACKAGES | 169 | packages = [] + BASE_PACKAGES |
117 | 166 | 170 | ||
118 | 167 | for v in resource_map().values(): | 171 | for v in resource_map().values(): |
119 | 168 | packages.extend(v['services']) | 172 | packages.extend(v['services']) |
124 | 169 | pkgs = neutron_plugin_attribute(config('neutron-plugin'), | 173 | if manage_plugin(): |
125 | 170 | 'server_packages', | 174 | pkgs = neutron_plugin_attribute(config('neutron-plugin'), |
126 | 171 | 'neutron') | 175 | 'server_packages', |
127 | 172 | packages.extend(pkgs) | 176 | 'neutron') |
128 | 177 | packages.extend(pkgs) | ||
129 | 173 | 178 | ||
130 | 174 | if get_os_codename_install_source(source) >= 'kilo': | 179 | if get_os_codename_install_source(source) >= 'kilo': |
131 | 175 | packages.extend(KILO_PACKAGES) | 180 | packages.extend(KILO_PACKAGES) |
132 | @@ -211,24 +216,31 @@ | |||
133 | 211 | else: | 216 | else: |
134 | 212 | resource_map.pop(APACHE_24_CONF) | 217 | resource_map.pop(APACHE_24_CONF) |
135 | 213 | 218 | ||
154 | 214 | # add neutron plugin requirements. nova-c-c only needs the neutron-server | 219 | if manage_plugin(): |
155 | 215 | # associated with configs, not the plugin agent. | 220 | # add neutron plugin requirements. nova-c-c only needs the |
156 | 216 | plugin = config('neutron-plugin') | 221 | # neutron-server associated with configs, not the plugin agent. |
157 | 217 | conf = neutron_plugin_attribute(plugin, 'config', 'neutron') | 222 | plugin = config('neutron-plugin') |
158 | 218 | ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') | 223 | conf = neutron_plugin_attribute(plugin, 'config', 'neutron') |
159 | 219 | or []) | 224 | ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') |
160 | 220 | services = neutron_plugin_attribute(plugin, 'server_services', | 225 | or []) |
161 | 221 | 'neutron') | 226 | services = neutron_plugin_attribute(plugin, 'server_services', |
162 | 222 | resource_map[conf] = {} | 227 | 'neutron') |
163 | 223 | resource_map[conf]['services'] = services | 228 | resource_map[conf] = {} |
164 | 224 | resource_map[conf]['contexts'] = ctxts | 229 | resource_map[conf]['services'] = services |
165 | 225 | resource_map[conf]['contexts'].append( | 230 | resource_map[conf]['contexts'] = ctxts |
166 | 226 | neutron_api_context.NeutronCCContext()) | 231 | resource_map[conf]['contexts'].append( |
167 | 227 | 232 | neutron_api_context.NeutronCCContext()) | |
168 | 228 | # update for postgres | 233 | |
169 | 229 | resource_map[conf]['contexts'].append( | 234 | # update for postgres |
170 | 230 | context.PostgresqlDBContext(database=config('database'))) | 235 | resource_map[conf]['contexts'].append( |
171 | 231 | 236 | context.PostgresqlDBContext(database=config('database'))) | |
172 | 237 | |||
173 | 238 | else: | ||
174 | 239 | resource_map[NEUTRON_CONF]['contexts'].append( | ||
175 | 240 | neutron_api_context.NeutronApiSDNContext() | ||
176 | 241 | ) | ||
177 | 242 | resource_map[NEUTRON_DEFAULT]['contexts'] = \ | ||
178 | 243 | [neutron_api_context.NeutronApiSDNConfigFileContext()] | ||
179 | 232 | return resource_map | 244 | return resource_map |
180 | 233 | 245 | ||
181 | 234 | 246 | ||
182 | 235 | 247 | ||
183 | === modified file 'metadata.yaml' | |||
184 | --- metadata.yaml 2015-05-13 02:16:14 +0000 | |||
185 | +++ metadata.yaml 2015-08-12 10:36:14 +0000 | |||
186 | @@ -37,6 +37,9 @@ | |||
187 | 37 | zeromq-configuration: | 37 | zeromq-configuration: |
188 | 38 | interface: zeromq-configuration | 38 | interface: zeromq-configuration |
189 | 39 | scope: container | 39 | scope: container |
190 | 40 | neutron-plugin-api-subordinate: | ||
191 | 41 | interface: neutron-plugin-api-subordinate | ||
192 | 42 | scope: container | ||
193 | 40 | peers: | 43 | peers: |
194 | 41 | cluster: | 44 | cluster: |
195 | 42 | interface: neutron-api-ha | 45 | interface: neutron-api-ha |
196 | 43 | 46 | ||
197 | === modified file 'templates/icehouse/neutron.conf' | |||
198 | --- templates/icehouse/neutron.conf 2015-03-16 14:16:02 +0000 | |||
199 | +++ templates/icehouse/neutron.conf 2015-08-12 10:36:14 +0000 | |||
200 | @@ -27,10 +27,14 @@ | |||
201 | 27 | 27 | ||
202 | 28 | {% if core_plugin -%} | 28 | {% if core_plugin -%} |
203 | 29 | core_plugin = {{ core_plugin }} | 29 | core_plugin = {{ core_plugin }} |
204 | 30 | {% if service_plugins -%} | ||
205 | 31 | service_plugins = {{ service_plugins }} | ||
206 | 32 | {% else -%} | ||
207 | 30 | {% if neutron_plugin in ['ovs', 'ml2'] -%} | 33 | {% if neutron_plugin in ['ovs', 'ml2'] -%} |
208 | 31 | service_plugins = neutron.services.l3_router.l3_router_plugin.L3RouterPlugin,neutron.services.firewall.fwaas_plugin.FirewallPlugin,neutron.services.loadbalancer.plugin.LoadBalancerPlugin,neutron.services.vpn.plugin.VPNDriverPlugin,neutron.services.metering.metering_plugin.MeteringPlugin | 34 | service_plugins = neutron.services.l3_router.l3_router_plugin.L3RouterPlugin,neutron.services.firewall.fwaas_plugin.FirewallPlugin,neutron.services.loadbalancer.plugin.LoadBalancerPlugin,neutron.services.vpn.plugin.VPNDriverPlugin,neutron.services.metering.metering_plugin.MeteringPlugin |
209 | 32 | {% endif -%} | 35 | {% endif -%} |
210 | 33 | {% endif -%} | 36 | {% endif -%} |
211 | 37 | {% endif -%} | ||
212 | 34 | 38 | ||
213 | 35 | {% if neutron_security_groups -%} | 39 | {% if neutron_security_groups -%} |
214 | 36 | allow_overlapping_ips = True | 40 | allow_overlapping_ips = True |
215 | @@ -50,6 +54,12 @@ | |||
216 | 50 | nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0 | 54 | nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0 |
217 | 51 | {% endif -%} | 55 | {% endif -%} |
218 | 52 | 56 | ||
219 | 57 | {% if sections and 'DEFAULT' in sections -%} | ||
220 | 58 | {% for key, value in sections['DEFAULT'] -%} | ||
221 | 59 | {{ key }} = {{ value }} | ||
222 | 60 | {% endfor -%} | ||
223 | 61 | {% endif %} | ||
224 | 62 | |||
225 | 53 | [quotas] | 63 | [quotas] |
226 | 54 | quota_driver = neutron.db.quota_db.DbQuotaDriver | 64 | quota_driver = neutron.db.quota_db.DbQuotaDriver |
227 | 55 | {% if neutron_security_groups -%} | 65 | {% if neutron_security_groups -%} |
228 | 56 | 66 | ||
229 | === modified file 'templates/juno/neutron.conf' | |||
230 | --- templates/juno/neutron.conf 2015-04-02 12:41:04 +0000 | |||
231 | +++ templates/juno/neutron.conf 2015-08-12 10:36:14 +0000 | |||
232 | @@ -54,6 +54,12 @@ | |||
233 | 54 | nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0 | 54 | nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0 |
234 | 55 | {% endif -%} | 55 | {% endif -%} |
235 | 56 | 56 | ||
236 | 57 | {% if sections and 'DEFAULT' in sections -%} | ||
237 | 58 | {% for key, value in sections['DEFAULT'] -%} | ||
238 | 59 | {{ key }} = {{ value }} | ||
239 | 60 | {% endfor -%} | ||
240 | 61 | {% endif %} | ||
241 | 62 | |||
242 | 57 | [quotas] | 63 | [quotas] |
243 | 58 | quota_driver = neutron.db.quota_db.DbQuotaDriver | 64 | quota_driver = neutron.db.quota_db.DbQuotaDriver |
244 | 59 | {% if neutron_security_groups -%} | 65 | {% if neutron_security_groups -%} |
245 | 60 | 66 | ||
246 | === modified file 'templates/kilo/neutron.conf' | |||
247 | --- templates/kilo/neutron.conf 2015-03-31 14:54:38 +0000 | |||
248 | +++ templates/kilo/neutron.conf 2015-08-12 10:36:14 +0000 | |||
249 | @@ -31,10 +31,14 @@ | |||
250 | 31 | 31 | ||
251 | 32 | {% if core_plugin -%} | 32 | {% if core_plugin -%} |
252 | 33 | core_plugin = {{ core_plugin }} | 33 | core_plugin = {{ core_plugin }} |
253 | 34 | {% if service_plugins -%} | ||
254 | 35 | service_plugins = {{ service_plugins }} | ||
255 | 36 | {% else -%} | ||
256 | 34 | {% if neutron_plugin in ['ovs', 'ml2'] -%} | 37 | {% if neutron_plugin in ['ovs', 'ml2'] -%} |
257 | 35 | service_plugins = router,firewall,lbaas,vpnaas,metering | 38 | service_plugins = router,firewall,lbaas,vpnaas,metering |
258 | 36 | {% endif -%} | 39 | {% endif -%} |
259 | 37 | {% endif -%} | 40 | {% endif -%} |
260 | 41 | {% endif -%} | ||
261 | 38 | 42 | ||
262 | 39 | {% if neutron_security_groups -%} | 43 | {% if neutron_security_groups -%} |
263 | 40 | allow_overlapping_ips = True | 44 | allow_overlapping_ips = True |
264 | @@ -52,6 +56,12 @@ | |||
265 | 52 | nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0 | 56 | nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0 |
266 | 53 | {% endif -%} | 57 | {% endif -%} |
267 | 54 | 58 | ||
268 | 59 | {% if sections and 'DEFAULT' in sections -%} | ||
269 | 60 | {% for key, value in sections['DEFAULT'] -%} | ||
270 | 61 | {{ key }} = {{ value }} | ||
271 | 62 | {% endfor -%} | ||
272 | 63 | {% endif %} | ||
273 | 64 | |||
274 | 55 | {% include "section-zeromq" %} | 65 | {% include "section-zeromq" %} |
275 | 56 | 66 | ||
276 | 57 | [quotas] | 67 | [quotas] |
277 | 58 | 68 | ||
278 | === modified file 'unit_tests/test_neutron_api_context.py' | |||
279 | --- unit_tests/test_neutron_api_context.py 2015-05-06 11:39:27 +0000 | |||
280 | +++ unit_tests/test_neutron_api_context.py 2015-08-12 10:36:14 +0000 | |||
281 | @@ -1,3 +1,4 @@ | |||
282 | 1 | import json | ||
283 | 1 | from test_utils import CharmTestCase | 2 | from test_utils import CharmTestCase |
284 | 2 | from mock import patch | 3 | from mock import patch |
285 | 3 | import neutron_api_context as context | 4 | import neutron_api_context as context |
286 | @@ -432,3 +433,135 @@ | |||
287 | 432 | } | 433 | } |
288 | 433 | for key in expect.iterkeys(): | 434 | for key in expect.iterkeys(): |
289 | 434 | self.assertEquals(napi_ctxt[key], expect[key]) | 435 | self.assertEquals(napi_ctxt[key], expect[key]) |
290 | 436 | |||
291 | 437 | |||
292 | 438 | class NeutronApiSDNContextTest(CharmTestCase): | ||
293 | 439 | |||
294 | 440 | def setUp(self): | ||
295 | 441 | super(NeutronApiSDNContextTest, self).setUp(context, TO_PATCH) | ||
296 | 442 | self.relation_get.side_effect = self.test_relation.get | ||
297 | 443 | |||
298 | 444 | def tearDown(self): | ||
299 | 445 | super(NeutronApiSDNContextTest, self).tearDown() | ||
300 | 446 | |||
301 | 447 | def test_init(self): | ||
302 | 448 | napisdn_ctxt = context.NeutronApiSDNContext() | ||
303 | 449 | self.assertEquals( | ||
304 | 450 | napisdn_ctxt.interfaces, | ||
305 | 451 | 'neutron-plugin-api-subordinate' | ||
306 | 452 | ) | ||
307 | 453 | self.assertEquals(napisdn_ctxt.service, 'neutron-api') | ||
308 | 454 | self.assertEquals( | ||
309 | 455 | napisdn_ctxt.config_file, | ||
310 | 456 | '/etc/neutron/neutron.conf' | ||
311 | 457 | ) | ||
312 | 458 | |||
313 | 459 | @patch.object(charmhelpers.contrib.openstack.context, 'log') | ||
314 | 460 | @patch.object(charmhelpers.contrib.openstack.context, 'relation_get') | ||
315 | 461 | @patch.object(charmhelpers.contrib.openstack.context, 'related_units') | ||
316 | 462 | @patch.object(charmhelpers.contrib.openstack.context, 'relation_ids') | ||
317 | 463 | def ctxt_check(self, rel_settings, expect, _rids, _runits, _rget, _log): | ||
318 | 464 | self.test_relation.set(rel_settings) | ||
319 | 465 | _runits.return_value = ['unit1'] | ||
320 | 466 | _rids.return_value = ['rid2'] | ||
321 | 467 | _rget.side_effect = self.test_relation.get | ||
322 | 468 | self.relation_ids.return_value = ['rid2'] | ||
323 | 469 | self.related_units.return_value = ['unit1'] | ||
324 | 470 | napisdn_ctxt = context.NeutronApiSDNContext()() | ||
325 | 471 | self.assertEquals(napisdn_ctxt, expect) | ||
326 | 472 | |||
327 | 473 | def test_defaults(self): | ||
328 | 474 | self.ctxt_check( | ||
329 | 475 | {'neutron-plugin': 'ovs'}, | ||
330 | 476 | { | ||
331 | 477 | 'core_plugin': 'neutron.plugins.ml2.plugin.Ml2Plugin', | ||
332 | 478 | 'neutron_plugin_config': ('/etc/neutron/plugins/ml2/' | ||
333 | 479 | 'ml2_conf.ini'), | ||
334 | 480 | 'service_plugins': 'router,firewall,lbaas,vpnaas,metering', | ||
335 | 481 | 'restart_trigger': '', | ||
336 | 482 | 'neutron_plugin': 'ovs', | ||
337 | 483 | 'sections': {}, | ||
338 | 484 | } | ||
339 | 485 | ) | ||
340 | 486 | |||
341 | 487 | def test_overrides(self): | ||
342 | 488 | self.ctxt_check( | ||
343 | 489 | { | ||
344 | 490 | 'neutron-plugin': 'ovs', | ||
345 | 491 | 'core-plugin': 'neutron.plugins.ml2.plugin.MidoPlumODL', | ||
346 | 492 | 'neutron-plugin-config': '/etc/neutron/plugins/fl/flump.ini', | ||
347 | 493 | 'service-plugins': 'router,unicorn,rainbows', | ||
348 | 494 | 'restart-trigger': 'restartnow', | ||
349 | 495 | }, | ||
350 | 496 | { | ||
351 | 497 | 'core_plugin': 'neutron.plugins.ml2.plugin.MidoPlumODL', | ||
352 | 498 | 'neutron_plugin_config': '/etc/neutron/plugins/fl/flump.ini', | ||
353 | 499 | 'service_plugins': 'router,unicorn,rainbows', | ||
354 | 500 | 'restart_trigger': 'restartnow', | ||
355 | 501 | 'neutron_plugin': 'ovs', | ||
356 | 502 | 'sections': {}, | ||
357 | 503 | } | ||
358 | 504 | ) | ||
359 | 505 | |||
360 | 506 | def test_subordinateconfig(self): | ||
361 | 507 | principle_config = { | ||
362 | 508 | "neutron-api": { | ||
363 | 509 | "/etc/neutron/neutron.conf": { | ||
364 | 510 | "sections": { | ||
365 | 511 | 'DEFAULT': [ | ||
366 | 512 | ('neutronboost', True) | ||
367 | 513 | ], | ||
368 | 514 | } | ||
369 | 515 | } | ||
370 | 516 | } | ||
371 | 517 | } | ||
372 | 518 | self.ctxt_check( | ||
373 | 519 | { | ||
374 | 520 | 'neutron-plugin': 'ovs', | ||
375 | 521 | 'subordinate_configuration': json.dumps(principle_config), | ||
376 | 522 | }, | ||
377 | 523 | { | ||
378 | 524 | 'core_plugin': 'neutron.plugins.ml2.plugin.Ml2Plugin', | ||
379 | 525 | 'neutron_plugin_config': ('/etc/neutron/plugins/ml2/' | ||
380 | 526 | 'ml2_conf.ini'), | ||
381 | 527 | 'service_plugins': 'router,firewall,lbaas,vpnaas,metering', | ||
382 | 528 | 'restart_trigger': '', | ||
383 | 529 | 'neutron_plugin': 'ovs', | ||
384 | 530 | 'sections': {u'DEFAULT': [[u'neutronboost', True]]}, | ||
385 | 531 | } | ||
386 | 532 | ) | ||
387 | 533 | |||
388 | 534 | def test_empty(self): | ||
389 | 535 | self.ctxt_check( | ||
390 | 536 | {}, | ||
391 | 537 | {'sections': {}}, | ||
392 | 538 | ) | ||
393 | 539 | |||
394 | 540 | |||
395 | 541 | class NeutronApiSDNConfigFileContextTest(CharmTestCase): | ||
396 | 542 | |||
397 | 543 | def setUp(self): | ||
398 | 544 | super(NeutronApiSDNConfigFileContextTest, self).setUp( | ||
399 | 545 | context, TO_PATCH) | ||
400 | 546 | self.relation_get.side_effect = self.test_relation.get | ||
401 | 547 | |||
402 | 548 | def tearDown(self): | ||
403 | 549 | super(NeutronApiSDNConfigFileContextTest, self).tearDown() | ||
404 | 550 | |||
405 | 551 | def test_configset(self): | ||
406 | 552 | self.test_relation.set({ | ||
407 | 553 | 'neutron-plugin-config': '/etc/neutron/superplugin.ini' | ||
408 | 554 | }) | ||
409 | 555 | self.relation_ids.return_value = ['rid2'] | ||
410 | 556 | self.related_units.return_value = ['unit1'] | ||
411 | 557 | napisdn_ctxt = context.NeutronApiSDNConfigFileContext()() | ||
412 | 558 | self.assertEquals(napisdn_ctxt, { | ||
413 | 559 | 'config': '/etc/neutron/superplugin.ini' | ||
414 | 560 | }) | ||
415 | 561 | |||
416 | 562 | def test_default(self): | ||
417 | 563 | self.relation_ids.return_value = [] | ||
418 | 564 | napisdn_ctxt = context.NeutronApiSDNConfigFileContext()() | ||
419 | 565 | self.assertEquals(napisdn_ctxt, { | ||
420 | 566 | 'config': '/etc/neutron/plugins/ml2/ml2_conf.ini' | ||
421 | 567 | }) | ||
422 | 435 | 568 | ||
423 | === modified file 'unit_tests/test_neutron_api_utils.py' | |||
424 | --- unit_tests/test_neutron_api_utils.py 2015-06-29 11:33:36 +0000 | |||
425 | +++ unit_tests/test_neutron_api_utils.py 2015-08-12 10:36:14 +0000 | |||
426 | @@ -104,28 +104,57 @@ | |||
427 | 104 | expect.extend(nutils.KILO_PACKAGES) | 104 | expect.extend(nutils.KILO_PACKAGES) |
428 | 105 | self.assertItemsEqual(pkg_list, expect) | 105 | self.assertItemsEqual(pkg_list, expect) |
429 | 106 | 106 | ||
430 | 107 | @patch.object(nutils, 'git_install_requested') | ||
431 | 108 | def test_determine_packages_noplugin(self, git_requested): | ||
432 | 109 | git_requested.return_value = False | ||
433 | 110 | self.test_config.set('manage-neutron-plugin-legacy-mode', False) | ||
434 | 111 | pkg_list = nutils.determine_packages() | ||
435 | 112 | expect = deepcopy(nutils.BASE_PACKAGES) | ||
436 | 113 | expect.extend(['neutron-server']) | ||
437 | 114 | self.assertItemsEqual(pkg_list, expect) | ||
438 | 115 | |||
439 | 107 | def test_determine_ports(self): | 116 | def test_determine_ports(self): |
440 | 108 | port_list = nutils.determine_ports() | 117 | port_list = nutils.determine_ports() |
441 | 109 | self.assertItemsEqual(port_list, [9696]) | 118 | self.assertItemsEqual(port_list, [9696]) |
442 | 110 | 119 | ||
443 | 120 | @patch.object(nutils, 'manage_plugin') | ||
444 | 111 | @patch('os.path.exists') | 121 | @patch('os.path.exists') |
446 | 112 | def test_resource_map(self, _path_exists): | 122 | def test_resource_map(self, _path_exists, _manage_plugin): |
447 | 113 | _path_exists.return_value = False | 123 | _path_exists.return_value = False |
448 | 124 | _manage_plugin.return_value = True | ||
449 | 114 | _map = nutils.resource_map() | 125 | _map = nutils.resource_map() |
450 | 115 | confs = [nutils.NEUTRON_CONF, nutils.NEUTRON_DEFAULT, | 126 | confs = [nutils.NEUTRON_CONF, nutils.NEUTRON_DEFAULT, |
451 | 116 | nutils.APACHE_CONF] | 127 | nutils.APACHE_CONF] |
452 | 117 | [self.assertIn(q_conf, _map.keys()) for q_conf in confs] | 128 | [self.assertIn(q_conf, _map.keys()) for q_conf in confs] |
453 | 118 | self.assertTrue(nutils.APACHE_24_CONF not in _map.keys()) | 129 | self.assertTrue(nutils.APACHE_24_CONF not in _map.keys()) |
454 | 119 | 130 | ||
455 | 131 | @patch.object(nutils, 'manage_plugin') | ||
456 | 120 | @patch('os.path.exists') | 132 | @patch('os.path.exists') |
458 | 121 | def test_resource_map_apache24(self, _path_exists): | 133 | def test_resource_map_apache24(self, _path_exists, _manage_plugin): |
459 | 122 | _path_exists.return_value = True | 134 | _path_exists.return_value = True |
460 | 135 | _manage_plugin.return_value = True | ||
461 | 123 | _map = nutils.resource_map() | 136 | _map = nutils.resource_map() |
462 | 124 | confs = [nutils.NEUTRON_CONF, nutils.NEUTRON_DEFAULT, | 137 | confs = [nutils.NEUTRON_CONF, nutils.NEUTRON_DEFAULT, |
463 | 125 | nutils.APACHE_24_CONF] | 138 | nutils.APACHE_24_CONF] |
464 | 126 | [self.assertIn(q_conf, _map.keys()) for q_conf in confs] | 139 | [self.assertIn(q_conf, _map.keys()) for q_conf in confs] |
465 | 127 | self.assertTrue(nutils.APACHE_CONF not in _map.keys()) | 140 | self.assertTrue(nutils.APACHE_CONF not in _map.keys()) |
466 | 128 | 141 | ||
467 | 142 | @patch.object(nutils, 'manage_plugin') | ||
468 | 143 | @patch('os.path.exists') | ||
469 | 144 | def test_resource_map_noplugin(self, _path_exists, _manage_plugin): | ||
470 | 145 | _path_exists.return_value = True | ||
471 | 146 | _manage_plugin.return_value = False | ||
472 | 147 | _map = nutils.resource_map() | ||
473 | 148 | found_sdn_ctxt = False | ||
474 | 149 | found_sdnconfig_ctxt = False | ||
475 | 150 | for ctxt in _map[nutils.NEUTRON_CONF]['contexts']: | ||
476 | 151 | if isinstance(ctxt, ncontext.NeutronApiSDNContext): | ||
477 | 152 | found_sdn_ctxt = True | ||
478 | 153 | for ctxt in _map[nutils.NEUTRON_DEFAULT]['contexts']: | ||
479 | 154 | if isinstance(ctxt, ncontext.NeutronApiSDNConfigFileContext): | ||
480 | 155 | found_sdnconfig_ctxt = True | ||
481 | 156 | self.assertTrue(found_sdn_ctxt and found_sdnconfig_ctxt) | ||
482 | 157 | |||
483 | 129 | @patch('os.path.exists') | 158 | @patch('os.path.exists') |
484 | 130 | def test_restart_map(self, mock_path_exists): | 159 | def test_restart_map(self, mock_path_exists): |
485 | 131 | mock_path_exists.return_value = False | 160 | mock_path_exists.return_value = False |
486 | @@ -520,3 +549,13 @@ | |||
487 | 520 | 'upgrade', | 549 | 'upgrade', |
488 | 521 | 'head'] | 550 | 'head'] |
489 | 522 | self.subprocess.check_output.assert_called_with(cmd) | 551 | self.subprocess.check_output.assert_called_with(cmd) |
490 | 552 | |||
491 | 553 | def test_manage_plugin_true(self): | ||
492 | 554 | self.test_config.set('manage-neutron-plugin-legacy-mode', True) | ||
493 | 555 | manage = nutils.manage_plugin() | ||
494 | 556 | self.assertTrue(manage) | ||
495 | 557 | |||
496 | 558 | def test_manage_plugin_false(self): | ||
497 | 559 | self.test_config.set('manage-neutron-plugin-legacy-mode', False) | ||
498 | 560 | manage = nutils.manage_plugin() | ||
499 | 561 | self.assertFalse(manage) |
charm_lint_check #7923 neutron-api-next for gnuoy mp263224
LINT FAIL: lint-test failed
LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.
Full lint test output: http:// paste.ubuntu. com/12060702/ 10.245. 162.77: 8080/job/ charm_lint_ check/7923/
Build: http://