mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add check for server manager module
This commit is contained in:
parent
4bdae47a44
commit
3270a2859f
1 changed files with 9 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue