mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Report powershell output instead of error
This commit is contained in:
parent
b99484fde2
commit
144bff2f67
2 changed files with 12 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -49,8 +49,14 @@ 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 the feature: {0}'.format(ret['changes']['feature']['ExitCode'])
|
||||
else:
|
||||
ret['result'] = False
|
||||
ret['comment'] = 'Failed to install {0}.\nError Message:\n{1}'.format(name, ret['changes']['feature']['message'])
|
||||
ret['changes'] = {}
|
||||
|
||||
return ret
|
||||
|
|
Loading…
Add table
Reference in a new issue