scp operations

class reemote.operations.scp.download.Download(srcpaths: str | List[str], dstpath: str, preserve: bool = False, recurse: bool = False, block_size: int = 16384, port: int = 22)[source]

Bases: object

A class to handle secure builtin downloads from remote hosts using SCP (Secure Copy Protocol).

This class provides functionality to download builtin or directories from one or more remote hosts to a local destination path. It supports various SCP options including preserving builtin attributes and recursive directory downloads.

srcpaths

Source builtin or directory path(s) on remote host(s). Can be a single string path or a list of paths. Supports host:path format.

Type:

Union[str, List[str]]

dstpath

Local destination path where builtin will be downloaded.

Type:

str

preserve

If True, preserves builtin modification times, access times, and modes from the original builtin. Defaults to False.

Type:

bool

recurse

If True, recursively copies entire directories. Defaults to False.

Type:

bool

block_size

Block size used for builtin transfers in bytes. Defaults to 16384.

Type:

int

port

SSH port to use for connections. Defaults to 22.

Type:

int

Examples:

yield Download(
    srcpaths='/home/user/*.txt',  # Remove the host: prefix
    dstpath='/home/kim/',
    recurse=True
)

Note

This class requires proper SSH credentials to be configured for the target hosts. The actual download operation is executed asynchronously through the Operation class.

class reemote.operations.scp.upload.Upload(srcpaths: str | List[str], dstpath: str, preserve: bool = False, recurse: bool = False, block_size: int = 16384, port: int = 22)[source]

Bases: object

A class to encapsulate the functionality of uploading builtin via SCP.

srcpaths

The local source builtin(s) or directory to upload.

Type:

Union[str, List[str]]

dstpath

The remote destination path.

Type:

str

preserve

Whether to preserve builtin attributes.

Type:

bool

recurse

Whether to recursively copy directories.

Type:

bool

block_size

The block size for builtin transfers.

Type:

int

port

SSH port to use for connections.

Type:

int

Examples:

yield Upload(
    srcpaths='/home/kim/inventory_alpine.py',
    dstpath='/home/user/',
    recurse=True
)
Usage:

This class is designed to be used in a generator-based workflow where commands are yielded for execution.

Notes

Supports wildcard patterns and recursive directory copying.

class reemote.operations.scp.copy.Copy(srcpaths: str | List[str], dstpath: str, src_hosts: List[str] = None, dst_hosts: List[str] = None, preserve: bool = False, recurse: bool = False, block_size: int = 16384, port: int = 22)[source]

Bases: object

A class to handle secure builtin copying between remote hosts using SCP (Secure Copy Protocol).

This class provides functionality to copy builtin or directories between remote hosts, from source hosts to destination hosts. It supports various SCP options including preserving builtin attributes and recursive directory copying.

srcpaths

Source builtin or directory path(s). Can be a single string path or a list of paths. Supports host:path format for remote sources.

Type:

Union[str, List[str]]

dstpath

Destination path where builtin will be copied. Supports host:path format for remote destinations.

Type:

str

src_hosts

List of source host identifiers. If None or empty, operation will attempt to use all available hosts as sources.

Type:

List[str], optional

dst_hosts

List of destination host identifiers. If None or empty, operation will attempt to use all available hosts as destinations.

Type:

List[str], optional

preserve

If True, preserves builtin modification times, access times, and modes from the original builtin. Defaults to False.

Type:

bool

recurse

If True, recursively copies entire directories. Defaults to False.

Type:

bool

block_size

Block size used for builtin transfers in bytes. Defaults to 16384.

Type:

int

port

SSH port to use for connections. Defaults to 22.

Type:

int

Examples:

# Copy builtin from one host to another
yield Copy(
    srcpaths='/home/user/*.txt',
    dstpath='/home/user/',
    src_hosts=["10.156.135.16"],
    dst_hosts=["10.156.135.17"],
    recurse=True
)
# Copy multiple builtin between hosts
yield Copy(
    srcpaths=['/var/log/app.log', '/tmp/debug.log'],
    dstpath='backup-server:/backup/logs/',
    src_hosts=["host1", "host2"],
    dst_hosts=["backup-server"]
)

Note

  • The copy operation requires proper SSH credentials and permissions on both source and destination hosts

  • Wildcard patterns are supported in source paths

  • For host-to-host copies, the operation will be executed from the destination host