Merge lp:~openstack-charmers/charms/trusty/neutron-api/vpp into lp:~openstack-charmers-archive/charms/trusty/neutron-api/next

Proposed by Liam Young
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
Reviewer Review Type Date Requested Status
James Page Approve
Review via email: mp+263224@code.launchpad.net
To post a comment you must log in.
Revision history for this message
James Page (james-page) :
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

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/
Build: http://10.245.162.77:8080/job/charm_lint_check/7923/

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

charm_unit_test #7341 neutron-api-next for gnuoy mp263224
    UNIT OK: passed

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

Revision history for this message
James Page (james-page) :
review: Needs Fixing
134. By Liam Young

Fix kilo template ordering

135. By Liam Young

Fix lint and remove pointless comment from template

Revision history for this message
James Page (james-page) :
review: Approve
Revision history for this message
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://paste.ubuntu.com/12060783/
Build: http://10.245.162.77:8080/job/charm_amulet_test/5764/

136. By Liam Young

Fix unit test

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

charm_lint_check #7924 neutron-api-next for gnuoy mp263224
    LINT OK: passed

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

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

charm_unit_test #7342 neutron-api-next for gnuoy mp263224
    UNIT OK: passed

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

Revision history for this message
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://paste.ubuntu.com/12060903/
Build: http://10.245.162.77:8080/job/charm_amulet_test/5765/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2015-07-10 14:14:33 +0000
+++ config.yaml 2015-08-12 10:36:14 +0000
@@ -368,3 +368,9 @@
368 description: |368 description: |
369 A comma-separated list of nagios servicegroups.369 A comma-separated list of nagios servicegroups.
370 If left empty, the nagios_context will be used as the servicegroup370 If left empty, the nagios_context will be used as the servicegroup
371 manage-neutron-plugin-legacy-mode:
372 type: boolean
373 default: True
374 description: |
375 If True neutron-server will install neutron packages for the plugin
376 configured.
371377
=== added symlink 'hooks/neutron-plugin-api-subordinate-relation-changed'
=== target is u'neutron_api_hooks.py'
=== added symlink 'hooks/neutron-plugin-api-subordinate-relation-departed'
=== target is u'neutron_api_hooks.py'
=== added symlink 'hooks/neutron-plugin-api-subordinate-relation-joined'
=== target is u'neutron_api_hooks.py'
=== modified file 'hooks/neutron_api_context.py'
--- hooks/neutron_api_context.py 2015-05-06 11:40:21 +0000
+++ hooks/neutron_api_context.py 2015-08-12 10:36:14 +0000
@@ -234,3 +234,63 @@
234 # for haproxy.conf234 # for haproxy.conf
235 ctxt['service_ports'] = port_mapping235 ctxt['service_ports'] = port_mapping
236 return ctxt236 return ctxt
237
238
239class NeutronApiSDNContext(context.SubordinateConfigContext):
240 interfaces = 'neutron-plugin-api-subordinate'
241
242 def __init__(self):
243 super(NeutronApiSDNContext, self).__init__(
244 interface='neutron-plugin-api-subordinate',
245 service='neutron-api',
246 config_file='/etc/neutron/neutron.conf')
247
248 def __call__(self):
249 ctxt = super(NeutronApiSDNContext, self).__call__()
250 defaults = {
251 'core-plugin': {
252 'templ_key': 'core_plugin',
253 'value': 'neutron.plugins.ml2.plugin.Ml2Plugin',
254 },
255 'neutron-plugin-config': {
256 'templ_key': 'neutron_plugin_config',
257 'value': '/etc/neutron/plugins/ml2/ml2_conf.ini',
258 },
259 'service-plugins': {
260 'templ_key': 'service_plugins',
261 'value': 'router,firewall,lbaas,vpnaas,metering',
262 },
263 'restart-trigger': {
264 'templ_key': 'restart_trigger',
265 'value': '',
266 },
267 }
268 for rid in relation_ids('neutron-plugin-api-subordinate'):
269 for unit in related_units(rid):
270 rdata = relation_get(rid=rid, unit=unit)
271 plugin = rdata.get('neutron-plugin')
272 if not plugin:
273 continue
274 ctxt['neutron_plugin'] = plugin
275 for key in defaults.keys():
276 remote_value = rdata.get(key)
277 ctxt_key = defaults[key]['templ_key']
278 if remote_value:
279 ctxt[ctxt_key] = remote_value
280 else:
281 ctxt[ctxt_key] = defaults[key]['value']
282 return ctxt
283 return ctxt
284
285
286class NeutronApiSDNConfigFileContext(context.OSContextGenerator):
287 interfaces = ['neutron-plugin-api-subordinate']
288
289 def __call__(self):
290 for rid in relation_ids('neutron-plugin-api-subordinate'):
291 for unit in related_units(rid):
292 rdata = relation_get(rid=rid, unit=unit)
293 neutron_server_plugin_conf = rdata.get('neutron-plugin-config')
294 if neutron_server_plugin_conf:
295 return {'config': neutron_server_plugin_conf}
296 return {'config': '/etc/neutron/plugins/ml2/ml2_conf.ini'}
237297
=== modified file 'hooks/neutron_api_hooks.py'
--- hooks/neutron_api_hooks.py 2015-04-23 08:49:03 +0000
+++ hooks/neutron_api_hooks.py 2015-08-12 10:36:14 +0000
@@ -479,7 +479,8 @@
479 users="neutron")479 users="neutron")
480480
481481
482@hooks.hook('zeromq-configuration-relation-changed')482@hooks.hook('zeromq-configuration-relation-changed',
483 'neutron-plugin-api-subordinate-relation-changed')
483@restart_on_change(restart_map(), stopstart=True)484@restart_on_change(restart_map(), stopstart=True)
484def zeromq_configuration_relation_changed():485def zeromq_configuration_relation_changed():
485 CONFIGS.write_all()486 CONFIGS.write_all()
486487
=== modified file 'hooks/neutron_api_utils.py'
--- hooks/neutron_api_utils.py 2015-07-13 19:07:37 +0000
+++ hooks/neutron_api_utils.py 2015-08-12 10:36:14 +0000
@@ -160,16 +160,21 @@
160 return API_PORTS[service]160 return API_PORTS[service]
161161
162162
163def manage_plugin():
164 return config('manage-neutron-plugin-legacy-mode')
165
166
163def determine_packages(source=None):167def determine_packages(source=None):
164 # currently all packages match service names168 # currently all packages match service names
165 packages = [] + BASE_PACKAGES169 packages = [] + BASE_PACKAGES
166170
167 for v in resource_map().values():171 for v in resource_map().values():
168 packages.extend(v['services'])172 packages.extend(v['services'])
169 pkgs = neutron_plugin_attribute(config('neutron-plugin'),173 if manage_plugin():
170 'server_packages',174 pkgs = neutron_plugin_attribute(config('neutron-plugin'),
171 'neutron')175 'server_packages',
172 packages.extend(pkgs)176 'neutron')
177 packages.extend(pkgs)
173178
174 if get_os_codename_install_source(source) >= 'kilo':179 if get_os_codename_install_source(source) >= 'kilo':
175 packages.extend(KILO_PACKAGES)180 packages.extend(KILO_PACKAGES)
@@ -211,24 +216,31 @@
211 else:216 else:
212 resource_map.pop(APACHE_24_CONF)217 resource_map.pop(APACHE_24_CONF)
213218
214 # add neutron plugin requirements. nova-c-c only needs the neutron-server219 if manage_plugin():
215 # associated with configs, not the plugin agent.220 # add neutron plugin requirements. nova-c-c only needs the
216 plugin = config('neutron-plugin')221 # neutron-server associated with configs, not the plugin agent.
217 conf = neutron_plugin_attribute(plugin, 'config', 'neutron')222 plugin = config('neutron-plugin')
218 ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron')223 conf = neutron_plugin_attribute(plugin, 'config', 'neutron')
219 or [])224 ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron')
220 services = neutron_plugin_attribute(plugin, 'server_services',225 or [])
221 'neutron')226 services = neutron_plugin_attribute(plugin, 'server_services',
222 resource_map[conf] = {}227 'neutron')
223 resource_map[conf]['services'] = services228 resource_map[conf] = {}
224 resource_map[conf]['contexts'] = ctxts229 resource_map[conf]['services'] = services
225 resource_map[conf]['contexts'].append(230 resource_map[conf]['contexts'] = ctxts
226 neutron_api_context.NeutronCCContext())231 resource_map[conf]['contexts'].append(
227232 neutron_api_context.NeutronCCContext())
228 # update for postgres233
229 resource_map[conf]['contexts'].append(234 # update for postgres
230 context.PostgresqlDBContext(database=config('database')))235 resource_map[conf]['contexts'].append(
231236 context.PostgresqlDBContext(database=config('database')))
237
238 else:
239 resource_map[NEUTRON_CONF]['contexts'].append(
240 neutron_api_context.NeutronApiSDNContext()
241 )
242 resource_map[NEUTRON_DEFAULT]['contexts'] = \
243 [neutron_api_context.NeutronApiSDNConfigFileContext()]
232 return resource_map244 return resource_map
233245
234246
235247
=== modified file 'metadata.yaml'
--- metadata.yaml 2015-05-13 02:16:14 +0000
+++ metadata.yaml 2015-08-12 10:36:14 +0000
@@ -37,6 +37,9 @@
37 zeromq-configuration:37 zeromq-configuration:
38 interface: zeromq-configuration38 interface: zeromq-configuration
39 scope: container39 scope: container
40 neutron-plugin-api-subordinate:
41 interface: neutron-plugin-api-subordinate
42 scope: container
40peers:43peers:
41 cluster:44 cluster:
42 interface: neutron-api-ha45 interface: neutron-api-ha
4346
=== modified file 'templates/icehouse/neutron.conf'
--- templates/icehouse/neutron.conf 2015-03-16 14:16:02 +0000
+++ templates/icehouse/neutron.conf 2015-08-12 10:36:14 +0000
@@ -27,10 +27,14 @@
2727
28{% if core_plugin -%}28{% if core_plugin -%}
29core_plugin = {{ core_plugin }}29core_plugin = {{ core_plugin }}
30{% if service_plugins -%}
31service_plugins = {{ service_plugins }}
32{% else -%}
30{% if neutron_plugin in ['ovs', 'ml2'] -%}33{% if neutron_plugin in ['ovs', 'ml2'] -%}
31service_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.MeteringPlugin34service_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
32{% endif -%}35{% endif -%}
33{% endif -%}36{% endif -%}
37{% endif -%}
3438
35{% if neutron_security_groups -%}39{% if neutron_security_groups -%}
36allow_overlapping_ips = True40allow_overlapping_ips = True
@@ -50,6 +54,12 @@
50nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.054nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0
51{% endif -%}55{% endif -%}
5256
57{% if sections and 'DEFAULT' in sections -%}
58{% for key, value in sections['DEFAULT'] -%}
59{{ key }} = {{ value }}
60{% endfor -%}
61{% endif %}
62
53[quotas]63[quotas]
54quota_driver = neutron.db.quota_db.DbQuotaDriver64quota_driver = neutron.db.quota_db.DbQuotaDriver
55{% if neutron_security_groups -%}65{% if neutron_security_groups -%}
5666
=== modified file 'templates/juno/neutron.conf'
--- templates/juno/neutron.conf 2015-04-02 12:41:04 +0000
+++ templates/juno/neutron.conf 2015-08-12 10:36:14 +0000
@@ -54,6 +54,12 @@
54nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.054nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0
55{% endif -%}55{% endif -%}
5656
57{% if sections and 'DEFAULT' in sections -%}
58{% for key, value in sections['DEFAULT'] -%}
59{{ key }} = {{ value }}
60{% endfor -%}
61{% endif %}
62
57[quotas]63[quotas]
58quota_driver = neutron.db.quota_db.DbQuotaDriver64quota_driver = neutron.db.quota_db.DbQuotaDriver
59{% if neutron_security_groups -%}65{% if neutron_security_groups -%}
6066
=== modified file 'templates/kilo/neutron.conf'
--- templates/kilo/neutron.conf 2015-03-31 14:54:38 +0000
+++ templates/kilo/neutron.conf 2015-08-12 10:36:14 +0000
@@ -31,10 +31,14 @@
3131
32{% if core_plugin -%}32{% if core_plugin -%}
33core_plugin = {{ core_plugin }}33core_plugin = {{ core_plugin }}
34{% if service_plugins -%}
35service_plugins = {{ service_plugins }}
36{% else -%}
34{% if neutron_plugin in ['ovs', 'ml2'] -%}37{% if neutron_plugin in ['ovs', 'ml2'] -%}
35service_plugins = router,firewall,lbaas,vpnaas,metering38service_plugins = router,firewall,lbaas,vpnaas,metering
36{% endif -%}39{% endif -%}
37{% endif -%}40{% endif -%}
41{% endif -%}
3842
39{% if neutron_security_groups -%}43{% if neutron_security_groups -%}
40allow_overlapping_ips = True44allow_overlapping_ips = True
@@ -52,6 +56,12 @@
52nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.056nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0
53{% endif -%}57{% endif -%}
5458
59{% if sections and 'DEFAULT' in sections -%}
60{% for key, value in sections['DEFAULT'] -%}
61{{ key }} = {{ value }}
62{% endfor -%}
63{% endif %}
64
55{% include "section-zeromq" %}65{% include "section-zeromq" %}
5666
57[quotas]67[quotas]
5868
=== modified file 'unit_tests/test_neutron_api_context.py'
--- unit_tests/test_neutron_api_context.py 2015-05-06 11:39:27 +0000
+++ unit_tests/test_neutron_api_context.py 2015-08-12 10:36:14 +0000
@@ -1,3 +1,4 @@
1import json
1from test_utils import CharmTestCase2from test_utils import CharmTestCase
2from mock import patch3from mock import patch
3import neutron_api_context as context4import neutron_api_context as context
@@ -432,3 +433,135 @@
432 }433 }
433 for key in expect.iterkeys():434 for key in expect.iterkeys():
434 self.assertEquals(napi_ctxt[key], expect[key])435 self.assertEquals(napi_ctxt[key], expect[key])
436
437
438class NeutronApiSDNContextTest(CharmTestCase):
439
440 def setUp(self):
441 super(NeutronApiSDNContextTest, self).setUp(context, TO_PATCH)
442 self.relation_get.side_effect = self.test_relation.get
443
444 def tearDown(self):
445 super(NeutronApiSDNContextTest, self).tearDown()
446
447 def test_init(self):
448 napisdn_ctxt = context.NeutronApiSDNContext()
449 self.assertEquals(
450 napisdn_ctxt.interfaces,
451 'neutron-plugin-api-subordinate'
452 )
453 self.assertEquals(napisdn_ctxt.service, 'neutron-api')
454 self.assertEquals(
455 napisdn_ctxt.config_file,
456 '/etc/neutron/neutron.conf'
457 )
458
459 @patch.object(charmhelpers.contrib.openstack.context, 'log')
460 @patch.object(charmhelpers.contrib.openstack.context, 'relation_get')
461 @patch.object(charmhelpers.contrib.openstack.context, 'related_units')
462 @patch.object(charmhelpers.contrib.openstack.context, 'relation_ids')
463 def ctxt_check(self, rel_settings, expect, _rids, _runits, _rget, _log):
464 self.test_relation.set(rel_settings)
465 _runits.return_value = ['unit1']
466 _rids.return_value = ['rid2']
467 _rget.side_effect = self.test_relation.get
468 self.relation_ids.return_value = ['rid2']
469 self.related_units.return_value = ['unit1']
470 napisdn_ctxt = context.NeutronApiSDNContext()()
471 self.assertEquals(napisdn_ctxt, expect)
472
473 def test_defaults(self):
474 self.ctxt_check(
475 {'neutron-plugin': 'ovs'},
476 {
477 'core_plugin': 'neutron.plugins.ml2.plugin.Ml2Plugin',
478 'neutron_plugin_config': ('/etc/neutron/plugins/ml2/'
479 'ml2_conf.ini'),
480 'service_plugins': 'router,firewall,lbaas,vpnaas,metering',
481 'restart_trigger': '',
482 'neutron_plugin': 'ovs',
483 'sections': {},
484 }
485 )
486
487 def test_overrides(self):
488 self.ctxt_check(
489 {
490 'neutron-plugin': 'ovs',
491 'core-plugin': 'neutron.plugins.ml2.plugin.MidoPlumODL',
492 'neutron-plugin-config': '/etc/neutron/plugins/fl/flump.ini',
493 'service-plugins': 'router,unicorn,rainbows',
494 'restart-trigger': 'restartnow',
495 },
496 {
497 'core_plugin': 'neutron.plugins.ml2.plugin.MidoPlumODL',
498 'neutron_plugin_config': '/etc/neutron/plugins/fl/flump.ini',
499 'service_plugins': 'router,unicorn,rainbows',
500 'restart_trigger': 'restartnow',
501 'neutron_plugin': 'ovs',
502 'sections': {},
503 }
504 )
505
506 def test_subordinateconfig(self):
507 principle_config = {
508 "neutron-api": {
509 "/etc/neutron/neutron.conf": {
510 "sections": {
511 'DEFAULT': [
512 ('neutronboost', True)
513 ],
514 }
515 }
516 }
517 }
518 self.ctxt_check(
519 {
520 'neutron-plugin': 'ovs',
521 'subordinate_configuration': json.dumps(principle_config),
522 },
523 {
524 'core_plugin': 'neutron.plugins.ml2.plugin.Ml2Plugin',
525 'neutron_plugin_config': ('/etc/neutron/plugins/ml2/'
526 'ml2_conf.ini'),
527 'service_plugins': 'router,firewall,lbaas,vpnaas,metering',
528 'restart_trigger': '',
529 'neutron_plugin': 'ovs',
530 'sections': {u'DEFAULT': [[u'neutronboost', True]]},
531 }
532 )
533
534 def test_empty(self):
535 self.ctxt_check(
536 {},
537 {'sections': {}},
538 )
539
540
541class NeutronApiSDNConfigFileContextTest(CharmTestCase):
542
543 def setUp(self):
544 super(NeutronApiSDNConfigFileContextTest, self).setUp(
545 context, TO_PATCH)
546 self.relation_get.side_effect = self.test_relation.get
547
548 def tearDown(self):
549 super(NeutronApiSDNConfigFileContextTest, self).tearDown()
550
551 def test_configset(self):
552 self.test_relation.set({
553 'neutron-plugin-config': '/etc/neutron/superplugin.ini'
554 })
555 self.relation_ids.return_value = ['rid2']
556 self.related_units.return_value = ['unit1']
557 napisdn_ctxt = context.NeutronApiSDNConfigFileContext()()
558 self.assertEquals(napisdn_ctxt, {
559 'config': '/etc/neutron/superplugin.ini'
560 })
561
562 def test_default(self):
563 self.relation_ids.return_value = []
564 napisdn_ctxt = context.NeutronApiSDNConfigFileContext()()
565 self.assertEquals(napisdn_ctxt, {
566 'config': '/etc/neutron/plugins/ml2/ml2_conf.ini'
567 })
435568
=== modified file 'unit_tests/test_neutron_api_utils.py'
--- unit_tests/test_neutron_api_utils.py 2015-06-29 11:33:36 +0000
+++ unit_tests/test_neutron_api_utils.py 2015-08-12 10:36:14 +0000
@@ -104,28 +104,57 @@
104 expect.extend(nutils.KILO_PACKAGES)104 expect.extend(nutils.KILO_PACKAGES)
105 self.assertItemsEqual(pkg_list, expect)105 self.assertItemsEqual(pkg_list, expect)
106106
107 @patch.object(nutils, 'git_install_requested')
108 def test_determine_packages_noplugin(self, git_requested):
109 git_requested.return_value = False
110 self.test_config.set('manage-neutron-plugin-legacy-mode', False)
111 pkg_list = nutils.determine_packages()
112 expect = deepcopy(nutils.BASE_PACKAGES)
113 expect.extend(['neutron-server'])
114 self.assertItemsEqual(pkg_list, expect)
115
107 def test_determine_ports(self):116 def test_determine_ports(self):
108 port_list = nutils.determine_ports()117 port_list = nutils.determine_ports()
109 self.assertItemsEqual(port_list, [9696])118 self.assertItemsEqual(port_list, [9696])
110119
120 @patch.object(nutils, 'manage_plugin')
111 @patch('os.path.exists')121 @patch('os.path.exists')
112 def test_resource_map(self, _path_exists):122 def test_resource_map(self, _path_exists, _manage_plugin):
113 _path_exists.return_value = False123 _path_exists.return_value = False
124 _manage_plugin.return_value = True
114 _map = nutils.resource_map()125 _map = nutils.resource_map()
115 confs = [nutils.NEUTRON_CONF, nutils.NEUTRON_DEFAULT,126 confs = [nutils.NEUTRON_CONF, nutils.NEUTRON_DEFAULT,
116 nutils.APACHE_CONF]127 nutils.APACHE_CONF]
117 [self.assertIn(q_conf, _map.keys()) for q_conf in confs]128 [self.assertIn(q_conf, _map.keys()) for q_conf in confs]
118 self.assertTrue(nutils.APACHE_24_CONF not in _map.keys())129 self.assertTrue(nutils.APACHE_24_CONF not in _map.keys())
119130
131 @patch.object(nutils, 'manage_plugin')
120 @patch('os.path.exists')132 @patch('os.path.exists')
121 def test_resource_map_apache24(self, _path_exists):133 def test_resource_map_apache24(self, _path_exists, _manage_plugin):
122 _path_exists.return_value = True134 _path_exists.return_value = True
135 _manage_plugin.return_value = True
123 _map = nutils.resource_map()136 _map = nutils.resource_map()
124 confs = [nutils.NEUTRON_CONF, nutils.NEUTRON_DEFAULT,137 confs = [nutils.NEUTRON_CONF, nutils.NEUTRON_DEFAULT,
125 nutils.APACHE_24_CONF]138 nutils.APACHE_24_CONF]
126 [self.assertIn(q_conf, _map.keys()) for q_conf in confs]139 [self.assertIn(q_conf, _map.keys()) for q_conf in confs]
127 self.assertTrue(nutils.APACHE_CONF not in _map.keys())140 self.assertTrue(nutils.APACHE_CONF not in _map.keys())
128141
142 @patch.object(nutils, 'manage_plugin')
143 @patch('os.path.exists')
144 def test_resource_map_noplugin(self, _path_exists, _manage_plugin):
145 _path_exists.return_value = True
146 _manage_plugin.return_value = False
147 _map = nutils.resource_map()
148 found_sdn_ctxt = False
149 found_sdnconfig_ctxt = False
150 for ctxt in _map[nutils.NEUTRON_CONF]['contexts']:
151 if isinstance(ctxt, ncontext.NeutronApiSDNContext):
152 found_sdn_ctxt = True
153 for ctxt in _map[nutils.NEUTRON_DEFAULT]['contexts']:
154 if isinstance(ctxt, ncontext.NeutronApiSDNConfigFileContext):
155 found_sdnconfig_ctxt = True
156 self.assertTrue(found_sdn_ctxt and found_sdnconfig_ctxt)
157
129 @patch('os.path.exists')158 @patch('os.path.exists')
130 def test_restart_map(self, mock_path_exists):159 def test_restart_map(self, mock_path_exists):
131 mock_path_exists.return_value = False160 mock_path_exists.return_value = False
@@ -520,3 +549,13 @@
520 'upgrade',549 'upgrade',
521 'head']550 'head']
522 self.subprocess.check_output.assert_called_with(cmd)551 self.subprocess.check_output.assert_called_with(cmd)
552
553 def test_manage_plugin_true(self):
554 self.test_config.set('manage-neutron-plugin-legacy-mode', True)
555 manage = nutils.manage_plugin()
556 self.assertTrue(manage)
557
558 def test_manage_plugin_false(self):
559 self.test_config.set('manage-neutron-plugin-legacy-mode', False)
560 manage = nutils.manage_plugin()
561 self.assertFalse(manage)

Subscribers

People subscribed via source and target branches