summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorRobin Norwood <rnorwood@redhat.com>2007-09-24 17:43:05 -0400
committerRobin Norwood <rnorwood@redhat.com>2007-09-24 17:43:05 -0400
commit3a78963db6e4747be51935bdd1928e220945b49b (patch)
tree72319cc571b8c783e836ef5b9aa7f852d858decc /modules
parentfbb252b32b8d966bde90aa8c6f9fb544b100149b (diff)
parent0067f7ff6189fdd46f49e45ed2099511eb4de004 (diff)
downloadthird_party-func-3a78963db6e4747be51935bdd1928e220945b49b.tar.gz
third_party-func-3a78963db6e4747be51935bdd1928e220945b49b.tar.xz
third_party-func-3a78963db6e4747be51935bdd1928e220945b49b.zip
Merge branch 'master' of git://git.fedoraproject.org/git/hosted/func
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/process.py10
-rwxr-xr-xmodules/reboot.py4
-rwxr-xr-xmodules/service.py4
-rwxr-xr-xmodules/smart.py57
-rwxr-xr-xmodules/virt.py6
5 files changed, 69 insertions, 12 deletions
diff --git a/modules/process.py b/modules/process.py
index 064b1b3..3e40fe1 100755
--- a/modules/process.py
+++ b/modules/process.py
@@ -15,7 +15,7 @@
##
# other modules
-import subprocess
+import sub_process
# our modules
from codes import *
@@ -32,7 +32,7 @@ class ProcessModule(func_module.FuncModule):
}
func_module.FuncModule.__init__(self)
- def info(self,flags="-aux"):
+ 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
@@ -41,7 +41,7 @@ class ProcessModule(func_module.FuncModule):
flags.replace(";","") # prevent stupidity
- cmd = subprocess.Popen("ps %s" % flags,stdout=subprocess.PIPE,shell=True)
+ cmd = sub_process.Popen("ps %s" % flags,stdout=sub_process.PIPE,shell=True)
data = cmd.communicate()[0]
results = []
@@ -53,12 +53,12 @@ class ProcessModule(func_module.FuncModule):
return results
def kill(self,pid,level=""):
- rc = subprocess.call("/bin/kill %s %s" % (pid, level), shell=True)
+ rc = sub_process.call("/bin/kill %s %s" % (pid, level), shell=True)
return rc
def pkill(self,name,level=""):
# example killall("thunderbird","-9")
- rc = subprocess.call("/usr/bin/pkill %s %s" % (name, level), shell=True)
+ rc = sub_process.call("/usr/bin/pkill %s %s" % (name, level), shell=True)
return rc
methods = ProcessModule()
diff --git a/modules/reboot.py b/modules/reboot.py
index ddc7651..8772b8f 100755
--- a/modules/reboot.py
+++ b/modules/reboot.py
@@ -11,7 +11,7 @@
from modules import func_module
-import subprocess
+import sub_process
class Reboot(func_module.FuncModule):
@@ -22,7 +22,7 @@ class Reboot(func_module.FuncModule):
func_module.FuncModule.__init__(self)
def reboot(self, when='now', message=''):
- return subprocess.call(["/sbin/shutdown", '-r', when, message])
+ return sub_process.call(["/sbin/shutdown", '-r', when, message])
methods = Reboot()
diff --git a/modules/service.py b/modules/service.py
index bbc51e1..524cd7b 100755
--- a/modules/service.py
+++ b/modules/service.py
@@ -18,7 +18,7 @@
from codes import *
from modules import func_module
-import subprocess
+import sub_process
import os
class Service(func_module.FuncModule):
@@ -37,7 +37,7 @@ class Service(func_module.FuncModule):
filename = os.path.join("/etc/rc.d/init.d/",service_name)
if os.path.exists(filename):
- return subprocess.call(["/sbin/service", service_name, command])
+ return sub_process.call(["/sbin/service", service_name, command])
else:
raise FuncException("Service not installed: %s" % service_name)
diff --git a/modules/smart.py b/modules/smart.py
new file mode 100755
index 0000000..4ed8335
--- /dev/null
+++ b/modules/smart.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+
+##
+## Grabs status from SMART to see if your hard drives are ok
+## Returns in the format of (return code, [line1, line2, line3,...])
+##
+## Copyright 2007, Red Hat, Inc
+## Michael DeHaan <mdehaan@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.
+##
+
+# other modules
+import sub_process
+
+# our modules
+from codes import *
+from modules import func_module
+
+# =================================
+
+class SmartModule(func_module.FuncModule):
+ def __init__(self):
+ self.methods = {
+ "info" : self.info,
+ }
+ func_module.FuncModule.__init__(self)
+
+ def info(self,flags="-q onecheck"):
+ """
+ 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
+
+ cmd = sub_process.Popen("/usr/sbin/smartd %s" % flags,stdout=sub_process.PIPE,shell=True)
+ data = cmd.communicate()[0]
+
+ results = []
+
+ for x in data.split("\n"):
+ results.append(x)
+
+ return (cmd.returncode, results)
+
+methods = SmartModule()
+register_rpc = methods.register_rpc
+
+
+
diff --git a/modules/virt.py b/modules/virt.py
index d345d75..15be92c 100755
--- a/modules/virt.py
+++ b/modules/virt.py
@@ -22,7 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# other modules
import sys
import os
-import subprocess
+import sub_process
import libvirt
# our modules
@@ -44,7 +44,7 @@ class FuncLibvirtConnection():
def __init__(self):
- cmd = subprocess.Popen("uname -r", shell=True, stdout=subprocess.PIPE)
+ cmd = sub_process.Popen("uname -r", shell=True, stdout=sub_process.PIPE)
output = cmd.communicate()[0]
if output.find("xen") != -1:
@@ -188,7 +188,7 @@ class Virt(func_module.FuncModule):
"--server=%s" % server_name
]
- rc = subprocess.call(koan_args,shell=False)
+ rc = sub_process.call(koan_args,shell=False)
if rc == 0:
return 0
else: