]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
purgedata: new command to purge /var/lib/ceph data
authorSage Weil <sage@inktank.com>
Fri, 22 Mar 2013 21:45:27 +0000 (14:45 -0700)
committerSage Weil <sage@inktank.com>
Fri, 22 Mar 2013 21:45:27 +0000 (14:45 -0700)
The package removal doesn't remove cluster data; this command will.  The
user should be careful doing this, of course.

Signed-off-by: Sage Weil <sage@inktank.com>
ceph_deploy/install.py
setup.py

index b380ac2d7f208c015d4bb1b11dcd2b22df00c3e8..c5937dd9ea9c9199765912df10856385cf240ad4 100644 (file)
@@ -160,6 +160,24 @@ def install_debian(release, codename, version_kind, version):
             ],
         )
 
+def purge_data_any():
+    import subprocess
+
+    subprocess.call(args=[
+            'rm', '-rf', '--one-file-system', '--', '/var/lib/ceph',
+            ])
+    if os.path.exists('/var/lib/ceph'):
+        subprocess.check_call(args=[
+                'find', '/var/lib/ceph',
+                '-mindepth', '1',
+                '-maxdepth', '2',
+                '-type', 'd',
+                '-exec', 'umount', '{}',
+                ])
+        subprocess.check_call(args=[
+                'rm', '-rf', '--one-file-system', '--', '/var/lib/ceph',
+                ])
+
 def install(args):
     version = getattr(args, args.version_kind)
     version_str = args.version_kind
@@ -248,6 +266,21 @@ def purge(args):
 
         purge_r(arg_purge=True)
 
+def purge_data(args):
+    LOG.debug(
+        'Purging data from cluster %s hosts %s',
+        args.cluster,
+        ' '.join(args.host),
+        )
+
+    for hostname in args.host:
+        # TODO username
+        sudo = args.pushy('ssh+sudo:{hostname}'.format(hostname=hostname))
+
+        LOG.debug('Purging data from host %s ...', hostname)
+        purge_data_any_r = sudo.compile(purge_data_any)
+        purge_data_any_r()
+
 class StoreVersion(argparse.Action):
     """
     Like ``"store"`` but also remember which one of the exclusive
@@ -349,3 +382,19 @@ def make_purge(parser):
     parser.set_defaults(
         func=purge,
         )
+
+
+@priority(80)
+def make_purge_data(parser):
+    """
+    Purge (delete, destroy, discard, shred) any Ceph data from /var/lib/ceph
+    """
+    parser.add_argument(
+        'host',
+        metavar='HOST',
+        nargs='+',
+        help='hosts to purge Ceph data from',
+        )
+    parser.set_defaults(
+        func=purge_data,
+        )
index 14d1f02878cf81e9bdd14027eb7540572c8e8718..36c45453fb3cdbdb781ee95bbec5b3ca4f5d6e79 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -49,6 +49,7 @@ setup(
             'install = ceph_deploy.install:make',
             'uninstall = ceph_deploy.install:make_uninstall',
             'purge = ceph_deploy.install:make_purge',
+            'purgedata = ceph_deploy.install:make_purge_data',
             'mon = ceph_deploy.mon:make',
             'gatherkeys = ceph_deploy.gatherkeys:make',
             'osd = ceph_deploy.osd:make',