%PDF- %PDF-
Direktori : /usr/lib/python2.7/site-packages/salt/modules/ |
Current File : //usr/lib/python2.7/site-packages/salt/modules/win_servermanager.pyc |
� ���^c @@ s d Z d d l m Z m Z m Z d d l Z y d d l m Z Wn! e k re d d l m Z n Xd d l Z d d l Z d d l Z d d l Z d d l m Z e j e � Z d Z d � Z d d � Z d � Z d � Z e e d d d � Z e e d � Z d S( u/ Manage Windows features via the ServerManager powershell module. Can list available and installed roles/features. Can install and remove roles/features. :maintainer: Shane Lee <slee@saltstack.com> :platform: Windows Server 2008R2 or greater :depends: PowerShell module ``ServerManager`` i ( t absolute_importt unicode_literalst print_functionN( t quote( t CommandExecutionErroru win_servermanagerc C@ se t j j j � s t St j j j t d d � d k rB t d f St j j j d � sa t d f St S( u8 Load only on windows with servermanager module u osversionu 6.1.7600i����u� Failed to load win_servermanager module: Requires Remote Server Administration Tools which is only available on Windows 2008 R2 and later.u ServerManageru� Failed to load win_servermanager module: ServerManager module not available. May need to install Remote Server Administration Tools.( t saltt utilst platformt is_windowst Falset versionst version_cmpt __grains__t powershellt module_existst __virtualname__( ( ( sB /usr/lib/python2.7/site-packages/salt/modules/win_servermanager.pyt __virtual__ s " c C@ sT d j | � } d | j � k r3 d j | � } n t j d | � t d | d d d | �} d | k ru | d =n | j d d � r� | d j � d } t | d | �� n d | k s� | d d k r� t d j | � d | �� n | d d k rd | d <n y# t j j j | d d t �} Wn# t k rOt d d | �� n X| S( u} Execute the desired powershell command and ensure that it returns data in JSON format and load that into python u Import-Module ServerManager; {0}u convertto-jsonu {0} | ConvertTo-Jsonu PowerShell: %su cmd.run_allt shellu powershellt cwdu pidu stderru i t infou retcodeu Issue executing PowerShell {0}u stdoutu {}t strictu No JSON results from PowerShell( t formatt lowert logt debugt __salt__t gett splitlinesR R R t jsont loadsR t ValueError( t cmdR t rett error( ( sB /usr/lib/python2.7/site-packages/salt/modules/win_servermanager.pyt _pshell_json4 s* # c C@ s d } t d | d d �S( u List available features to install Returns: str: A list of available features as returned by the ``Get-WindowsFeature`` PowerShell command CLI Example: .. code-block:: bash salt '*' win_servermanager.list_available um Import-Module ServerManager; Get-WindowsFeature -ErrorAction SilentlyContinue -WarningAction SilentlyContinueu cmd.shellR u powershell( R ( R ( ( sB /usr/lib/python2.7/site-packages/salt/modules/win_servermanager.pyt list_availableW s c C@ sL d } t | � } i } x- | D]% } | d r | d | | d <q q W| S( u� List installed features. Supported on Windows Server 2008 and Windows 8 and newer. Returns: dict: A dictionary of installed features CLI Example: .. code-block:: bash salt '*' win_servermanager.list_installed ut Get-WindowsFeature -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Select DisplayName,Name,Installedu Installedu DisplayNameu Name( R"