From: Sage Weil Date: Mon, 29 Jul 2013 22:06:29 +0000 (-0700) Subject: mon: archive, instead of deleting, destroyed monitor data X-Git-Tag: v1.2~14^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F27%2Fhead;p=ceph-deploy.git mon: archive, instead of deleting, destroyed monitor data Fixes: #5738 Signed-off-by: Sage Weil --- diff --git a/ceph_deploy/mon.py b/ceph_deploy/mon.py index f57a067..75af9ca 100644 --- a/ceph_deploy/mon.py +++ b/ceph_deploy/mon.py @@ -149,6 +149,8 @@ def mon_create(args): def destroy_mon(cluster, paths, is_running): + import datetime + import errno import os import subprocess # noqa import socket @@ -206,17 +208,25 @@ def destroy_mon(cluster, paths, is_running): else: break - # delete monitor directory - # XXX This should not remove the mon data - # but move it + # archive old monitor directory + fn = '{cluster}-{hostname}-{stamp}'.format( + hostname=hostname, + cluster=cluster, + stamp=datetime.datetime.utcnow().strftime("%Y-%m-%dZ%H:%M:%S"), + ) subprocess.check_call( args=[ - 'rm', - '-rf', - path, + 'mkdir', + '-p', + '/var/lib/ceph/mon-removed', ], ) - + try: + os.makedirs('/var/lib/ceph/mon-removed') + except OSError, e: + if e.errno != errno.EEXIST: + raise + os.rename(path, os.path.join('/var/lib/ceph/mon-removed/', fn)) def mon_destroy(args): errors = 0