Merge lp:~gnuoy/charms/trusty/nova-cloud-controller/neutron-refactor into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next

Proposed by Liam Young
Status: Merged
Merged at revision: 81
Proposed branch: lp:~gnuoy/charms/trusty/nova-cloud-controller/neutron-refactor
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
Diff against target: 659 lines (+290/-68)
8 files modified
README.txt (+5/-0)
hooks/nova_cc_context.py (+31/-1)
hooks/nova_cc_hooks.py (+85/-33)
hooks/nova_cc_utils.py (+48/-31)
metadata.yaml (+2/-0)
revision (+1/-1)
unit_tests/test_nova_cc_hooks.py (+85/-2)
unit_tests/test_nova_cc_utils.py (+33/-0)
To merge this branch: bzr merge lp:~gnuoy/charms/trusty/nova-cloud-controller/neutron-refactor
Reviewer Review Type Date Requested Status
Liam Young (community) Needs Resubmitting
James Page Needs Fixing
Review via email: mp+224070@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Liam Young (gnuoy) wrote :

Merge to add support for splitting neutron api to seperate principle charm

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

Updated with fixes suggested from mp

84. By Liam Young

Fixed lint and unit tests

85. By Liam Young

Bug fix. Charm was looking for the wrong key in api relations s/_/-/

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

Updated branch with updates suggested to mp

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.txt'
2--- README.txt 2014-03-25 09:11:04 +0000
3+++ README.txt 2014-06-23 12:22:41 +0000
4@@ -4,6 +4,11 @@
5
6 Cloud controller node for Openstack nova. Contains nova-schedule, nova-api, nova-network and nova-objectstore.
7
8+The neutron-api interface can be used join this charm with an external neutron-api server. If this is done
9+then this charm will shutdown its neutron-api service and the external charm will be registered as the
10+neutron-api endpoint in keystone. It will also use the quantum-security-groups setting which is passed to
11+it by the api service rather than its own quantum-security-groups setting.
12+
13 ******************************************************
14 Special considerations to be deployed using Postgresql
15 ******************************************************
16
17=== added symlink 'hooks/neutron-api-relation-broken'
18=== target is u'nova_cc_hooks.py'
19=== added symlink 'hooks/neutron-api-relation-changed'
20=== target is u'nova_cc_hooks.py'
21=== added symlink 'hooks/neutron-api-relation-departed'
22=== target is u'nova_cc_hooks.py'
23=== added symlink 'hooks/neutron-api-relation-joined'
24=== target is u'nova_cc_hooks.py'
25=== modified file 'hooks/nova_cc_context.py'
26--- hooks/nova_cc_context.py 2014-05-03 06:48:39 +0000
27+++ hooks/nova_cc_context.py 2014-06-23 12:22:41 +0000
28@@ -1,7 +1,7 @@
29
30 from charmhelpers.core.hookenv import (
31 config, relation_ids, relation_set, log, ERROR,
32- unit_get)
33+ unit_get, related_units, relation_get)
34
35 from charmhelpers.fetch import apt_install, filter_installed_packages
36 from charmhelpers.contrib.openstack import context, neutron, utils
37@@ -14,6 +14,17 @@
38 )
39
40
41+def context_complete(ctxt):
42+ _missing = []
43+ for k, v in ctxt.iteritems():
44+ if v is None or v == '':
45+ _missing.append(k)
46+ if _missing:
47+ log('Missing required data: %s' % ' '.join(_missing), level='INFO')
48+ return False
49+ return True
50+
51+
52 class ApacheSSLContext(context.ApacheSSLContext):
53
54 interfaces = ['https']
55@@ -27,6 +38,25 @@
56 return super(ApacheSSLContext, self).__call__()
57
58
59+class NeutronAPIContext(context.OSContextGenerator):
60+ def __call__(self):
61+ log('Generating template context from neutron api relation')
62+ ctxt = {}
63+ for rid in relation_ids('neutron-api'):
64+ for unit in related_units(rid):
65+ rdata = relation_get(rid=rid, unit=unit)
66+ ctxt = {
67+ 'neutron_url': rdata.get('neutron-url'),
68+ 'neutron_plugin': rdata.get('neutron-plugin'),
69+ 'neutron_security_groups':
70+ rdata.get('neutron-security-groups'),
71+ 'network_manager': 'neutron',
72+ }
73+ if context_complete(ctxt):
74+ return ctxt
75+ return {}
76+
77+
78 class VolumeServiceContext(context.OSContextGenerator):
79 interfaces = []
80
81
82=== modified file 'hooks/nova_cc_hooks.py'
83--- hooks/nova_cc_hooks.py 2014-04-11 16:41:42 +0000
84+++ hooks/nova_cc_hooks.py 2014-06-23 12:22:41 +0000
85@@ -24,7 +24,9 @@
86 )
87
88 from charmhelpers.core.host import (
89- restart_on_change
90+ restart_on_change,
91+ service_running,
92+ service_stop,
93 )
94
95 from charmhelpers.fetch import (
96@@ -41,6 +43,10 @@
97 neutron_plugin_attribute,
98 )
99
100+from nova_cc_context import (
101+ NeutronAPIContext
102+ )
103+
104 from nova_cc_utils import (
105 api_port,
106 auth_token_config,
107@@ -120,10 +126,11 @@
108 log('amqp relation incomplete. Peer not ready?')
109 return
110 CONFIGS.write(NOVA_CONF)
111- if network_manager() == 'quantum':
112- CONFIGS.write(QUANTUM_CONF)
113- if network_manager() == 'neutron':
114- CONFIGS.write(NEUTRON_CONF)
115+ if not is_relation_made('neutron-api'):
116+ if network_manager() == 'quantum':
117+ CONFIGS.write(QUANTUM_CONF)
118+ if network_manager() == 'neutron':
119+ CONFIGS.write(NEUTRON_CONF)
120
121
122 @hooks.hook('shared-db-relation-joined')
123@@ -235,12 +242,13 @@
124 return
125 CONFIGS.write('/etc/nova/api-paste.ini')
126 CONFIGS.write(NOVA_CONF)
127- if network_manager() == 'quantum':
128- CONFIGS.write(QUANTUM_API_PASTE)
129- CONFIGS.write(QUANTUM_CONF)
130- save_novarc()
131- if network_manager() == 'neutron':
132- CONFIGS.write(NEUTRON_CONF)
133+ if not is_relation_made('neutron-api'):
134+ if network_manager() == 'quantum':
135+ CONFIGS.write(QUANTUM_API_PASTE)
136+ CONFIGS.write(QUANTUM_CONF)
137+ save_novarc()
138+ if network_manager() == 'neutron':
139+ CONFIGS.write(NEUTRON_CONF)
140 [compute_joined(rid) for rid in relation_ids('cloud-compute')]
141 [quantum_joined(rid) for rid in relation_ids('quantum-network-service')]
142 [nova_vmware_relation_joined(rid) for rid in relation_ids('nova-vmware')]
143@@ -293,6 +301,34 @@
144 out.write('export OS_REGION_NAME=%s\n' % config('region'))
145
146
147+def neutron_settings():
148+ neutron_settings = {}
149+ if is_relation_made('neutron-api', 'neutron-plugin'):
150+ neutron_api_info = NeutronAPIContext()
151+ neutron_settings.update({
152+ # XXX: Rename these relations settings?
153+ 'quantum_plugin': neutron_api_info()['neutron_plugin'],
154+ 'region': config('region'),
155+ 'quantum_security_groups':
156+ neutron_api_info()['neutron_security_groups'],
157+ 'quantum_url': neutron_api_info()['neutron_url'],
158+ })
159+ else:
160+ neutron_settings.update({
161+ # XXX: Rename these relations settings?
162+ 'quantum_plugin': neutron_plugin(),
163+ 'region': config('region'),
164+ 'quantum_security_groups': config('quantum-security-groups'),
165+ 'quantum_url': (canonical_url(CONFIGS) + ':' +
166+ str(api_port('neutron-server'))),
167+ })
168+ neutron_settings['quantum_host'] = \
169+ urlparse(neutron_settings['quantum_url']).hostname
170+ neutron_settings['quantum_port'] = \
171+ urlparse(neutron_settings['quantum_url']).port
172+ return neutron_settings
173+
174+
175 def keystone_compute_settings():
176 ks_auth_config = _auth_config()
177 rel_settings = {}
178@@ -300,20 +336,10 @@
179 if network_manager() in ['quantum', 'neutron']:
180 if ks_auth_config:
181 rel_settings.update(ks_auth_config)
182-
183- rel_settings.update({
184- # XXX: Rename these relations settings?
185- 'quantum_plugin': neutron_plugin(),
186- 'region': config('region'),
187- 'quantum_security_groups': config('quantum-security-groups'),
188- 'quantum_url': (canonical_url(CONFIGS) + ':' +
189- str(api_port('neutron-server'))),
190- })
191-
192+ rel_settings.update(neutron_settings())
193 ks_ca = keystone_ca_cert_b64()
194 if ks_auth_config and ks_ca:
195 rel_settings['ca_cert'] = ks_ca
196-
197 return rel_settings
198
199
200@@ -328,7 +354,6 @@
201 # this may not even be needed.
202 'ec2_host': unit_get('private-address'),
203 }
204-
205 # update relation setting if we're attempting to restart remote
206 # services
207 if remote_restart:
208@@ -367,15 +392,7 @@
209 if not eligible_leader(CLUSTER_RES):
210 return
211
212- url = canonical_url(CONFIGS) + ':9696'
213- # XXX: Can we rename to neutron_*?
214- rel_settings = {
215- 'quantum_host': urlparse(url).hostname,
216- 'quantum_url': url,
217- 'quantum_port': 9696,
218- 'quantum_plugin': neutron_plugin(),
219- 'region': config('region')
220- }
221+ rel_settings = neutron_settings()
222
223 # inform quantum about local keystone auth config
224 ks_auth_config = _auth_config()
225@@ -385,7 +402,6 @@
226 ks_ca = keystone_ca_cert_b64()
227 if ks_auth_config and ks_ca:
228 rel_settings['ca_cert'] = ks_ca
229-
230 relation_set(relation_id=rid, **rel_settings)
231
232
233@@ -500,6 +516,42 @@
234 identity_joined(rid=r_id)
235
236
237+@hooks.hook('neutron-api-relation-joined')
238+def neutron_api_relation_joined(rid=None):
239+ with open('/etc/init/neutron-server.override', 'wb') as out:
240+ out.write('manual\n')
241+ if os.path.isfile(NEUTRON_CONF):
242+ os.rename(NEUTRON_CONF, NEUTRON_CONF + '_unused')
243+ if service_running('neutron-server'):
244+ service_stop('neutron-server')
245+ for id_rid in relation_ids('identity-service'):
246+ identity_joined(rid=id_rid)
247+ nova_url = canonical_url(CONFIGS) + ":8774/v2"
248+ relation_set(relation_id=rid, nova_url=nova_url)
249+
250+
251+@hooks.hook('neutron-api-relation-changed')
252+@restart_on_change(restart_map())
253+def neutron_api_relation_changed():
254+ CONFIGS.write(NOVA_CONF)
255+ for rid in relation_ids('cloud-compute'):
256+ compute_joined(rid=rid)
257+ for rid in relation_ids('quantum-network-service'):
258+ quantum_joined(rid=rid)
259+
260+
261+@hooks.hook('neutron-api-relation-broken')
262+@restart_on_change(restart_map())
263+def neutron_api_relation_broken():
264+ if os.path.isfile('/etc/init/neutron-server.override'):
265+ os.remove('/etc/init/neutron-server.override')
266+ CONFIGS.write_all()
267+ for rid in relation_ids('cloud-compute'):
268+ compute_joined(rid=rid)
269+ for rid in relation_ids('quantum-network-service'):
270+ quantum_joined(rid=rid)
271+
272+
273 def main():
274 try:
275 hooks.execute(sys.argv)
276
277=== modified file 'hooks/nova_cc_utils.py'
278--- hooks/nova_cc_utils.py 2014-06-12 09:46:56 +0000
279+++ hooks/nova_cc_utils.py 2014-06-23 12:22:41 +0000
280@@ -33,12 +33,13 @@
281 relation_get,
282 relation_ids,
283 remote_unit,
284+ is_relation_made,
285 INFO,
286 ERROR,
287 )
288
289 from charmhelpers.core.host import (
290- service_start
291+ service_start,
292 )
293
294
295@@ -106,8 +107,7 @@
296 context.SyslogContext(),
297 nova_cc_context.HAProxyContext(),
298 nova_cc_context.IdentityServiceContext(),
299- nova_cc_context.VolumeServiceContext(),
300- nova_cc_context.NeutronCCContext()],
301+ nova_cc_context.VolumeServiceContext()],
302 }),
303 (NOVA_API_PASTE, {
304 'services': [s for s in BASE_SERVICES if 'api' in s],
305@@ -188,39 +188,47 @@
306
307 net_manager = network_manager()
308
309- # pop out irrelevant resources from the OrderedDict (easier than adding
310- # them late)
311- if net_manager != 'quantum':
312- [resource_map.pop(k) for k in list(resource_map.iterkeys())
313- if 'quantum' in k]
314- if net_manager != 'neutron':
315- [resource_map.pop(k) for k in list(resource_map.iterkeys())
316- if 'neutron' in k]
317-
318 if os.path.exists('/etc/apache2/conf-available'):
319 resource_map.pop(APACHE_CONF)
320 else:
321 resource_map.pop(APACHE_24_CONF)
322
323- # add neutron plugin requirements. nova-c-c only needs the neutron-server
324- # associated with configs, not the plugin agent.
325- if net_manager in ['quantum', 'neutron']:
326- plugin = neutron_plugin()
327- if plugin:
328- conf = neutron_plugin_attribute(plugin, 'config', net_manager)
329- ctxts = (neutron_plugin_attribute(plugin, 'contexts', net_manager)
330- or [])
331- services = neutron_plugin_attribute(plugin, 'server_services',
332- net_manager)
333- resource_map[conf] = {}
334- resource_map[conf]['services'] = services
335- resource_map[conf]['contexts'] = ctxts
336- resource_map[conf]['contexts'].append(
337- nova_cc_context.NeutronCCContext())
338+ if is_relation_made('neutron-api'):
339+ [resource_map.pop(k) for k in list(resource_map.iterkeys())
340+ if 'quantum' in k or 'neutron' in k]
341+ resource_map[NOVA_CONF]['contexts'].append(
342+ nova_cc_context.NeutronAPIContext())
343+ else:
344+ resource_map[NOVA_CONF]['contexts'].append(
345+ nova_cc_context.NeutronCCContext())
346+ # pop out irrelevant resources from the OrderedDict (easier than adding
347+ # them late)
348+ if net_manager != 'quantum':
349+ [resource_map.pop(k) for k in list(resource_map.iterkeys())
350+ if 'quantum' in k]
351+ if net_manager != 'neutron':
352+ [resource_map.pop(k) for k in list(resource_map.iterkeys())
353+ if 'neutron' in k]
354+ # add neutron plugin requirements. nova-c-c only needs the
355+ # neutron-server associated with configs, not the plugin agent.
356+ if net_manager in ['quantum', 'neutron']:
357+ plugin = neutron_plugin()
358+ if plugin:
359+ conf = neutron_plugin_attribute(plugin, 'config', net_manager)
360+ ctxts = (neutron_plugin_attribute(plugin, 'contexts',
361+ net_manager)
362+ or [])
363+ services = neutron_plugin_attribute(plugin, 'server_services',
364+ net_manager)
365+ resource_map[conf] = {}
366+ resource_map[conf]['services'] = services
367+ resource_map[conf]['contexts'] = ctxts
368+ resource_map[conf]['contexts'].append(
369+ nova_cc_context.NeutronCCContext())
370
371- # update for postgres
372- resource_map[conf]['contexts'].append(
373- nova_cc_context.NeutronPostgresqlDBContext())
374+ # update for postgres
375+ resource_map[conf]['contexts'].append(
376+ nova_cc_context.NeutronPostgresqlDBContext())
377
378 # nova-conductor for releases >= G.
379 if os_release('nova-common') not in ['essex', 'folsom']:
380@@ -235,6 +243,7 @@
381 for s in vmware_ctxt['services']:
382 if s not in resource_map[NOVA_CONF]['services']:
383 resource_map[NOVA_CONF]['services'].append(s)
384+
385 return resource_map
386
387
388@@ -681,7 +690,15 @@
389 })
390
391 # XXX: Keep these relations named quantum_*??
392- if network_manager() in ['quantum', 'neutron']:
393+ if is_relation_made('neutron-api'):
394+ endpoints.update({
395+ 'quantum_service': None,
396+ 'quantum_region': None,
397+ 'quantum_public_url': None,
398+ 'quantum_admin_url': None,
399+ 'quantum_internal_url': None,
400+ })
401+ elif network_manager() in ['quantum', 'neutron']:
402 endpoints.update({
403 'quantum_service': 'quantum',
404 'quantum_region': region,
405
406=== modified file 'metadata.yaml'
407--- metadata.yaml 2014-03-31 11:56:09 +0000
408+++ metadata.yaml 2014-06-23 12:22:41 +0000
409@@ -30,6 +30,8 @@
410 interface: nova-volume
411 quantum-network-service:
412 interface: quantum
413+ neutron-api:
414+ interface: neutron-api
415 ha:
416 interface: hacluster
417 scope: container
418
419=== modified file 'revision'
420--- revision 2014-04-16 08:25:14 +0000
421+++ revision 2014-06-23 12:22:41 +0000
422@@ -1,1 +1,1 @@
423-315
424+500
425
426=== modified file 'unit_tests/test_nova_cc_hooks.py'
427--- unit_tests/test_nova_cc_hooks.py 2014-05-21 10:03:01 +0000
428+++ unit_tests/test_nova_cc_hooks.py 2014-06-23 12:22:41 +0000
429@@ -1,6 +1,6 @@
430 from mock import MagicMock, patch
431-from test_utils import CharmTestCase
432-
433+from test_utils import CharmTestCase, patch_open
434+import os
435 with patch('charmhelpers.core.hookenv.config') as config:
436 config.return_value = 'neutron'
437 import nova_cc_utils as utils
438@@ -38,6 +38,8 @@
439 'ssh_known_hosts_b64',
440 'ssh_authorized_keys_b64',
441 'save_script_rc',
442+ 'service_running',
443+ 'service_stop',
444 'execd_preinstall',
445 'network_manager',
446 'volume_service',
447@@ -105,8 +107,10 @@
448 self.relation_set.assert_called_with(known_hosts='hosts',
449 authorized_keys='keys')
450
451+# @patch.object(hooks, 'NeutronAPIContext')
452 @patch.object(hooks, '_auth_config')
453 def test_compute_joined_neutron(self, auth_config):
454+ self.is_relation_made.return_value = False
455 self.network_manager.return_value = 'neutron'
456 self.eligible_leader = True
457 self.keystone_ca_cert_b64.return_value = 'foocert64'
458@@ -122,6 +126,8 @@
459 relation_id=None,
460 quantum_url='http://nova-cc-host1:9696',
461 ca_cert='foocert64',
462+ quantum_port=9696,
463+ quantum_host='nova-cc-host1',
464 quantum_security_groups='no',
465 region='RegionOne',
466 volume_service='cinder',
467@@ -129,6 +135,40 @@
468 quantum_plugin='nvp',
469 network_manager='neutron', **FAKE_KS_AUTH_CFG)
470
471+ @patch.object(hooks, 'NeutronAPIContext')
472+ @patch.object(hooks, '_auth_config')
473+ def test_compute_joined_neutron_api_rel(self, auth_config, napi):
474+ def mock_NeutronAPIContext():
475+ return {
476+ 'neutron_plugin': 'bob',
477+ 'neutron_security_groups': 'yes',
478+ 'neutron_url': 'http://nova-cc-host1:9696',
479+ }
480+ napi.return_value = mock_NeutronAPIContext
481+ self.is_relation_made.return_value = True
482+ self.network_manager.return_value = 'neutron'
483+ self.eligible_leader = True
484+ self.keystone_ca_cert_b64.return_value = 'foocert64'
485+ self.volume_service.return_value = 'cinder'
486+ self.unit_get.return_value = 'nova-cc-host1'
487+ self.canonical_url.return_value = 'http://nova-cc-host1'
488+ self.api_port.return_value = '9696'
489+ self.neutron_plugin.return_value = 'nvp'
490+ auth_config.return_value = FAKE_KS_AUTH_CFG
491+ hooks.compute_joined()
492+ self.relation_set.assert_called_with(
493+ relation_id=None,
494+ quantum_url='http://nova-cc-host1:9696',
495+ ca_cert='foocert64',
496+ quantum_port=9696,
497+ quantum_host='nova-cc-host1',
498+ quantum_security_groups='yes',
499+ region='RegionOne',
500+ volume_service='cinder',
501+ ec2_host='nova-cc-host1',
502+ quantum_plugin='bob',
503+ network_manager='neutron', **FAKE_KS_AUTH_CFG)
504+
505 @patch.object(hooks, '_auth_config')
506 def test_nova_vmware_joined(self, auth_config):
507 auth_config.return_value = FAKE_KS_AUTH_CFG
508@@ -231,3 +271,46 @@
509 self._postgresql_db_test(configs)
510 self.assertTrue(configs.write_all.called)
511 self.migrate_database.assert_called_with()
512+
513+ @patch.object(os, 'rename')
514+ @patch.object(os.path, 'isfile')
515+ @patch.object(hooks, 'CONFIGS')
516+ def test_neutron_api_relation_joined(self, configs, isfile, rename):
517+ neutron_conf = '/etc/neutron/neutron.conf'
518+ nova_url = 'http://novaurl:8774/v2'
519+ isfile.return_value = True
520+ self.service_running.return_value = True
521+ _identity_joined = self.patch('identity_joined')
522+ self.relation_ids.side_effect = ['relid']
523+ self.canonical_url.return_value = 'http://novaurl'
524+ with patch_open() as (_open, _file):
525+ hooks.neutron_api_relation_joined()
526+ self.service_stop.assert_called_with('neutron-server')
527+ rename.assert_called_with(neutron_conf, neutron_conf + '_unused')
528+ self.assertTrue(_identity_joined.called)
529+ self.relation_set.assert_called_with(relation_id=None,
530+ nova_url=nova_url)
531+
532+ @patch.object(hooks, 'CONFIGS')
533+ def test_neutron_api_relation_changed(self, configs):
534+ self.relation_ids.return_value = ['relid']
535+ _compute_joined = self.patch('compute_joined')
536+ _quantum_joined = self.patch('quantum_joined')
537+ hooks.neutron_api_relation_changed()
538+ self.assertTrue(configs.write.called_with('/etc/nova/nova.conf'))
539+ self.assertTrue(_compute_joined.called)
540+ self.assertTrue(_quantum_joined.called)
541+
542+ @patch.object(os, 'remove')
543+ @patch.object(os.path, 'isfile')
544+ @patch.object(hooks, 'CONFIGS')
545+ def test_neutron_api_relation_broken(self, configs, isfile, remove):
546+ isfile.return_value = True
547+ self.relation_ids.return_value = ['relid']
548+ _compute_joined = self.patch('compute_joined')
549+ _quantum_joined = self.patch('quantum_joined')
550+ hooks.neutron_api_relation_broken()
551+ remove.assert_called_with('/etc/init/neutron-server.override')
552+ self.assertTrue(configs.write_all.called)
553+ self.assertTrue(_compute_joined.called)
554+ self.assertTrue(_quantum_joined.called)
555
556=== modified file 'unit_tests/test_nova_cc_utils.py'
557--- unit_tests/test_nova_cc_utils.py 2014-05-02 10:06:23 +0000
558+++ unit_tests/test_nova_cc_utils.py 2014-06-23 12:22:41 +0000
559@@ -22,6 +22,7 @@
560 'eligible_leader',
561 'enable_policy_rcd',
562 'get_os_codename_install_source',
563+ 'is_relation_made',
564 'log',
565 'ml2_migration',
566 'network_manager',
567@@ -151,6 +152,7 @@
568
569 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
570 def test_resource_map_quantum(self, subcontext):
571+ self.is_relation_made.return_value = False
572 self._resource_map(network_manager='quantum')
573 _map = utils.resource_map()
574 confs = [
575@@ -162,6 +164,7 @@
576
577 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
578 def test_resource_map_neutron(self, subcontext):
579+ self.is_relation_made.return_value = False
580 self._resource_map(network_manager='neutron')
581 _map = utils.resource_map()
582 confs = [
583@@ -170,6 +173,17 @@
584 [self.assertIn(q_conf, _map.keys()) for q_conf in confs]
585
586 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
587+ def test_resource_map_neutron_api_rel(self, subcontext):
588+ self.is_relation_made.return_value = True
589+ self._resource_map(network_manager='neutron')
590+ _map = utils.resource_map()
591+ confs = [
592+ '/etc/neutron/neutron.conf',
593+ ]
594+ for q_conf in confs:
595+ self.assertFalse(q_conf in _map.keys())
596+
597+ @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
598 def test_resource_map_vmware(self, subcontext):
599 fake_context = MagicMock()
600 fake_context.return_value = {
601@@ -201,6 +215,7 @@
602 @patch('os.path.exists')
603 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
604 def test_restart_map_api_before_frontends(self, subcontext, _exists):
605+ self.is_relation_made.return_value = False
606 _exists.return_value = False
607 self._resource_map(network_manager='neutron')
608 _map = utils.restart_map()
609@@ -226,6 +241,7 @@
610
611 @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
612 def test_determine_packages_neutron(self, subcontext):
613+ self.is_relation_made.return_value = False
614 self._resource_map(network_manager='neutron')
615 pkgs = utils.determine_packages()
616 self.assertIn('neutron-server', pkgs)
617@@ -421,11 +437,13 @@
618 self.os_release.return_value = 'folsom'
619
620 def test_determine_endpoints_base(self):
621+ self.is_relation_made.return_value = False
622 self.relation_ids.return_value = []
623 self.assertEquals(
624 BASE_ENDPOINTS, utils.determine_endpoints('http://foohost.com'))
625
626 def test_determine_endpoints_nova_volume(self):
627+ self.is_relation_made.return_value = False
628 self.relation_ids.return_value = ['nova-volume-service/0']
629 endpoints = deepcopy(BASE_ENDPOINTS)
630 endpoints.update({
631@@ -441,6 +459,7 @@
632 endpoints, utils.determine_endpoints('http://foohost.com'))
633
634 def test_determine_endpoints_quantum_neutron(self):
635+ self.is_relation_made.return_value = False
636 self.relation_ids.return_value = []
637 self.network_manager.return_value = 'quantum'
638 endpoints = deepcopy(BASE_ENDPOINTS)
639@@ -453,6 +472,20 @@
640 self.assertEquals(
641 endpoints, utils.determine_endpoints('http://foohost.com'))
642
643+ def test_determine_endpoints_neutron_api_rel(self):
644+ self.is_relation_made.return_value = True
645+ self.relation_ids.return_value = []
646+ self.network_manager.return_value = 'quantum'
647+ endpoints = deepcopy(BASE_ENDPOINTS)
648+ endpoints.update({
649+ 'quantum_admin_url': None,
650+ 'quantum_internal_url': None,
651+ 'quantum_public_url': None,
652+ 'quantum_region': None,
653+ 'quantum_service': None})
654+ self.assertEquals(
655+ endpoints, utils.determine_endpoints('http://foohost.com'))
656+
657 @patch.object(utils, 'known_hosts')
658 @patch('subprocess.check_output')
659 def test_ssh_known_host_key(self, _check_output, _known_hosts):

Subscribers

People subscribed via source and target branches