Merge lp:~hopem/charm-helpers/pki into lp:charm-helpers

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 321
Proposed branch: lp:~hopem/charm-helpers/pki
Merge into: lp:charm-helpers
Diff against target: 90 lines (+50/-9)
2 files modified
charmhelpers/contrib/openstack/context.py (+26/-9)
tests/contrib/openstack/test_os_contexts.py (+24/-0)
To merge this branch: bzr merge lp:~hopem/charm-helpers/pki
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
OpenStack Charmers Pending
Review via email: mp+250369@code.launchpad.net
To post a comment you must log in.
lp:~hopem/charm-helpers/pki updated
321. By Edward Hope-Morley

synced lp:charm-helpers

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

Approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/context.py'
2--- charmhelpers/contrib/openstack/context.py 2015-02-24 11:22:24 +0000
3+++ charmhelpers/contrib/openstack/context.py 2015-02-24 12:34:15 +0000
4@@ -279,9 +279,25 @@
5 class IdentityServiceContext(OSContextGenerator):
6 interfaces = ['identity-service']
7
8+ def __init__(self, service=None, service_user=None):
9+ self.service = service
10+ self.service_user = service_user
11+
12 def __call__(self):
13 log('Generating template context for identity-service', level=DEBUG)
14 ctxt = {}
15+
16+ if self.service and self.service_user:
17+ # This is required for pki token signing if we don't want /tmp to
18+ # be used.
19+ cachedir = '/var/cache/%s' % (self.service)
20+ if not os.path.isdir(cachedir):
21+ log("Creating service cache dir %s" % (cachedir), level=DEBUG)
22+ mkdir(path=cachedir, owner=self.service_user,
23+ group=self.service_user, perms=0o700)
24+
25+ ctxt['signing_dir'] = cachedir
26+
27 for rid in relation_ids('identity-service'):
28 for unit in related_units(rid):
29 rdata = relation_get(rid=rid, unit=unit)
30@@ -291,15 +307,16 @@
31 auth_host = format_ipv6_addr(auth_host) or auth_host
32 svc_protocol = rdata.get('service_protocol') or 'http'
33 auth_protocol = rdata.get('auth_protocol') or 'http'
34- ctxt = {'service_port': rdata.get('service_port'),
35- 'service_host': serv_host,
36- 'auth_host': auth_host,
37- 'auth_port': rdata.get('auth_port'),
38- 'admin_tenant_name': rdata.get('service_tenant'),
39- 'admin_user': rdata.get('service_username'),
40- 'admin_password': rdata.get('service_password'),
41- 'service_protocol': svc_protocol,
42- 'auth_protocol': auth_protocol}
43+ ctxt.update({'service_port': rdata.get('service_port'),
44+ 'service_host': serv_host,
45+ 'auth_host': auth_host,
46+ 'auth_port': rdata.get('auth_port'),
47+ 'admin_tenant_name': rdata.get('service_tenant'),
48+ 'admin_user': rdata.get('service_username'),
49+ 'admin_password': rdata.get('service_password'),
50+ 'service_protocol': svc_protocol,
51+ 'auth_protocol': auth_protocol})
52+
53 if context_complete(ctxt):
54 # NOTE(jamespage) this is required for >= icehouse
55 # so a missing value just indicates keystone needs
56
57=== modified file 'tests/contrib/openstack/test_os_contexts.py'
58--- tests/contrib/openstack/test_os_contexts.py 2015-02-24 11:22:24 +0000
59+++ tests/contrib/openstack/test_os_contexts.py 2015-02-24 12:34:15 +0000
60@@ -631,6 +631,30 @@
61 }
62 self.assertEquals(result, expected)
63
64+ def test_identity_service_context_with_cache(self):
65+ '''Test shared-db context with signing cache info'''
66+ relation = FakeRelation(relation_data=IDENTITY_SERVICE_RELATION_UNSET)
67+ self.relation_get.side_effect = relation.get
68+ svc = 'cinder'
69+ identity_service = context.IdentityServiceContext(service=svc,
70+ service_user=svc)
71+ result = identity_service()
72+ expected = {
73+ 'admin_password': 'foo',
74+ 'admin_tenant_name': 'admin',
75+ 'admin_tenant_id': None,
76+ 'admin_user': 'adam',
77+ 'auth_host': 'keystone-host.local',
78+ 'auth_port': '35357',
79+ 'auth_protocol': 'http',
80+ 'service_host': 'keystonehost.local',
81+ 'service_port': '5000',
82+ 'service_protocol': 'http',
83+ 'signing_dir': '/var/cache/cinder',
84+ }
85+ self.assertTrue(self.mkdir.called)
86+ self.assertEquals(result, expected)
87+
88 def test_identity_service_context_with_data_http(self):
89 '''Test shared-db context with all required data'''
90 relation = FakeRelation(relation_data=IDENTITY_SERVICE_RELATION_HTTP)

Subscribers

People subscribed via source and target branches