From: Sage Weil Date: Fri, 22 Mar 2013 21:45:27 +0000 (-0700) Subject: purgedata: new command to purge /var/lib/ceph data X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bb1314f103898e3797470d9eabaa0c06c1e43a0d;p=ceph-deploy.git purgedata: new command to purge /var/lib/ceph data 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 --- diff --git a/ceph_deploy/install.py b/ceph_deploy/install.py index b380ac2..c5937dd 100644 --- a/ceph_deploy/install.py +++ b/ceph_deploy/install.py @@ -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, + ) diff --git a/setup.py b/setup.py index 14d1f02..36c4545 100644 --- 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',