Update bootstrap handling to ensure key and fsid are present before

trying to init and start OSD devices.

Refactor osd device rescanning into ceph package.
This commit is contained in:
James Page 2012-10-15 11:13:36 +01:00
parent 9379c31404
commit cdf09477ab
2 changed files with 27 additions and 13 deletions

View File

@ -72,9 +72,22 @@ def is_osd_disk(dev):
pass pass
return False return False
def rescan_osd_devices():
cmd = [
'udevadm', 'trigger',
'--subsystem-match=block', '--action=add'
]
subprocess.call(cmd)
_bootstrap_keyring = "/var/lib/ceph/bootstrap-osd/ceph.keyring" _bootstrap_keyring = "/var/lib/ceph/bootstrap-osd/ceph.keyring"
def is_bootstrapped():
return os.path.exists(_bootstrap_keyring)
def import_osd_bootstrap_key(key): def import_osd_bootstrap_key(key):
if not os.path.exists(_bootstrap_keyring): if not os.path.exists(_bootstrap_keyring):
cmd = [ cmd = [

View File

@ -31,8 +31,11 @@ def install():
def emit_cephconf(): def emit_cephconf():
mon_hosts = get_mon_hosts()
utils.juju_log('INFO', 'Monitor hosts are ' + repr(mon_hosts))
cephcontext = { cephcontext = {
'mon_hosts': ' '.join(get_mon_hosts()), 'mon_hosts': ' '.join(mon_hosts),
'fsid': get_fsid() 'fsid': get_fsid()
} }
@ -43,15 +46,12 @@ def emit_cephconf():
def config_changed(): def config_changed():
utils.juju_log('INFO', 'Begin config-changed hook.') utils.juju_log('INFO', 'Begin config-changed hook.')
utils.juju_log('INFO', 'Monitor hosts are ' + repr(get_mon_hosts())) if ceph.is_bootstrapped():
utils.juju_log('INFO', 'ceph bootstrapped, rescanning disks')
if get_fsid():
utils.juju_log('INFO', 'cluster fsid detected, rescanning disks')
emit_cephconf() emit_cephconf()
for dev in utils.config_get('osd-devices').split(' '): for dev in utils.config_get('osd-devices').split(' '):
osdize(dev) osdize(dev)
subprocess.call(['udevadm', 'trigger', ceph.rescan_osd_devices()
'--subsystem-match=block', '--action=add'])
utils.juju_log('INFO', 'End config-changed hook.') utils.juju_log('INFO', 'End config-changed hook.')
@ -103,17 +103,18 @@ def osdize(dev):
def mon_relation(): def mon_relation():
utils.juju_log('INFO', 'Begin mon-relation hook.') utils.juju_log('INFO', 'Begin mon-relation hook.')
if get_fsid(): bootstrap_key = utils.relation_get('osd_bootstrap_key')
utils.juju_log('INFO', 'mon has provided fsid - scanning disks') if (get_fsid() and
bootstrap_key != ""):
utils.juju_log('INFO', 'mon has provided fsid & key- scanning disks')
emit_cephconf() emit_cephconf()
ceph.import_osd_bootstrap_key(utils.relation_get('osd_bootstrap_key')) ceph.import_osd_bootstrap_key(bootstrap_key)
for dev in utils.config_get('osd-devices').split(' '): for dev in utils.config_get('osd-devices').split(' '):
osdize(dev) osdize(dev)
subprocess.call(['udevadm', 'trigger', ceph.rescan_osd_devices()
'--subsystem-match=block', '--action=add'])
else: else:
utils.juju_log('INFO', utils.juju_log('INFO',
'mon cluster has not yet provided fsid') 'mon cluster has not yet provided fsid & key')
utils.juju_log('INFO', 'End mon-relation hook.') utils.juju_log('INFO', 'End mon-relation hook.')