From: Gary Lowell Date: Fri, 19 Jul 2013 18:07:40 +0000 (-0700) Subject: install.py: Warn if purging all data and ceph still installed. X-Git-Tag: v1.2~29^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b82cf3a4e49b524751a423d25b88592b5096dabf;p=ceph-deploy.git install.py: Warn if purging all data and ceph still installed. If any of the hosts listed in the purgedata command still have ceph installed issue a warning message and prompt to continue. Fixes #5300. Signed-off-by: Gary Lowell Reviewed-by: Alfredo Deza --- diff --git a/ceph_deploy/install.py b/ceph_deploy/install.py index f59c93e..7d9ed5f 100644 --- a/ceph_deploy/install.py +++ b/ceph_deploy/install.py @@ -1,5 +1,6 @@ import argparse import logging +from distutils.util import strtobool from . import exc from . import lsb @@ -8,6 +9,20 @@ from .sudo_pushy import get_transport LOG = logging.getLogger(__name__) +def check_ceph_installed(): + """ + Check if the ceph packages are installed by looking for the + presence of the ceph command. + """ + import subprocess + + args = [ 'which', 'ceph', ] + process = subprocess.Popen( + args=args, + ) + lsb_release_path, _ = process.communicate() + return process.wait() + def install_suse(release, codename, version_kind, version): import platform import subprocess @@ -462,6 +477,21 @@ def purge_data(args): ' '.join(args.host), ) + installed_hosts=[] + for hostname in args.host: + sudo = args.pushy(get_transport(hostname)) + check_ceph_installed_r = sudo.compile(check_ceph_installed) + status = check_ceph_installed_r() + if status == 0: + installed_hosts.append(hostname) + sudo.close() + + if installed_hosts: + print "ceph is still installed on: ", installed_hosts + answer=raw_input("Continue (y/n)") + if not strtobool(answer): + return + for hostname in args.host: # TODO username sudo = args.pushy(get_transport(hostname))