Merge pull request #24690 from twangboy/fix_17041

Report powershell output instead of error
This commit is contained in:
Shane Lee 2015-06-17 10:33:49 -06:00
commit 59db24602f
2 changed files with 15 additions and 4 deletions

View file

@ -36,6 +36,8 @@ def _srvmgr(func):
def _parse_powershell_list(lst):
'''
Parse command output when piped to format-list
Need to look at splitting with ':' so you can get the full value
Need to check for error codes and return false if it's trying to parse
'''
ret = {}
for line in lst.splitlines():
@ -46,6 +48,7 @@ def _parse_powershell_list(lst):
# baz}
if len(splt) > 2:
ret[splt[0]] = splt[2]
ret['message'] = lst
return ret

View file

@ -38,7 +38,7 @@ def installed(name, recurse=False, force=False):
if name not in __salt__['win_servermanager.list_installed']():
ret['changes'] = {'feature': '{0} will be installed recurse={1}'.format(name, recurse)}
elif force and recurse:
ret['changes'] = {'feature': 'already installed but might install sub-features'.format(name)}
ret['changes'] = {'feature': '{0} already installed but might install sub-features'.format(name)}
else:
ret['comment'] = 'The feature {0} is already installed'.format(name)
return ret
@ -49,8 +49,16 @@ def installed(name, recurse=False, force=False):
# Install the features
ret['changes'] = {'feature': __salt__['win_servermanager.install'](name, recurse)}
ret['result'] = ret['changes']['feature']['Success'] == 'True'
if not ret['result']:
ret['comment'] = 'failed to install the feature: {0}'.format(ret['changes']['feature']['ExitCode'])
if 'Success' in ret['changes']['feature']:
ret['result'] = ret['changes']['feature']['Success'] == 'True'
if not ret['result']:
ret['comment'] = 'Failed to install {0}: {1}'.format(name, ret['changes']['feature']['ExitCode'])
else:
ret['comment'] = 'Installed {0}'.format(name)
else:
ret['result'] = False
ret['comment'] = 'Failed to install {0}.\nError Message:\n{1}'.format(name, ret['changes']['feature']['message'])
ret['changes'] = {}
return ret