mlos_bench.services.remote.ssh package

SSH remote service.

class mlos_bench.services.remote.ssh.SshFileShareService(config: Dict[str, Any] | None = None, global_config: Dict[str, Any] | None = None, parent: Service | None = None, methods: Dict[str, Callable] | List[Callable] | None = None)

Bases: FileShareService, SshService

A collection of functions for interacting with SSH servers as file shares.

Attributes:
config_loader_service

Return a config loader service.

Methods

clear_client_cache()

Clears the cache of client connections.

download(params, remote_path, local_path[, ...])

Downloads contents from a remote share path to a local path.

export()

Return a dictionary of functions available in this service.

merge_methods(ext_methods, local_methods)

Merge methods from the external caller with the local ones.

new(class_name[, config, global_config, parent])

Factory method for a new service with a given config.

pprint()

Produce a human-readable string listing all public methods of the service.

register(services)

Register new mix-in services.

upload(params, local_path, remote_path[, ...])

Uploads contents from a local path to remote share path.

download(params: dict, remote_path: str, local_path: str, recursive: bool = True) None

Downloads contents from a remote share path to a local path.

Parameters:
paramsdict

Flat dictionary of (key, value) pairs of (optional) connection details.

remote_pathstr

Path to download from the remote file share, a file if recursive=False or a directory if recursive=True.

local_pathstr

Path to store the downloaded content to.

recursivebool

If False, ignore the subdirectories; if True (the default), download the entire directory tree.

upload(params: dict, local_path: str, remote_path: str, recursive: bool = True) None

Uploads contents from a local path to remote share path.

Parameters:
paramsdict

Flat dictionary of (key, value) pairs of (optional) connection details.

local_pathstr

Path to the local directory to upload contents from.

remote_pathstr

Path in the remote file share to store the uploaded content to.

recursivebool

If False, ignore the subdirectories; if True (the default), upload the entire directory tree.

class mlos_bench.services.remote.ssh.SshHostService(config: Dict[str, Any] | None = None, global_config: Dict[str, Any] | None = None, parent: Service | None = None, methods: Dict[str, Callable] | List[Callable] | None = None)

Bases: SshService, SupportsOSOps, SupportsRemoteExec

Helper methods to manage machines via SSH.

Attributes:
config_loader_service

Return a config loader service.

Methods

clear_client_cache()

Clears the cache of client connections.

export()

Return a dictionary of functions available in this service.

get_remote_exec_results(config)

Get the results of the asynchronously running command.

merge_methods(ext_methods, local_methods)

Merge methods from the external caller with the local ones.

new(class_name[, config, global_config, parent])

Factory method for a new service with a given config.

pprint()

Produce a human-readable string listing all public methods of the service.

reboot(params[, force])

Initiates a (graceful) shutdown of the Host/VM OS.

register(services)

Register new mix-in services.

remote_exec(script, config, env_params)

Start running a command on remote host OS.

shutdown(params[, force])

Initiates a (graceful) shutdown of the Host/VM OS.

wait_os_operation(params)

Waits for a pending operation on an OS to resolve to SUCCEEDED or FAILED.

get_remote_exec_results(config: dict) Tuple[Status, dict]

Get the results of the asynchronously running command.

Parameters:
configdict

Flat dictionary of (key, value) pairs of tunable parameters. Must have the “asyncRemoteExecResultsFuture” key to get the results. If the key is not present, return Status.PENDING.

Returns:
result(Status, dict)

A pair of Status and result. Status is one of {PENDING, SUCCEEDED, FAILED, TIMED_OUT}

reboot(params: dict, force: bool = False) Tuple[Status, dict]

Initiates a (graceful) shutdown of the Host/VM OS.

Parameters:
params: dict

Flat dictionary of (key, value) pairs of tunable parameters.

forcebool

If True, force restart the Host/VM.

Returns:
result(Status, dict={})

A pair of Status and result. Status is one of {PENDING, SUCCEEDED, FAILED}

remote_exec(script: Iterable[str], config: dict, env_params: dict) Tuple[Status, dict]

Start running a command on remote host OS.

Parameters:
scriptIterable[str]

A list of lines to execute as a script on a remote VM.

configdict

Flat dictionary of (key, value) pairs of parameters. They usually come from const_args and tunable_params properties of the Environment.

env_paramsdict

Parameters to pass as shell environment variables into the script. This is usually a subset of config with some possible conversions.

Returns:
result(Status, dict)

A pair of Status and result. Status is one of {PENDING, SUCCEEDED, FAILED}

shutdown(params: dict, force: bool = False) Tuple[Status, dict]

Initiates a (graceful) shutdown of the Host/VM OS.

Parameters:
params: dict

Flat dictionary of (key, value) pairs of tunable parameters.

forcebool

If True, force stop the Host/VM.

Returns:
result(Status, dict={})

A pair of Status and result. Status is one of {PENDING, SUCCEEDED, FAILED}

wait_os_operation(params: dict) Tuple[Status, dict]

Waits for a pending operation on an OS to resolve to SUCCEEDED or FAILED. Return TIMED_OUT when timing out.

Parameters:
params: dict

Flat dictionary of (key, value) pairs of tunable parameters. Must have the “asyncRemoteExecResultsFuture” key to get the results. If the key is not present, return Status.PENDING.

Returns:
result(Status, dict)

A pair of Status and result. Status is one of {PENDING, SUCCEEDED, FAILED, TIMED_OUT} Result is info on the operation runtime if SUCCEEDED, otherwise {}.

Submodules