twindb_backup.ssh package¶
Submodules¶
twindb_backup.ssh.client module¶
Module that implements SSH client.
-
class
twindb_backup.ssh.client.
SshClient
(host='127.0.0.1', port=22, key='/root/.id_rsa', user='root')[source]¶ Bases:
object
SSH client class. Allows to connect to a remote SSH server and execute commands on it.
- Parameters
host (str) – Destination host to connect to. Detaults to ‘127.0.0.1’.
port (int) – Destination port to connect to. Default is 22.
key (str) – SSH client key for passwordless authentication. Default is ‘/root/.id_rsa’.
user (str) – SSH client username. Default is ‘root’.
-
execute
(cmd, quiet=False, background=False)[source]¶ Execute a command on a remote SSH server.
- Parameters
cmd (str) – Command for execution.
quiet – if quiet is True don’t print error messages
background (bool) – Don’t wait until the command exits.
- Returns
Strings with stdout and stderr. If command is executed in background the method will return None.
- Return type
tuple
- Raises
SshClientException – if any error or non-zero exit code
-
get_remote_handlers
(cmd)[source]¶ Get remote stdin, stdout and stderr handler
- Parameters
cmd (str) – Command for execution
- Returns
Remote stdin, stdout and stderr handler
- Return type
tuple(generator, generator, generator)
- Raises
SshDestinationError – if any error
-
get_text_content
(path)[source]¶ Get text content of file by path
- Parameters
path (str) – File path
- Returns
File content
- Return type
str
-
property
host
¶ Remote SSH host
-
list_files
(path, recursive=False, files_only=False)[source]¶ Get list of file by prefix
- Parameters
path (str) – Path
recursive (bool) – Recursive return list of files
files_only (bool) – Don’t list directories if True. Default is False.
- Returns
List of files
- Return type
list
-
property
port
¶ TCP port for SSH connection
-
property
user
¶ User for SSH connection
twindb_backup.ssh.exceptions module¶
SSH Client Exceptions.
-
exception
twindb_backup.ssh.exceptions.
SshClientException
[source]¶ Bases:
twindb_backup.exceptions.TwinDBBackupError
Exception in SshClient