calypso.dispatchers.orchestrator.executor.ssh module

class calypso.dispatchers.orchestrator.executor.ssh.SSHClient(host, username, port=22, password=None, key_filename=None)

Bases: object

SSHClient class for managing SSH connections and file transfers.

Parameters:
  • host (str) – SSH server hostname or IP address.

  • username (str) – SSH username.

  • password (str, optional) – SSH password, by default None.

  • key_filename (str, optional) – SSH private key file path, by default None.

connect()

Establishes an SSH connection and SFTP session.

disconnect()

Closes the SSH and SFTP connections.

download_file(remote_file, local_file)

Downloads a file from the SSH server.

Parameters:
  • remote_file (str) – Path to the remote file.

  • local_file (str) – Path to the local file.

execute_command(command, timeout=3600)

Executes a command on the SSH server.

Parameters:
  • command (str) – Command to be executed.

  • timeout (int, optional) – Timeout in seconds, by default 3600.

Returns:

stdout, stderr, and return code of the executed command.

Return type:

tuple

file_exist(filename)
files_exist(remote_path, filenames)

Checks if files exist on the SSH server.

Parameters:
  • remote_path (str) – Path to the remote directory.

  • filenames (list of str) – List of filenames to check.

Returns:

True if all files exist, False otherwise.

Return type:

bool

get_file_obj(remote_file_name, mode='r')
mkdir(remote_path)

Creates a directory on the SSH server.

Parameters:

remote_path (str) – Path to the remote directory.

read_file(remote_file_name)
remote_rglob(remote_dir, pattern)
upload_file(local_file, remote_file)

Uploads a file to the SSH server.

Parameters:
  • local_file (str) – Path to the local file.

  • remote_file (str) – Path to the remote file.

write_file(data, remote_file_name)
class calypso.dispatchers.orchestrator.executor.ssh.SSHExecutor(name, host=None, port=None, username=None, password=None, key_filename=None, **kwargs)

Bases: BaseExecutor

SSHExecutor class for managing job execution and file transfers over SSH.

Parameters:
  • name (str) – Name of the executor.

  • host (str) – SSH server hostname or IP address.

  • username (str) – SSH username.

  • password (str, optional) – SSH password, by default None.

  • key_filename (str, optional) – SSH private key file path, by default None.

download_job(job: Job)

Downloads job files from the SSH server.

Parameters:

job (dict) – Dictionary containing job details.

download_remote_file(remote_file_name: str | Path, local_file_name: str | Path)
execute(command, timeout=3600, log_file=None)

Executes a command on the SSH server.

Parameters:
  • command (str) – Command to be executed.

  • timeout (int, optional) – Timeout in seconds, by default 3600.

Returns:

Contains output, error, and return code of the executed command.

Return type:

ProcInfo

files_exist(base_path, filenames, remote=True)
get_remote_file_obj(remote_file_name: str | Path, mode='r')
locally_files_exist(base_path, filenames)

Checks if files exist locally.

Parameters:
  • base_path (str) – Path to the local directory.

  • filenames (list of str) – List of filenames to check.

Returns:

True if all files exist, False otherwise.

Return type:

bool

locally_rglob(remote_dir, pattern)
make_remote_dir(remote_dir_name: str | Path)
read_remote_file(remote_file_name: str | Path)
remote_file_exist(remote_file_name: str | Path)
rglob(remote_dir, pattern, remote=True)
upload_file_to_remote(local_filename: str | Path, remote_filename: str | Path)
upload_job(job: Job)

Uploads job files to the SSH server.

Parameters:

job (dict) – Dictionary containing job details.

write_into_remote_file(data, remote_file_name: str | Path)