[mod] simplify code, give more verbose debug output

This commit is contained in:
Laurent Peuch 2018-05-11 22:20:07 +02:00
parent 1fab47cbea
commit 7435cfdea3

View file

@ -511,11 +511,11 @@ def _run_service_command(action, service):
if service not in services.keys(): if service not in services.keys():
raise MoulinetteError(errno.EINVAL, m18n.n('service_unknown', service=service)) raise MoulinetteError(errno.EINVAL, m18n.n('service_unknown', service=service))
cmd = None possible_actions = ['start', 'stop', 'restart', 'reload', 'enable', 'disable']
if action in ['start', 'stop', 'restart', 'reload', 'enable', 'disable']: if action not in possible_actions:
raise ValueError("Unknown action '%s', available actions are: %s" % (action, ", ".join(possible_actions)))
cmd = 'systemctl %s %s' % (action, service) cmd = 'systemctl %s %s' % (action, service)
else:
raise ValueError("Unknown action '%s'" % action)
need_lock = services[service].get('need_lock', False) \ need_lock = services[service].get('need_lock', False) \
and action in ['start', 'stop', 'restart', 'reload'] and action in ['start', 'stop', 'restart', 'reload']