]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
mon: archive, instead of deleting, destroyed monitor data 27/head
authorSage Weil <sage@inktank.com>
Mon, 29 Jul 2013 22:06:29 +0000 (15:06 -0700)
committerSage Weil <sage@inktank.com>
Mon, 29 Jul 2013 22:06:29 +0000 (15:06 -0700)
Fixes: #5738
Signed-off-by: Sage Weil <sage@inktank.com>
ceph_deploy/mon.py

index f57a06797e1b47878d772f5f9b852c1e5fd4b72f..75af9ca95c65033436010cf5981d4cf044415370 100644 (file)
@@ -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