From d8704bdc92241eb08f70db3d7200dce77d8fd03f Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 17 Dec 2012 17:37:31 +0000 Subject: [PATCH] Zap journal once --- hooks/ceph.py | 5 +++++ hooks/hooks.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/hooks/ceph.py b/hooks/ceph.py index 90a22a2..b3b67f4 100644 --- a/hooks/ceph.py +++ b/hooks/ceph.py @@ -109,6 +109,11 @@ def rescan_osd_devices(): subprocess.call(cmd) +def zap_disk(dev): + cmd = ['sgdisk', '--zap-all', dev] + subprocess.check_call(cmd) + + _bootstrap_keyring = "/var/lib/ceph/bootstrap-osd/ceph.keyring" diff --git a/hooks/hooks.py b/hooks/hooks.py index b0a16b9..ec1453b 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -45,6 +45,8 @@ def emit_cephconf(): with open('/etc/ceph/ceph.conf', 'w') as cephconf: cephconf.write(utils.render_template('ceph.conf', cephcontext)) +JOURNAL_ZAPPED = '/var/lib/ceph/journal_zapped' + def config_changed(): utils.juju_log('INFO', 'Begin config-changed hook.') @@ -69,6 +71,14 @@ def config_changed(): filesystem_mounted(e_mountpoint)): subprocess.call(['umount', e_mountpoint]) + osd_journal = utils.config_get('osd-journal') + if (osd_journal and + not os.path.exists(JOURNAL_ZAPPED) and + os.path.exists(osd_journal)): + ceph.zap_disk(osd_journal) + with open(JOURNAL_ZAPPED, 'w') as zapped: + zapped.write('DONE') + for dev in utils.config_get('osd-devices').split(' '): osdize(dev)