From eba6728cafe7abe1620705168a82697f5dea3add Mon Sep 17 00:00:00 2001 From: Luke Macken Date: Mon, 14 Jan 2008 16:18:39 -0500 Subject: Give props to Pádraig Brady for his ps_mem.py work, and update the AUTHORS file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- func/minion/modules/process.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'func') diff --git a/func/minion/modules/process.py b/func/minion/modules/process.py index 4c75251..92c6d6a 100644 --- a/func/minion/modules/process.py +++ b/func/minion/modules/process.py @@ -1,3 +1,4 @@ +## -*- coding: utf-8 -*- ## ## Process lister (control TBA) ## @@ -64,7 +65,7 @@ class ProcessModule(func_module.FuncModule): ["52.3 MiB", "10.8 MiB", "63.0 MiB", "liferea-bin"] ["171.6 MiB", "11.9 MiB", "183.5 MiB", "firefox-bin"]] - Taken from the ps_mem.py script written by P draigBrady com + Taken from the ps_mem.py script written by Pádraig Brady. http://www.pixelbeat.org/scripts/ps_mem.py """ import os -- cgit From 74e9bf9f3319da3c78e2718a8122e5edf8879638 Mon Sep 17 00:00:00 2001 From: Luke Macken Date: Mon, 14 Jan 2008 16:32:46 -0500 Subject: Slay a couple of tab characters --- func/minion/module_loader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'func') diff --git a/func/minion/module_loader.py b/func/minion/module_loader.py index 611323d..6fb2a6b 100755 --- a/func/minion/module_loader.py +++ b/func/minion/module_loader.py @@ -82,7 +82,7 @@ def load_modules(blacklist=None): try: blip = __import__("modules.%s" % ( mod_imp_name), globals(), locals(), [mod_imp_name]) if not hasattr(blip, "register_rpc"): - errmsg = _("%(module_path)s%(modname)s module not a proper module") + errmsg = _("%(module_path)s%(modname)s module not a proper module") logger.warning(errmsg % {'module_path': module_file_path, 'modname':mod_imp_name}) bad_mods[mod_imp_name] = True continue -- cgit From c4371ce647118902dd7574394d86c690c9be686e Mon Sep 17 00:00:00 2001 From: Luke Macken Date: Mon, 14 Jan 2008 17:14:23 -0500 Subject: Our client.command.Command class looks for 'usage', not 'useage' --- func/overlord/cmd_modules/call.py | 2 +- func/overlord/cmd_modules/copyfile.py | 2 +- func/overlord/cmd_modules/listminions.py | 2 +- func/overlord/cmd_modules/ping.py | 2 +- func/overlord/cmd_modules/show.py | 4 ++-- func/overlord/func_command.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) (limited to 'func') diff --git a/func/overlord/cmd_modules/call.py b/func/overlord/cmd_modules/call.py index 4828981..7add5bf 100644 --- a/func/overlord/cmd_modules/call.py +++ b/func/overlord/cmd_modules/call.py @@ -25,7 +25,7 @@ DEFAULT_FORKS = 1 class Call(client.command.Command): name = "call" - useage = "call nodule method name arg1 arg2..." + usage = "call module method name arg1 arg2..." def addOptions(self): self.parser.add_option("-v", "--verbose", dest="verbose", action="store_true") diff --git a/func/overlord/cmd_modules/copyfile.py b/func/overlord/cmd_modules/copyfile.py index 7950b7b..295aeab 100644 --- a/func/overlord/cmd_modules/copyfile.py +++ b/func/overlord/cmd_modules/copyfile.py @@ -26,7 +26,7 @@ DEFAULT_PORT = 51234 class CopyFile(client.command.Command): name = "copyfile" - useage = "copy a file to a client" + usage = "copy a file to a client" def addOptions(self): diff --git a/func/overlord/cmd_modules/listminions.py b/func/overlord/cmd_modules/listminions.py index b34efe4..50c7e24 100644 --- a/func/overlord/cmd_modules/listminions.py +++ b/func/overlord/cmd_modules/listminions.py @@ -22,7 +22,7 @@ DEFAULT_PORT = 51234 class ListMinions(client.command.Command): name = "list_minions" - useage = "show known minions" + usage = "show known minions" def addOptions(self): self.parser.add_option("-v", "--verbose", dest="verbose", diff --git a/func/overlord/cmd_modules/ping.py b/func/overlord/cmd_modules/ping.py index 397adc8..f756fd9 100644 --- a/func/overlord/cmd_modules/ping.py +++ b/func/overlord/cmd_modules/ping.py @@ -28,7 +28,7 @@ DEFAULT_PORT = 51234 class Ping(client.command.Command): name = "ping" - useage = "see what func minions are up/accessible" + usage = "see what func minions are up/accessible" def addOptions(self): """ diff --git a/func/overlord/cmd_modules/show.py b/func/overlord/cmd_modules/show.py index 4a26a75..e1df554 100644 --- a/func/overlord/cmd_modules/show.py +++ b/func/overlord/cmd_modules/show.py @@ -25,7 +25,7 @@ DEFAULT_PORT = 51234 class ShowHardware(client.command.Command): name = "hardware" - useage = "show hardware details" + usage = "show hardware details" # FIXME: we might as well make verbose be in the subclass # and probably an inc variable while we are at it @@ -74,7 +74,7 @@ class ShowHardware(client.command.Command): class Show(client.command.Command): name = "show" - useage = "various simple report stuff" + usage = "various simple report stuff" subCommandClasses = [ShowHardware] def addOptions(self): self.parser.add_option("-v", "--verbose", dest="verbose", diff --git a/func/overlord/func_command.py b/func/overlord/func_command.py index 76b4e95..09b324a 100644 --- a/func/overlord/func_command.py +++ b/func/overlord/func_command.py @@ -15,7 +15,7 @@ from func.overlord import client class FuncCommandLine(command.Command): name = "func" - useage = "func is the commandline interface to a func minion" + usage = "func is the commandline interface to a func minion" subCommandClasses = [call.Call, show.Show, copyfile.CopyFile, listminions.ListMinions, ping.Ping] -- cgit From bd9e4fe320ac35efaacd792be6edfa32838801e9 Mon Sep 17 00:00:00 2001 From: Steve 'Ashcrow' Milner Date: Mon, 14 Jan 2008 21:04:07 -0500 Subject: removed more shebangs from files that are not executable as part of the application. rpmlint should output less warnings/errors. --- func/certmaster.py | 2 -- func/minion/server.py | 1 - func/overlord/inventory.py | 2 -- func/overlord/sslclient.py | 2 -- 4 files changed, 7 deletions(-) (limited to 'func') diff --git a/func/certmaster.py b/func/certmaster.py index fa72493..1cde806 100755 --- a/func/certmaster.py +++ b/func/certmaster.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - # FIXME: more intelligent fault raises """ diff --git a/func/minion/server.py b/func/minion/server.py index cd353b9..6e55e70 100755 --- a/func/minion/server.py +++ b/func/minion/server.py @@ -1,4 +1,3 @@ -#!/usr/bin/python """ func diff --git a/func/overlord/inventory.py b/func/overlord/inventory.py index aafc764..e5319ee 100755 --- a/func/overlord/inventory.py +++ b/func/overlord/inventory.py @@ -1,4 +1,3 @@ -#!/usr/bin/python ## ## func inventory app. ## use func to collect inventory data on anything, yes, anything @@ -186,6 +185,5 @@ class FuncInventory(object): if __name__ == "__main__": - inv = FuncInventory() inv.run(sys.argv) diff --git a/func/overlord/sslclient.py b/func/overlord/sslclient.py index ccb2c9c..3861bb8 100755 --- a/func/overlord/sslclient.py +++ b/func/overlord/sslclient.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - import sys import xmlrpclib import urllib -- cgit From 462b3fbe80a6f82d207652e737212a2dc94061b7 Mon Sep 17 00:00:00 2001 From: Steve 'Ashcrow' Milner Date: Mon, 14 Jan 2008 21:34:17 -0500 Subject: Fixed the FIXME note about stdout/stderr in process.info. Also raise exception when bad args are passed using the first line as the exception message. --- func/minion/modules/process.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'func') diff --git a/func/minion/modules/process.py b/func/minion/modules/process.py index 92c6d6a..bdd5193 100644 --- a/func/minion/modules/process.py +++ b/func/minion/modules/process.py @@ -32,22 +32,27 @@ class ProcessModule(func_module.FuncModule): } func_module.FuncModule.__init__(self) - def info(self,flags="-auxh"): + def info(self, flags="-auxh"): """ Returns a struct of hardware information. By default, this pulls down all of the devices. If you don't care about them, set with_devices to False. """ - flags.replace(";","") # prevent stupidity + flags.replace(";", "") # prevent stupidity + cmd = sub_process.Popen(["/bin/ps", flags], executable="/bin/ps", + stdout=sub_process.PIPE, + stderr=sub_process.PIPE, + shell=False) - #FIXME: we need to swallow stdout/stderr as well, right now it spews to the console - cmd = sub_process.Popen(["/bin/ps", flags] ,executable="/bin/ps", stdout=sub_process.PIPE,shell=False) - data = cmd.communicate()[0] + data, error = cmd.communicate() - results = [] + # We can get warnings for odd formatting. warnings != errors. + if error and error[:7] != "Warning": + raise codes.FuncException(error.split('\n')[0]) + results = [] for x in data.split("\n"): tokens = x.split() results.append(tokens) @@ -196,17 +201,20 @@ class ProcessModule(func_module.FuncModule): if pid == "0": raise codes.FuncException("Killing pid group 0 not permitted") if signal == "": - # this is default /bin/kill behaviour, it claims, but enfore it anyway + # this is default /bin/kill behaviour, + # it claims, but enfore it anyway signal = "-TERM" if signal[0] != "-": signal = "-%s" % signal - rc = sub_process.call(["/bin/kill",signal, pid], executable="/bin/kill", shell=False) + rc = sub_process.call(["/bin/kill",signal, pid], + executable="/bin/kill", shell=False) print rc return rc def pkill(self,name,level=""): # example killall("thunderbird","-9") - rc = sub_process.call(["/usr/bin/pkill", name, level], executable="/usr/bin/pkill", shell=False) + rc = sub_process.call(["/usr/bin/pkill", name, level], + executable="/usr/bin/pkill", shell=False) return rc methods = ProcessModule() -- cgit From 7ec2b2c68be0545e2dc0e7eb4ae93ef4270b47a9 Mon Sep 17 00:00:00 2001 From: Steve 'Ashcrow' Milner Date: Mon, 14 Jan 2008 21:48:45 -0500 Subject: somehow networktest fell off the side of git ... added back. --- func/minion/modules/networktest.py | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 func/minion/modules/networktest.py (limited to 'func') diff --git a/func/minion/modules/networktest.py b/func/minion/modules/networktest.py new file mode 100644 index 0000000..e88c169 --- /dev/null +++ b/func/minion/modules/networktest.py @@ -0,0 +1,64 @@ +# Copyright 2008, Red Hat, Inc +# Steve 'Ashcrow' Milner +# +# This software may be freely redistributed under the terms of the GNU +# general public license. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + +from modules import func_module +from codes import FuncException + +import sub_process + +class NetworkTest(func_module.FuncModule): + + def __init__(self): + self.methods = { + "ping" : self.ping, + "netstat" : self.netstat, + "traceroute" : self.traceroute, + "dig" : self.dig, + "isportopen" : self.isportopen, + } + func_module.FuncModule.__init__(self) + + def ping(self, *args): + if '-c' not in args: + raise(FuncException("You must define a count with -c!")) + return self.__run_command('/bin/ping', self.__args_to_list(args)) + + def netstat(self, *args): + return self.__run_command('/bin/netstat', + self.__args_to_list(args)) + + def traceroute(self, *args): + return self.__run_command('/bin/traceroute', + self.__args_to_list(args)) + + def dig(self, *args): + return self.__run_command('/usr/bin/dig', + self.__args_to_list(args)) + + def isportopen(self, host, port): + import socket + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect((host, int(port))) + data = sock.recv(2048) + sock.close() + return [line for line in data.split('\n')] + + def __args_to_list(self, args): + return [arg for arg in args] + + def __run_command(self, command, opts=[]): + full_cmd = [command] + opts + cmd = sub_process.Popen(full_cmd, stdout=sub_process.PIPE) + return [line for line in cmd.communicate()[0].split('\n')] + + +methods = NetworkTest() +register_rpc = methods.register_rpc -- cgit