Checkin new helpers.

This commit is contained in:
Adam Gandelman
2013-09-23 12:04:24 -07:00
parent e3b3cc19bf
commit 1ecc7117d3

View File

@@ -334,3 +334,25 @@ def ensure_ceph_storage(service, pool, rbd_img, sizemb, mount_point,
log('ceph: Starting service {} after migrating data.'
.format(svc))
service_start(svc)
def ensure_ceph_keyring(service, user=None, group=None):
'''
Ensures a ceph keyring is created for a named service
and optionally ensures user and group ownership.
Returns False if no ceph key is available in relation state.
'''
key = None
for rid in relation_ids('ceph'):
for unit in related_units(rid):
key = relation_get('key', rid=rid, unit=unit)
if key:
break
if not key:
return False
create_keyring(service=service, key=key)
keyring = _keyring_path(service)
if user and group:
check_call(['chown', '%s.%s' % (user, group), keyring])
return True