From 440e60d6cc35730b5a541f1cfbd3e4a75cb188dc Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 12 Nov 2012 09:45:28 +0000 Subject: [PATCH] Add feature to enabled forced reformatting of OSD devices. --- config.yaml | 9 +++++++++ hooks/hooks.py | 10 +++++++++- revision | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/config.yaml b/config.yaml index d08845b..ffc45a4 100644 --- a/config.yaml +++ b/config.yaml @@ -39,6 +39,15 @@ options: . These devices are the range of devices that will be checked for and used across all service units. + osd-reformat: + type: string + description: | + By default, the charm will not re-format a device that already looks + as if it might be an OSD device. This is a safeguard to try to + prevent data loss. + . + Specifying this option (any value) forces a reformat of any OSD devices + found which are not already mounted. ephemeral-unmount: type: string description: | diff --git a/hooks/hooks.py b/hooks/hooks.py index 44bdc3a..b364b68 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -121,6 +121,13 @@ def bootstrap_monitor_cluster(): os.unlink(keyring) +def reformat_osd(): + if utils.config_get('osd-reformat') != "": + return True + else: + return False + + def osdize(dev): if not os.path.exists(dev): utils.juju_log('INFO', @@ -131,7 +138,8 @@ def osdize(dev): if e_mountpoint != "": subprocess.call(['umount', e_mountpoint]) - if ceph.is_osd_disk(dev): + if (ceph.is_osd_disk(dev) and not + reformat_osd()): utils.juju_log('INFO', 'Looks like {} is already an OSD, skipping.' .format(dev)) diff --git a/revision b/revision index 8cf5c1a..84df352 100644 --- a/revision +++ b/revision @@ -1 +1 @@ -86 +87