salt.modules.daemontools: added features and removed code

- Mostly pylint griping about no spaces after commas
    - Removed more code than added by 1 line and still managed to
      add an outputter for 1 of the functions
This commit is contained in:
Jeff Schroeder 2012-11-01 20:47:57 -07:00
parent 8e224c8f28
commit 2dd205bbda

View File

@ -7,19 +7,23 @@ service state via provider interface:
- provider: daemontools
'''
# Import Python libs
import os
import re
# Local variable
service_dir="/service"
__outputter__ = {
'get_all': 'yaml',
}
SERVICE_DIR = "/service"
def _service_path(name):
'''
build service path
'''
return '{0}/{1}'.format(service_dir,name)
return '{0}/{1}'.format(SERVICE_DIR, name)
#-- states.service compatible args
def start(name,enable=None,sig=None):
def start(name, enable=None, sig=None):
'''
Starts service via daemontools
@ -32,7 +36,7 @@ def start(name,enable=None,sig=None):
#-- states.service compatible
def stop(name,enable=None,sig=None):
def stop(name, enable=None, sig=None):
'''
Stops service via daemontools
@ -97,7 +101,7 @@ def status(name, sig=None):
'''
cmd = 'svstat {0}'.format(_service_path(name))
ret = __salt__['cmd.run_stdout'](cmd)
m = re.search('\(pid (\d+)\)',ret)
m = re.search('\(pid (\d+)\)', ret)
try:
pid = m.group(1)
except:
@ -113,9 +117,4 @@ def get_all():
salt '*' daemontools.get_all
'''
#- List all daemontools services in
cmd = 'ls {0}/'.format(service_dir)
all_srv = __salt__['cmd.run_stdout'](cmd)
ret=set()
for srv in all_srv.split():
ret.add(srv)
return sorted(ret)
return sorted(os.listdir(SERVICE_DIR))