268
271
@hooks.hook('client-relation-joined')
269
def client_relation(relid=None):
272
def client_relation_joined(relid=None):
270
273
if ceph.is_quorum():
271
274
log('mon cluster in quorum - providing client with keys')
272
275
service_name = None
273
276
if relid is None:
274
service_name = remote_unit().split('/')[0]
277
units = [remote_unit()]
278
service_name = units[0].split('/')[0]
276
280
units = related_units(relid)
277
281
if len(units) > 0:
278
282
service_name = units[0].split('/')[0]
279
284
if service_name is not None:
281
'key': ceph.get_named_key(service_name),
282
'auth': config('auth-supported'),
283
'ceph-public-address': get_public_addr(),
285
data = {'key': ceph.get_named_key(service_name),
286
'auth': config('auth-supported'),
287
'ceph-public-address': get_public_addr()}
285
288
relation_set(relation_id=relid,
286
289
relation_settings=data)
291
client_relation_changed(relid=relid)
288
293
log('mon cluster not in quorum - deferring key provision')
296
@hooks.hook('client-relation-changed')
297
def client_relation_changed(relid=None):
298
"""Process broker requests from ceph client relations."""
300
settings = relation_get(rid=relid)
301
if 'broker_req' in settings:
302
if not ceph.is_leader():
303
log("Not leader - ignoring broker request", level=DEBUG)
305
rsp = process_requests(settings['broker_req'])
306
relation_set(relation_id=relid,
307
relation_settings={'broker_rsp': rsp})
309
log('mon cluster not in quorum', level=DEBUG)
291
312
@hooks.hook('upgrade-charm')
292
313
def upgrade_charm():