%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlm	Z	m
Z
ejdej�Z
ejd�Zeje�Zdefd��YZdS(	u�
    salt.utils.vt_helper
    ~~~~~~~~~~~~~~~~~~~~

    VT Helper

    This module provides the SSHConnection to expose an SSH connection object
    allowing users to programmatically execute commands on a remote server using
    Salt VT.
i(tabsolute_importtprint_functiontunicode_literalsN(tTerminaltTerminalExceptionu(?:.*)[Pp]assword(?: for .*)?:u.*\(yes\/no\).*t
SSHConnectionc	B@sDeZdZdddeddejdd�Zd�Zd	�ZRS(
u,
    SSH Connection to a remote server.
    usaltupasswordu	localhostu(Cmd)iuc	C@s}tdj|||�dtdtdddtdddtd	t�|_d
}	tj|�|_||_x
|jj	rx|jj
�\}
}|
rtj|
�r|s�t
jd�td��n|	|kr�|jj||j�|	d
7}	qlqutd��ql|
rYtj|
�rY|rFt
jd|�|jjd�qlqu|jjd�ql|
rl|jj|
�rlPqlqlWdS(u�
        Establishes a connection to the remote server.

        The format for parameters is:

        username (string): The username to use for this
            ssh connection. Defaults to root.
        password (string): The password to use for this
            ssh connection. Defaults to password.
        host (string): The host to connect to.
            Defaults to localhost.
        key_accept (boolean): Should we accept this host's key
            and add it to the known_hosts file? Defaults to False.
        prompt (string): The shell prompt (regex) on the server.
            Prompt is compiled into a regular expression.
            Defaults to (Cmd)
        passwd_retries (int): How many times should I try to send the password?
            Defaults to 3.
        linesep (string): The line separator to use when sending
            commands to the server. Defaults to os.linesep.
        ssh_args (string): Extra ssh args to use with ssh.
             Example: '-o PubkeyAuthentication=no'
        ussh {0} -l {1} {2}tshellt
log_stdouttlog_stdout_levelutracet
log_stderrtlog_stderr_levelt
stream_stdoutt
stream_stderriuFailure while authentication.u0Permission denied, no authentication informationiuPassword authentication faileduAdding %s to known_hostsuyesunoN(RtformattTruetFalsetconntretcompilet	prompt_retlinesepthas_unread_datatrecvtSSH_PASSWORD_PROMPT_REtsearchtlogterrorRtsendlinetKEY_VALID_REtinfo(tselftusernametpasswordthostt
key_accepttprompttpasswd_retriesRtssh_argstsent_passwdtstdouttstderr((s8/usr/lib/python2.7/site-packages/salt/utils/vt_helper.pyt__init__ s@ 	

cC@s�|jj||j�g}g}xz|jjr�|jj�\}}|r\|j|�n|rtjd�|j|�n|r%|jj	|�r%Pq%q%Wdj
|�dj
|�fS(u�
        Send this command to the server and
        return a tuple of the output and the stderr.

        The format for parameters is:

        cmd (string): The command to send to the sever.
        uError while executing command.u(RRRRRtappendRtdebugRRtjoin(Rtcmdt
ret_stdoutt
ret_stderrR'R(((s8/usr/lib/python2.7/site-packages/salt/utils/vt_helper.pyRks	
cC@s|jjdtdt�dS(u-
        Close the server connection
        t	terminatetkillN(RtcloseR(R((s8/usr/lib/python2.7/site-packages/salt/utils/vt_helper.pytclose_connection�s(	t__name__t
__module__t__doc__RtosRR)RR3(((s8/usr/lib/python2.7/site-packages/salt/utils/vt_helper.pyRsC	(R6t
__future__RRRtloggingR7Rt
salt.utils.vtRRRtMRRt	getLoggerR4RtobjectR(((s8/usr/lib/python2.7/site-packages/salt/utils/vt_helper.pyt<module>s

Zerion Mini Shell 1.0