mlos_bench.services.remote.ssh.ssh_host_service module

A collection Service functions for managing hosts via SSH.

class mlos_bench.services.remote.ssh.ssh_host_service.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 {}.