Fix issue 36679 win_servermanager failure

This commit is contained in:
m03 2016-10-01 19:12:54 -07:00 committed by Loren Gordon
parent c089ac6c67
commit 21c2664b6a

View file

@ -3,8 +3,9 @@
Manage Windows features via the ServerManager powershell module
'''
from __future__ import absolute_import
import logging
import ast
import json
import logging
# Import python libs
try:
@ -24,6 +25,17 @@ def __virtual__():
'''
Load only on windows with servermanager module
'''
def _module_present():
'''
Check for the presence of the ServerManager module.
'''
cmd = r"[Bool] (Get-Module -ListAvailable | Where-Object { $_.Name -eq 'ServerManager' })"
cmd_ret = __salt__['cmd.run_all'](cmd, shell='powershell', python_shell=True)
if cmd_ret['retcode'] == 0:
return ast.literal_eval(cmd_ret['stdout'])
return False
if not salt.utils.is_windows():
return False, 'Failed to load win_servermanager module: ' \
'Only available on Windows systems.'
@ -33,7 +45,7 @@ def __virtual__():
'Requires Remote Server Administration Tools which ' \
'is only available on Windows 2008 R2 and later.'
if not _check_server_manager():
if not _module_present():
return False, 'Failed to load win_servermanager module: ' \
'ServerManager module not available. ' \
'May need to install Remote Server Administration Tools.'