%PDF- %PDF-
Direktori : /usr/lib/python2.7/site-packages/salt/utils/ |
Current File : //usr/lib/python2.7/site-packages/salt/utils/vt_helper.pyc |
� ���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l Z d d l Z d d l m Z m Z e j d e j � Z e j d � Z e j e � Z d e f d � � YZ d S( 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 ( t absolute_importt print_functiont unicode_literalsN( t Terminalt TerminalExceptionu (?:.*)[Pp]assword(?: for .*)?:u .*\(yes\/no\).*t SSHConnectionc B@ sD e Z d Z d d d e d d e j d d � Z d � Z d � Z RS( u, SSH Connection to a remote server. u saltu passwordu localhostu (Cmd)i u c C@ s} t d j | | | � d t d t d d d t d d d t d t �| _ d } t j | � | _ | | _ x | j j rx| j j � \ } } | rt j | � r| s� t j d � t d � � n | | k r� | j j | | j � | d 7} ql qut d � � ql | rYt j | � rY| rFt j d | � | j j d � ql qu| j j d � ql | rl | j j | � rl Pql ql Wd S( 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' u ssh {0} -l {1} {2}t shellt log_stdoutt log_stdout_levelu tracet log_stderrt log_stderr_levelt stream_stdoutt stream_stderri u Failure while authentication.u0 Permission denied, no authentication informationi u Password authentication failedu Adding %s to known_hostsu yesu noN( R t formatt Truet Falset connt ret compilet prompt_ret linesept has_unread_datat recvt SSH_PASSWORD_PROMPT_REt searcht logt errorR t sendlinet KEY_VALID_REt info( t selft usernamet passwordt hostt key_acceptt promptt passwd_retriesR t ssh_argst sent_passwdt stdoutt stderr( ( s8 /usr/lib/python2.7/site-packages/salt/utils/vt_helper.pyt __init__ s@ c C@ s� | j j | | j � g } g } xz | j j r� | j j � \ } } | r\ | j | � n | r t j d � | j | � n | r% | j j | � r% Pq% q% Wd j | � d j | � f S( 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. u Error while executing command.u ( R R R R R t appendR t debugR R t join( R t cmdt ret_stdoutt ret_stderrR'