Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check service enable state in test mode #29218

Merged
merged 1 commit into from Dec 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 5 additions & 15 deletions salt/states/service.py
Expand Up @@ -298,17 +298,11 @@ def running(name, enable=None, sig=None, init_delay=None, **kwargs):
# See if the service is already running
if before_toggle_status:
ret['comment'] = 'The service {0} is already running'.format(name)
if __opts__['test']:
ret['result'] = True
return ret
if enable is True and not before_toggle_enable_status:
ret.update(_enable(name, None, **kwargs))
return ret
elif enable is False and before_toggle_enable_status:
ret.update(_disable(name, None, **kwargs))
return ret
else:
return ret
return ret

# Run the tests
if __opts__['test']:
Expand Down Expand Up @@ -385,14 +379,10 @@ def dead(name, enable=None, sig=None, **kwargs):
before_toggle_enable_status = __salt__['service.enabled'](name)
if not before_toggle_status:
ret['comment'] = 'The service {0} is already dead'.format(name)
if not __opts__['test']:
if enable is True and not before_toggle_enable_status:
ret.update(_enable(name, None, **kwargs))
elif enable is False and before_toggle_enable_status:
ret.update(_disable(name, None, **kwargs))
return ret
else:
ret['result'] = True
if enable is True and not before_toggle_enable_status:
ret.update(_enable(name, None, **kwargs))
elif enable is False and before_toggle_enable_status:
ret.update(_disable(name, None, **kwargs))
return ret

if __opts__['test']:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/states/service_test.py
Expand Up @@ -151,7 +151,7 @@ def test_dead(self):
{'changes': {},
'comment': 'Service salt was killed', 'name': 'salt',
'result': True},
{'changes': {},
{'changes': 'saltstack',
'comment': 'The service salt is already dead', 'name': 'salt',
'result': True}]

Expand Down