Package node_manager_fkie :: Module ssh_handler :: Class SSHhandler
[frames] | no frames]

Class SSHhandler

source code

object --+
         |
        SSHhandler

The class to handle the SSH sessions to the remote hosts.

Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
remove(self, host)
Removes an existing ssh session, so the new one can be created.
source code
 
close(self)
Closes all open SSH sessions.
source code
 
transfer(self, host, local_file, remote_file, user=None, pw=None, auto_pw_request=False)
Copies a file to a remote location using paramiko sfpt.
source code
tuple(ChannelFile, ChannelFile, ChannelFile, boolean)
ssh_exec(self, host, cmd, user=None, pw=None, auto_pw_request=False, get_pty=False, close_stdin=False, close_stdout=False, close_stderr=False)
Executes a command on remote host.
source code
 
ssh_x11_exec(self, host, cmd, title=None, user=None)
Executes a command on remote host using a terminal with X11 forwarding.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  SSH_SESSIONS = {}
  SSH_AUTH = {}
Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

close(self)

source code 

Closes all open SSH sessions. Used on the closing the node manager.

transfer(self, host, local_file, remote_file, user=None, pw=None, auto_pw_request=False)

source code 

Copies a file to a remote location using paramiko sfpt.

Parameters:
  • host (str) - the host
  • local_file (str) - the local file
  • remote_file (str) - the remote file name
  • user - user name
  • pw - the password

ssh_exec(self, host, cmd, user=None, pw=None, auto_pw_request=False, get_pty=False, close_stdin=False, close_stdout=False, close_stderr=False)

source code 

Executes a command on remote host. Returns the output channels with execution result or None. The connection will be established using paramiko SSH library.

Parameters:
  • host (str) - the host
  • cmd ([str,...]) - the list with command and arguments
  • user - user name
  • pw - the password
Returns: tuple(ChannelFile, ChannelFile, ChannelFile, boolean)
the 4-tuple stdin, stdout, stderr and boolean of the executing command

ssh_x11_exec(self, host, cmd, title=None, user=None)

source code 

Executes a command on remote host using a terminal with X11 forwarding.

Parameters:
  • host (str) - the host
  • cmd ([str,...]) - the list with command and arguments
  • title (str or None) - the title of the new opened terminal, if it is None, no new terminal will be created
  • user - user name
Returns:
the result of subprocess.Popen(command)

To Do: establish connection using paramiko SSH library.

See Also: http://docs.python.org/library/subprocess.html?highlight=subproces#subprocess