~corey.bryant/charms/trusty/ceph/fix-for-1352547

« back to all changes in this revision

Viewing changes to hooks/ceph.py

  • Committer: Adam Gandelman
  • Date: 2013-09-23 17:09:59 UTC
  • mfrom: (64.1.3 ceph)
  • Revision ID: adamg@canonical.com-20130923170959-ppkcvlorqf66d2bv
[jamespage] Update default mon permissions to have rw for pool creation, upgrade keys on charm upgrade

Show diffs side-by-side

added added

removed removed

Lines of Context:
224
224
 
225
225
# OSD caps taken from ceph-create-keys
226
226
_radosgw_caps = {
227
 
    'mon': ['allow r'],
 
227
    'mon': ['allow rw'],
228
228
    'osd': ['allow rwx']
229
229
}
230
230
 
234
234
 
235
235
 
236
236
_default_caps = {
237
 
    'mon': ['allow r'],
 
237
    'mon': ['allow rw'],
238
238
    'osd': ['allow rwx']
239
239
}
240
240
 
259
259
    return parse_key(subprocess.check_output(cmd).strip())  # IGNORE:E1103
260
260
 
261
261
 
 
262
def upgrade_key_caps(key, caps):
 
263
    ''' Upgrade key to have capabilities caps '''
 
264
    if not is_leader():
 
265
        # Not the MON leader OR not clustered
 
266
        return
 
267
    cmd = [
 
268
        'ceph', 'auth', 'caps', key
 
269
    ]
 
270
    for subsystem, subcaps in caps.iteritems():
 
271
        cmd.extend([subsystem, '; '.join(subcaps)])
 
272
    subprocess.check_call(cmd)
 
273
 
 
274
 
262
275
def bootstrap_monitor_cluster(secret):
263
276
    hostname = get_unit_hostname()
264
277
    path = '/var/lib/ceph/mon/ceph-{}'.format(hostname)