]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
install.py: Warn if purging all data and ceph still installed.
authorGary Lowell <gary.lowell@inktank.com>
Fri, 19 Jul 2013 18:07:40 +0000 (11:07 -0700)
committerGary Lowell <gary.lowell@inktank.com>
Fri, 19 Jul 2013 21:09:40 +0000 (14:09 -0700)
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 <gary.lowell@inktank.com>
Reviewed-by: Alfredo Deza <alfredo.deza@inktank.com>
ceph_deploy/install.py

index f59c93e3b04930c78d71e36b6b4fb348d7abdf00..7d9ed5ffe7add05f260e536126db5849b90dba10 100644 (file)
@@ -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))