mlos_bench.services.remote.ssh.ssh_host_service

A collection Service functions for managing hosts via SSH.

Classes

SshHostService

Helper methods to manage machines via SSH.

Module Contents

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

Bases: mlos_bench.services.remote.ssh.ssh_service.SshService, mlos_bench.services.types.os_ops_type.SupportsOSOps, mlos_bench.services.types.remote_exec_type.SupportsRemoteExec

Helper methods to manage machines via SSH.

Create a new instance of an SSH Service.

Parameters:
  • config (dict) – Free-format dictionary that contains the benchmark environment configuration.

  • global_config (dict) – Free-format dictionary of global parameters.

  • parent (Service) – Parent service that can provide mixin functions.

  • methods (Union[Dict[str, Callable], List[Callable], None]) – New methods to register with the service.

get_remote_exec_results(config: dict) Tuple[mlos_bench.environments.status.Status, dict][source]

Get the results of the asynchronously running command.

Parameters:

config (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 – A pair of Status and result. Status is one of {PENDING, SUCCEEDED, FAILED, TIMED_OUT}

Return type:

(Status, dict)

reboot(params: dict, force: bool = False) Tuple[mlos_bench.environments.status.Status, dict][source]

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

Parameters:
  • params (dict) – Flat dictionary of (key, value) pairs of tunable parameters.

  • force (bool) – If True, force restart the Host/VM.

Returns:

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

Return type:

(Status, dict)

remote_exec(script: Iterable[str], config: dict, env_params: dict) Tuple[mlos_bench.environments.status.Status, dict][source]

Start running a command on remote host OS.

Parameters:
  • script (Iterable[str]) – A list of lines to execute as a script on a remote VM.

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

  • env_params (dict) – Parameters to pass as shell environment variables into the script. This is usually a subset of config with some possible conversions.

Returns:

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

Return type:

(Status, dict)

shutdown(params: dict, force: bool = False) Tuple[mlos_bench.environments.status.Status, dict][source]

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

Parameters:
  • params (dict) – Flat dictionary of (key, value) pairs of tunable parameters.

  • force (bool) – If True, force stop the Host/VM.

Returns:

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

Return type:

(Status, dict)

wait_os_operation(params: dict) Tuple[mlos_bench.environments.status.Status, dict][source]

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 – 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 {}.

Return type:

(Status, dict)