summaryrefslogtreecommitdiffstats
path: root/func
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-01-15 15:31:03 -0500
committerMichael DeHaan <mdehaan@redhat.com>2008-01-15 15:31:03 -0500
commitdc85cea9b1912ad2cbe59224050b8ae38b051167 (patch)
tree6aa8b6efdcbc3335521edd0a89a41364cac54608 /func
parentb51e8c0837354eba4e234a1f9bcf0ecd630d2ae0 (diff)
parent7ec2b2c68be0545e2dc0e7eb4ae93ef4270b47a9 (diff)
downloadfunc-dc85cea9b1912ad2cbe59224050b8ae38b051167.tar.gz
func-dc85cea9b1912ad2cbe59224050b8ae38b051167.tar.xz
func-dc85cea9b1912ad2cbe59224050b8ae38b051167.zip
Merge branch 'master' of ssh://git.fedoraproject.org/git/hosted/func
Diffstat (limited to 'func')
-rwxr-xr-xfunc/certmaster.py2
-rwxr-xr-xfunc/minion/module_loader.py2
-rw-r--r--func/minion/modules/networktest.py64
-rw-r--r--func/minion/modules/process.py29
-rwxr-xr-xfunc/minion/server.py1
-rw-r--r--func/overlord/cmd_modules/call.py2
-rw-r--r--func/overlord/cmd_modules/copyfile.py2
-rw-r--r--func/overlord/cmd_modules/listminions.py2
-rw-r--r--func/overlord/cmd_modules/ping.py2
-rw-r--r--func/overlord/cmd_modules/show.py4
-rw-r--r--func/overlord/func_command.py2
-rwxr-xr-xfunc/overlord/inventory.py2
-rwxr-xr-xfunc/overlord/sslclient.py2
13 files changed, 91 insertions, 25 deletions
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/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
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 <smilner@redhat.com>
+#
+# 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
diff --git a/func/minion/modules/process.py b/func/minion/modules/process.py
index 4c75251..bdd5193 100644
--- a/func/minion/modules/process.py
+++ b/func/minion/modules/process.py
@@ -1,3 +1,4 @@
+## -*- coding: utf-8 -*-
##
## Process lister (control TBA)
##
@@ -31,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)
@@ -64,7 +70,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
@@ -195,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()
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/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]
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