Add check for server manager module

This commit is contained in:
twangboy 2016-02-17 14:36:09 -07:00
parent 4bdae47a44
commit 3270a2859f

View file

@ -4,7 +4,6 @@ Manage Windows features via the ServerManager powershell module
'''
from __future__ import absolute_import
import logging
from distutils.version import LooseVersion
# Import python libs
try:
@ -28,13 +27,20 @@ def __virtual__():
return (False, 'Failed to load win_servermanager module:\n'
'Only available on Windows systems.')
if LooseVersion(__grains__['osrelease']) < LooseVersion('6.1'):
if not _check_server_manager():
return (False, 'Failed to load win_servermanager module:\n'
'Only available on Windows 2008R2 and newer.')
'ServerManager module not available\n'
'May need to install Remote Server Administration Tools')
return __virtualname__
def _check_server_manager():
return not __salt__['cmd.retcode']('Import-Module ServerManager',
shell='powershell',
python_shell=True)
def _srvmgr(func):
'''
Execute a function from the ServerManager PS module and return the STDOUT