openbsd-rcctl: use new syntax to speed up listing services

I just introduced a new subcommand to rcctl(8) in OpenBSD that allows
querying for services (all, enabled, disabled, ...) so make salt use it.
This commit is contained in:
Antoine Jacoutot 2015-07-15 05:07:58 +02:00
parent f9b8567c06
commit 487c05f9e6

View File

@ -91,12 +91,9 @@ def get_all():
salt '*' service.get_all
'''
badvar = ("_timeout", "_user")
ret = []
service = _cmd()
for svc in __salt__['cmd.run']('{0} getall'.format(service)).splitlines():
svc = re.sub('(_flags|)=.*$', '', svc)
if not svc.endswith(badvar):
for svc in __salt__['cmd.run']('{0} ls all'.format(service)).splitlines():
ret.append(svc)
return sorted(ret)
@ -111,14 +108,10 @@ def get_disabled():
salt '*' service.get_disabled
'''
badvar = ("_timeout", "_user")
ret = []
service = _cmd()
for svc in __salt__['cmd.run']('{0} getall'.format(service)).splitlines():
if svc.endswith("=NO"):
svc = re.sub('(_flags|)=.*$', '', svc)
if not svc.endswith(badvar):
ret.append(svc)
for svc in __salt__['cmd.run']('{0} ls off'.format(service)).splitlines():
ret.append(svc)
return sorted(ret)
@ -132,14 +125,10 @@ def get_enabled():
salt '*' service.get_enabled
'''
badvar = ("_timeout", "_user")
ret = []
service = _cmd()
for svc in __salt__['cmd.run']('{0} getall'.format(service)).splitlines():
if not svc.endswith("=NO"):
svc = re.sub('(_flags|)=.*$', '', svc)
if not svc.endswith(badvar):
ret.append(svc)
for svc in __salt__['cmd.run']('{0} ls on'.format(service)).splitlines():
ret.append(svc)
return sorted(ret)