From 8e9b9a57ff3bc18bc2cd181bd184bd55b585abda Mon Sep 17 00:00:00 2001 From: lxnay Date: Tue, 27 Mar 2007 06:04:46 +0000 Subject: [PATCH] added the --show-hosts option for the distcc module git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@198 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- handlers/enzyme | 1 + libraries/entropyTools.py | 6 ++++++ libraries/enzymeTools.py | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/handlers/enzyme b/handlers/enzyme index 2c8438b78..658226a49 100644 --- a/handlers/enzyme +++ b/handlers/enzyme @@ -80,6 +80,7 @@ def print_help(): entropyTools.print_info(" \t\t "+entropyTools.red("--remove-host")+"\t\t remove a hostname/ip") entropyTools.print_info(" \t\t "+entropyTools.red("--enable")+"\t\t enable the DistCC funcionality") entropyTools.print_info(" \t\t "+entropyTools.red("--disable")+"\t\t disable the DistCC funcionality") + entropyTools.print_info(" \t\t "+entropyTools.red("--show-hosts")+"\t\t show the currently enabled hosts") entropyTools.print_info(" \t"+entropyTools.green(entropyTools.bold("cleanup"))+entropyTools.yellow("\t\t to clean temporary files")) options = sys.argv[1:] diff --git a/libraries/entropyTools.py b/libraries/entropyTools.py index 7610d5fd8..0ebe8d7ab 100644 --- a/libraries/entropyTools.py +++ b/libraries/entropyTools.py @@ -1262,6 +1262,12 @@ def removeDistCCHosts(hosts): def getDistCCStatus(): return etpConst['distcc-status'] +def isIPAvailable(ip): + rc = os.system("ping -c 1 "+ip+" &> /dev/null") + if (rc): + return False + return True + def getFileUnixMtime(path): return os.path.getmtime(path) diff --git a/libraries/enzymeTools.py b/libraries/enzymeTools.py index a990814b3..0714799ea 100644 --- a/libraries/enzymeTools.py +++ b/libraries/enzymeTools.py @@ -936,6 +936,7 @@ def distcc(options): addDistCCHosts(myhosts) myhosts = string.join(myhosts," ") print_info(green(" * ")+red("Hosts: ")+blue(myhosts)+red(" added.")) + elif (options[0] == "--remove-host"): if (not getDistCCStatus()): print_warning(yellow(" * ")+red("Attention: distcc is not enabled.")) @@ -948,3 +949,18 @@ def distcc(options): myhosts = string.join(myhosts," ") print_info(green(" * ")+red("Hosts: ")+blue(myhosts)+red(" removed.")) + elif (options[0] == "--show-hosts"): + if (not getDistCCStatus()): + print_warning(yellow(" * ")+red("Attention: distcc is not enabled.")) + hosts = getDistCCHosts() + if len(hosts) == 0: + print_warning(yellow(" * ")+red("Attention: no hosts selected.")) + sys.exit(205) + print_info(green(" * ")+red("Showing DistCC hosts table:")) + for host in hosts: + availability = isIPAvailable(host) + if (availability): + availability = green("running") + else: + availability = green("not running") + print_info(green(" * ")+yellow("\tHost:\t")+blue(host)+red(" :: ")+availability) \ No newline at end of file