279
279
class IdentityServiceContext(OSContextGenerator):
280
280
interfaces = ['identity-service']
282
def __init__(self, service=None, service_user=None):
283
self.service = service
284
self.service_user = service_user
282
286
def __call__(self):
283
287
log('Generating template context for identity-service', level=DEBUG)
290
if self.service and self.service_user:
291
# This is required for pki token signing if we don't want /tmp to
293
cachedir = '/var/cache/%s' % (self.service)
294
if not os.path.isdir(cachedir):
295
log("Creating service cache dir %s" % (cachedir), level=DEBUG)
296
mkdir(path=cachedir, owner=self.service_user,
297
group=self.service_user, perms=0o700)
299
ctxt['signing_dir'] = cachedir
285
301
for rid in relation_ids('identity-service'):
286
302
for unit in related_units(rid):
287
303
rdata = relation_get(rid=rid, unit=unit)
291
307
auth_host = format_ipv6_addr(auth_host) or auth_host
292
308
svc_protocol = rdata.get('service_protocol') or 'http'
293
309
auth_protocol = rdata.get('auth_protocol') or 'http'
294
ctxt = {'service_port': rdata.get('service_port'),
295
'service_host': serv_host,
296
'auth_host': auth_host,
297
'auth_port': rdata.get('auth_port'),
298
'admin_tenant_name': rdata.get('service_tenant'),
299
'admin_user': rdata.get('service_username'),
300
'admin_password': rdata.get('service_password'),
301
'service_protocol': svc_protocol,
302
'auth_protocol': auth_protocol}
310
ctxt.update({'service_port': rdata.get('service_port'),
311
'service_host': serv_host,
312
'auth_host': auth_host,
313
'auth_port': rdata.get('auth_port'),
314
'admin_tenant_name': rdata.get('service_tenant'),
315
'admin_user': rdata.get('service_username'),
316
'admin_password': rdata.get('service_password'),
317
'service_protocol': svc_protocol,
318
'auth_protocol': auth_protocol})
303
320
if context_complete(ctxt):
304
321
# NOTE(jamespage) this is required for >= icehouse
305
322
# so a missing value just indicates keystone needs
1021
1038
for unit in related_units(rid):
1022
1039
ctxt['zmq_nonce'] = relation_get('nonce', unit, rid)
1023
1040
ctxt['zmq_host'] = relation_get('host', unit, rid)
1041
ctxt['zmq_redis_address'] = relation_get(
1042
'zmq_redis_address', unit, rid)