%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s6dZddlmZmZmZddlZddlZddlZddl	m
Z
y&ddlmZ
ddlZeZWnek
r�eZnXeje�Zd�Zd�Zd�Zd	�Zd
�Zd�Ze
e�ed��Ze
e�d
��Ze
e�d��Ze
e�d��ZdS(u'
Manage RDP Service on Windows servers
i(tabsolute_importtunicode_literalstprint_functionN(tdepends(terrorcC@s tjjj�rdStdfS(u'
    Only works on Windows systems
    urdpuModule only works on Windows.(tsalttutilstplatformt
is_windowstFalse(((s4/usr/lib/python2.7/site-packages/salt/modules/rdp.pyt__virtual__scC@s9tjd|�}|s"tdfSt|jd��SdS(uP
    return from the input string the return code of the powershell command
    uReturnValue\s*: (\d*)u'Could not parse PowerShell return code.iN(tretsearchR	tinttgroup(tstringtregex((s4/usr/lib/python2.7/site-packages/salt/modules/rdp.pyt_parse_return_code_powershell"s
cC@s,d}tddj||�dddt�S(u�
    Create a Win32_TerminalServiceSetting WMI Object as $RDP and execute the
    command cmd returns the STDOUT of the command
    u�$RDP = Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\CIMV2\TerminalServices -Computer . -Authentication 6 -ErrorAction Stopucmd.runu	{0} ; {1}tshellu
powershelltpython_shell(t__salt__tformattTrue(tcmdtrdp((s4/usr/lib/python2.7/site-packages/salt/modules/rdp.pyt_psrdp.scC@sttd��dkS(uw
    Enable RDP the service on the server

    CLI Example:

    .. code-block:: bash

        salt '*' rdp.enable
    u$RDP.SetAllowTsConnections(1,1)i(RR(((s4/usr/lib/python2.7/site-packages/salt/modules/rdp.pytenable:scC@sttd��dkS(uy
    Disable RDP the service on the server

    CLI Example:

    .. code-block:: bash

        salt '*' rdp.disable
    u$RDP.SetAllowTsConnections(0,1)i(RR(((s4/usr/lib/python2.7/site-packages/salt/modules/rdp.pytdisableIscC@s"ttd�j��}|dkS(uw
    Show if rdp is enabled on the server

    CLI Example:

    .. code-block:: bash

        salt '*' rdp.status
    uecho $RDP.AllowTSConnectionsi(R
Rtstrip(tout((s4/usr/lib/python2.7/site-packages/salt/modules/rdp.pytstatusXsc
C@s�t�}tj}idtj6dtj6dtj6}i
dtj6dtj6dtj6dtj	6dtj
6d	tj6d
tj6dtj
6dtj6d
tj6}x�tj|�D]�}tj||dtj�p�d}tj||dtj�}tj||dtj�}|j|d�}	|j|d�}
|dpAd}i|
d6|	d6|dd6|d6|d6}|r�|r�|j|�q�q�|j|�q�W|s�tjd�nt|dd��S(u9
    List information about the sessions.

    .. versionadded:: 2016.11.0

    :param logged_in_users_only: If True, only return sessions with users logged in.
    :return: A list containing dictionaries of session information.

    CLI Example:

    .. code-block:: bash

        salt '*' rdp.list_sessions
    uconsoleucitrixurdpuactiveu	connectedu
connect_queryushadowudisconnecteduidleulistenuresetudownuinitu	SessionIduunknownuWinStationNameuDisconnecteduconnection_statusuprotocolu
session_idustationuuseruNo sessions found.tkeycS@s|dS(Nu
session_id((tk((s4/usr/lib/python2.7/site-packages/salt/modules/rdp.pyt<lambda>�sN(tlisttwin32tstWTS_CURRENT_SERVER_HANDLEtWTS_PROTOCOL_TYPE_CONSOLEtWTS_PROTOCOL_TYPE_ICAtWTS_PROTOCOL_TYPE_RDPt	WTSActivetWTSConnectedtWTSConnectQueryt	WTSShadowtWTSDisconnectedtWTSIdlet	WTSListentWTSResettWTSDowntWTSInittWTSEnumerateSessionstWTSQuerySessionInformationtWTSUserNametNonetWTSClientProtocolTypetWTSConnectStatetgettappendt_LOGtwarningtsorted(
tlogged_in_users_onlytrettservert	protocolststatusestsessiontusertprotocol_idt	status_idtprotocoltconnection_statuststationtconnection_info((s4/usr/lib/python2.7/site-packages/salt/modules/rdp.pyt
list_sessionsgs<		



cC@skt�}t�}g|D]}|d|kr|^q}|rN|d}n|sgtjd|�n|S(u2
    Get information about a session.

    .. versionadded:: 2016.11.0

    :param session_id: The numeric Id of the session.
    :return: A dictionary of session information.

    CLI Example:

    .. code-block:: bash

        salt '*' rdp.get_session session_id

        salt '*' rdp.get_session 99
    u
session_idiuNo session found for id: %s(tdictRJR:R;(t
session_idR>tsessionstitemRB((s4/usr/lib/python2.7/site-packages/salt/modules/rdp.pytget_session�s		)
cC@sEytjtj|t�Wn$tk
r@}tjd|�tSXtS(uI
    Disconnect a session.

    .. versionadded:: 2016.11.0

    :param session_id: The numeric Id of the session.
    :return: A boolean representing whether the disconnect succeeded.

    CLI Example:

    .. code-block:: bash

        salt '*' rdp.disconnect_session session_id

        salt '*' rdp.disconnect_session 99
    u&Error calling WTSDisconnectSession: %s(R#tWTSDisconnectSessionR$Rt
PyWinErrorR:RR	(RLR((s4/usr/lib/python2.7/site-packages/salt/modules/rdp.pytdisconnect_session�scC@sEytjtj|t�Wn$tk
r@}tjd|�tSXtS(uI
    Initiate the logoff of a session.

    .. versionadded:: 2016.11.0

    :param session_id: The numeric Id of the session.
    :return: A boolean representing whether the logoff succeeded.

    CLI Example:

    .. code-block:: bash

        salt '*' rdp.logoff_session session_id

        salt '*' rdp.logoff_session 99
    u"Error calling WTSLogoffSession: %s(R#tWTSLogoffSessionR$RRQR:RR	(RLR((s4/usr/lib/python2.7/site-packages/salt/modules/rdp.pytlogoff_session�s( t__doc__t
__future__RRRtloggingRtsalt.utils.platformRtsalt.utils.decoratorsRt
pywintypesRRQR#Rt_HAS_WIN32TS_DEPENDENCIEStImportErrorR	t	getLoggert__name__R:R
RRRRRRJRORRRT(((s4/usr/lib/python2.7/site-packages/salt/modules/rdp.pyt<module>s.


								2

Zerion Mini Shell 1.0