mlos_bench.services.remote.ssh.ssh_host_service
===============================================

.. py:module:: mlos_bench.services.remote.ssh.ssh_host_service

.. autoapi-nested-parse::

   A collection Service functions for managing hosts via SSH.



Classes
-------

.. autoapisummary::

   mlos_bench.services.remote.ssh.ssh_host_service.SshHostService


Module Contents
---------------

.. py:class:: 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, collections.abc.Callable] | list[collections.abc.Callable] | None = None)

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


   Helper methods to manage machines via SSH.

   Create a new instance of an SSH Service.

   :param config: Free-format dictionary that contains the benchmark environment
                  configuration.
   :type config: dict
   :param global_config: Free-format dictionary of global parameters.
   :type global_config: dict
   :param parent: Parent service that can provide mixin functions.
   :type parent: Service
   :param methods: New methods to register with the service.
   :type methods: Union[dict[str, Callable], list[Callable], None]


   .. py:method:: get_remote_exec_results(config: dict) -> tuple[mlos_bench.environments.status.Status, dict]

      Get the results of the asynchronously running command.

      :param config: 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.
      :type config: dict

      :returns: **result** -- A pair of Status and result.
                Status is one of {PENDING, SUCCEEDED, FAILED, TIMED_OUT}
      :rtype: (Status, dict)



   .. py:method:: reboot(params: dict, force: bool = False) -> tuple[mlos_bench.environments.status.Status, dict]

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

      :param params: Flat dictionary of (key, value) pairs of tunable parameters.
      :type params: dict
      :param force: If True, force restart the Host/VM.
      :type force: bool

      :returns: **result** -- A pair of Status and result.
                Status is one of {PENDING, SUCCEEDED, FAILED}
      :rtype: (Status, dict)



   .. py:method:: remote_exec(script: collections.abc.Iterable[str], config: dict, env_params: dict) -> tuple[mlos_bench.environments.status.Status, dict]

      Start running a command on remote host OS.

      :param script: A list of lines to execute as a script on a remote VM.
      :type script: Iterable[str]
      :param config: Flat dictionary of (key, value) pairs of parameters.
                     They usually come from `const_args` and `tunable_params`
                     properties of the Environment.
      :type config: dict
      :param env_params: Parameters to pass as *shell* environment variables into the script.
                         This is usually a subset of `config` with some possible conversions.
      :type env_params: dict

      :returns: **result** -- A pair of Status and result.
                Status is one of {PENDING, SUCCEEDED, FAILED}
      :rtype: (Status, dict)



   .. py:method:: shutdown(params: dict, force: bool = False) -> tuple[mlos_bench.environments.status.Status, dict]

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

      :param params: Flat dictionary of (key, value) pairs of tunable parameters.
      :type params: dict
      :param force: If True, force stop the Host/VM.
      :type force: bool

      :returns: **result** -- A pair of Status and result.
                Status is one of {PENDING, SUCCEEDED, FAILED}
      :rtype: (Status, dict)



   .. py:method:: wait_os_operation(params: dict) -> tuple[mlos_bench.environments.status.Status, dict]

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

      :param params: 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.
      :type params: dict

      :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 {}.
      :rtype: (Status, dict)