summaryrefslogtreecommitdiffstats
path: root/func
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2007-10-25 14:31:42 -0400
committerMichael DeHaan <mdehaan@redhat.com>2007-10-25 14:31:42 -0400
commit505165364f8acff6fb93329b4fc315a3e3427bcf (patch)
tree618dbdc747e622a742de2f2df6920d5acec8d957 /func
parent054209f0c97becc17fa71aa323a7a3de08370cb0 (diff)
downloadthird_party-func-505165364f8acff6fb93329b4fc315a3e3427bcf.tar.gz
third_party-func-505165364f8acff6fb93329b4fc315a3e3427bcf.tar.xz
third_party-func-505165364f8acff6fb93329b4fc315a3e3427bcf.zip
Added the first part of the service inventory code (chkconfig state) .. next up is the list of currently running
services.
Diffstat (limited to 'func')
-rwxr-xr-xfunc/minion/modules/service.py40
1 files changed, 35 insertions, 5 deletions
diff --git a/func/minion/modules/service.py b/func/minion/modules/service.py
index 433d70b..9dcc422 100755
--- a/func/minion/modules/service.py
+++ b/func/minion/modules/service.py
@@ -24,11 +24,14 @@ class Service(func_module.FuncModule):
def __init__(self):
self.methods = {
- "start" : self.start,
- "stop" : self.stop,
- "restart" : self.restart,
- "reload" : self.reload,
- "status" : self.status
+ "start" : self.start,
+ "stop" : self.stop,
+ "restart" : self.restart,
+ "reload" : self.reload,
+ "status" : self.status,
+ "get_enabled" : self.get_enabled,
+ "get_running" : self.get_running,
+ "inventory" : self.inventory,
}
func_module.FuncModule.__init__(self)
@@ -55,5 +58,32 @@ class Service(func_module.FuncModule):
def status(self, service_name):
return self.__command(service_name, "status")
+ def inventory(self):
+ return {
+ "running" : self.get_running(),
+ "enabled" : self.get_enabled()
+ }
+
+ def get_enabled(self):
+ chkconfig = sub_process.Popen(["/sbin/chkconfig", "--list"], stdout=sub_process.PIPE)
+ data = chkconfig.communicate()[0]
+ results = []
+ for line in data.split("\n"):
+ if line.find("0:") != -1:
+ # regular services
+ tokens = line.split()
+ results.append((tokens[0],tokens[1:]))
+ elif line.find(":") != -1 and not line.endswith(":"):
+ # xinetd.d based services
+ tokens = line.split()
+ tokens[0] = tokens[0].replace(":","")
+ results.append((tokens[0],tokens[1]))
+ return results
+
+ def get_running(self):
+ return {
+
+ }
+
methods = Service()
register_rpc = methods.register_rpc