%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/win_servermanager.pyc

�
���^c@@s
dZddlmZmZmZddlZyddlmZWn!e	k
reddl
mZnXddlZddl
ZddlZddlZddlmZeje�ZdZd�Zdd�Zd	�Zd
�Zeeddd�Zeed�ZdS(
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(tabsolute_importtunicode_literalstprint_functionN(tquote(tCommandExecutionErroruwin_servermanagercC@setjjj�stStjjjtdd�dkrBtdfStjjj	d�satdfSt
S(u8
    Load only on windows with servermanager module
    u	osversionu6.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.(tsalttutilstplatformt
is_windowstFalsetversionstversion_cmpt
__grains__t
powershellt
module_existst__virtualname__(((sB/usr/lib/python2.7/site-packages/salt/modules/win_servermanager.pyt__virtual__ s"

cC@sTdj|�}d|j�kr3dj|�}ntjd|�td|ddd|�}d	|kru|d	=n|jd
d�r�|d
j�d}t|d
|��nd|ks�|ddkr�tdj|�d
|��n|ddkrd|d<ny#tj	j
j|ddt�}Wn#t
k
rOtdd
|��nX|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}uconvertto-jsonu{0} | ConvertTo-JsonuPowerShell: %sucmd.run_alltshellu
powershelltcwdupidustderruitinfouretcodeuIssue executing PowerShell {0}ustdoutu{}tstrictuNo JSON results from PowerShell(tformattlowertlogtdebugt__salt__tgett
splitlinesRRRtjsontloadsR	t
ValueError(tcmdRtretterror((sB/usr/lib/python2.7/site-packages/salt/modules/win_servermanager.pyt_pshell_json4s*

#
cC@sd}td|dd�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
    umImport-Module ServerManager; Get-WindowsFeature -ErrorAction SilentlyContinue -WarningAction SilentlyContinueu	cmd.shellRu
powershell(R(R((sB/usr/lib/python2.7/site-packages/salt/modules/win_servermanager.pytlist_availableWscC@sLd}t|�}i}x-|D]%}|dr|d||d<qqW|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
    utGet-WindowsFeature -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Select DisplayName,Name,Installedu	InstalleduDisplayNameuName(R"(RtfeaturesR tentry((sB/usr/lib/python2.7/site-packages/salt/modules/win_servermanager.pytlist_installedls

cC@st|t�r!dj|�}nd}d}tjjjtdd�dkr^d}d}nd	j|t	|�||rd
nd|dkr�dndj|��}t|�}|dk	r�t|�}	n|dr�i|d
d
6t
d6t
d6id6|dd6}
xr|dD]f}i|dd6|dd6|dd6|dd6|dd6|
d|d<|drt|
d<qqWx?|jd�D].}||
dkr�idd6|
d|<q�q�W|dk	rvx�|	dD]�}||
dkr�idd6|	d|dd6|	d|dd6|	d|dd6|	d|dd6|
d|<|	d|drot|
d<qoq�q�Wn|r�|
dr�tddt�r�t|
d<q�q�n|
Si|d
d
6id6t
d6t
d6|dd6}
x,|jd�D]}idd6|
d|<q�W|
SdS(u	
    Install a feature

    .. note::
        Some features require reboot after un/installation, if so until the
        server is restarted other features can not be installed!

    .. note::
        Some features take a long time to complete un/installation, set -t with
        a long timeout

    Args:

        feature (str, list):
            The name of the feature(s) to install. This can be a single feature,
            a string of features in a comma delimited list (no spaces), or a
            list of features.

            .. versionadded:: 2018.3.0
                Added the ability to pass a list of features to be installed.

        recurse (Options[bool]):
            Install all sub-features. Default is False

        restart (Optional[bool]):
            Restarts the computer when installation is complete, if required by
            the role/feature installed. Will also trigger a reboot if an item
            in ``exclude`` requires a reboot to be properly removed. Default is
            False

        source (Optional[str]):
            Path to the source files if missing from the target system. None
            means that the system will use windows update services to find the
            required files. Default is None

        exclude (Optional[str]):
            The name of the feature to exclude when installing the named
            feature. This can be a single feature, a string of features in a
            comma-delimited list (no spaces), or a list of features.

            .. warning::
                As there is no exclude option for the ``Add-WindowsFeature``
                or ``Install-WindowsFeature`` PowerShell commands the features
                named in ``exclude`` will be installed with other sub-features
                and will then be removed. **If the feature named in ``exclude``
                is not a sub-feature of one of the installed items it will still
                be removed.**

    Returns:
        dict: A dictionary containing the results of the install

    CLI Example:

    .. code-block:: bash

        # Install the Telnet Client passing a single string
        salt '*' win_servermanager.install Telnet-Client

        # Install the TFTP Client and the SNMP Service passing a comma-delimited
        # string. Install all sub-features
        salt '*' win_servermanager.install TFTP-Client,SNMP-Service recurse=True

        # Install the TFTP Client from d:\side-by-side
        salt '*' win_servermanager.install TFTP-Client source=d:\\side-by-side

        # Install the XPS Viewer, SNMP Service, and Remote Access passing a
        # list. Install all sub-features, but exclude the Web Server
        salt '*' win_servermanager.install "['XPS-Viewer', 'SNMP-Service', 'RemoteAccess']" True recurse=True exclude="Web-Server"
    u,uAdd-WindowsFeatureuu	osversionu6.2iuInstall-WindowsFeatureu-IncludeManagementToolsu9{0} -Name {1} {2} {3} {4} -WarningAction SilentlyContinueu-IncludeAllSubFeatureu-Source {0}u
FeatureResultuExitCodeu
RestartNeededu	RestarteduFeaturesuSuccessuDisplayNameuMessageu
SkipReasonuNameuAlready installedu$Removed after installation (exclude)usystem.restartt
in_secondsN(t
isinstancetlisttjoinRRR
RRRt
_cmd_quotetNoneR"tremoveR	tTruetsplitR(tfeaturetrecursetrestarttsourcetexcludetcommandtmanagement_toolsRtouttremovedR titem((sB/usr/lib/python2.7/site-packages/salt/modules/win_servermanager.pytinstall�spG"	$


cC@s7t|t�r!dj|�}nd}d}d}tjjjtdd�dkrsd}d}|rsd	}qsnd
j|t	|�|||r�dnd�}yt
|�}Wn=tk
r�}d|jkr�td
d|j
��n�nX|dr�i|dd6td6td6id6|dd6}	x[|dD]O}
i|
dd6|
dd6|
dd6|
dd6|
dd6|	d|
d<q6Wx?|jd�D].}
|
|	dkr�idd6|	d|
<q�q�W|	Si|dd6id6td6td6|dd6}	x,|jd�D]}
idd6|	d|
<qW|	SdS(u
    Remove an installed feature

    .. note::
        Some features require a reboot after installation/uninstallation. If
        one of these features are modified, then other features cannot be
        installed until the server is restarted. Additionally, some features
        take a while to complete installation/uninstallation, so it is a good
        idea to use the ``-t`` option to set a longer timeout.

    Args:

        feature (str, list):
            The name of the feature(s) to remove. This can be a single feature,
            a string of features in a comma delimited list (no spaces), or a
            list of features.

            .. versionadded:: 2018.3.0
                Added the ability to pass a list of features to be removed.

        remove_payload (Optional[bool]):
            True will cause the feature to be removed from the side-by-side
            store (``%SystemDrive%:\Windows\WinSxS``). Default is False

        restart (Optional[bool]):
            Restarts the computer when uninstall is complete, if required by the
            role/feature removed. Default is False

    Returns:
        dict: A dictionary containing the results of the uninstall

    CLI Example:

    .. code-block:: bash

        salt -t 600 '*' win_servermanager.remove Telnet-Client
    u,uRemove-WindowsFeatureuu	osversionu6.2iuUninstall-WindowsFeatureu-IncludeManagementToolsu-Removeu9{0} -Name {1} {2} {3} {4} -WarningAction SilentlyContinueu-RestartuArgumentNotValiduInvalid Feature NameRu
FeatureResultuExitCodeu
RestartNeededu	RestarteduFeaturesuSuccessuDisplayNameuMessageu
SkipReasonuNameu
Not installedN(R(R)R*RRR
RRRR+R"RtmessageRR	R/(R0tremove_payloadR2R5R6t_remove_payloadRR7texcR R9((sB/usr/lib/python2.7/site-packages/salt/modules/win_servermanager.pyR--sZ'"
(t__doc__t
__future__RRRtloggingtshlexRR+tImportErrortpipestsalt.utils.jsonRtsalt.utils.platformtsalt.utils.powershelltsalt.utils.versionstsalt.exceptionsRt	getLoggert__name__RRRR,R"R#R&R	R:R-(((sB/usr/lib/python2.7/site-packages/salt/modules/win_servermanager.pyt<module>	s&
	#		�

Zerion Mini Shell 1.0