From 948de0a2f6eed935f7f36954f745569801f5137d Mon Sep 17 00:00:00 2001 From: Colton Myers Date: Fri, 13 Jun 2014 16:18:47 -0600 Subject: [PATCH] Add test mode conditionals to the alternatives state --- salt/states/alternatives.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/salt/states/alternatives.py b/salt/states/alternatives.py index 997800ebe8..e0a2e24232 100644 --- a/salt/states/alternatives.py +++ b/salt/states/alternatives.py @@ -65,6 +65,12 @@ def install(name, link, path, priority): isinstalled = __salt__['alternatives.check_installed'](name, path) if not isinstalled: + if __opts__['test']: + ret['comment'] = ( + 'Alternative will be set for {0} to {1} with priority {2}' + ).format(name, path, priority) + ret['result'] = None + return ret __salt__['alternatives.install'](name, link, path, priority) ret['comment'] = ( 'Setting alternative for {0} to {1} with priority {2}' @@ -100,6 +106,11 @@ def remove(name, path): isinstalled = __salt__['alternatives.check_installed'](name, path) if isinstalled: + if __opts__['test']: + ret['comment'] = ('Alternative for {0} will be removed' + .format(name)) + ret['result'] = None + return ret __salt__['alternatives.remove'](name, path) current = __salt__['alternatives.show_current'](name) if current: @@ -154,6 +165,10 @@ def auto(name): ret['comment'] = '{0} already in auto mode'.format(name) return ret + if __opts__['test']: + ret['comment'] = '{0} will be put in auto mode'.format(name) + ret['result'] = None + return ret ret['changes']['result'] = __salt__['alternatives.auto'](name) return ret @@ -192,6 +207,12 @@ def set_(name, path): break if isinstalled: + if __opts__['test']: + ret['comment'] = ( + 'Alternative for {0} will be set to path {1}' + ).format(name, current) + ret['result'] = None + return ret __salt__['alternatives.set'](name, path) current = __salt__['alternatives.show_current'](name) if current == path: