pytest_mh.utils.services

Classes

SystemdServices(*args, **kwargs)

Manage remote services.

class pytest_mh.utils.services.SystemdServices(*args, **kwargs)

Bases: MultihostReentrantUtility[MultihostHost]

Manage remote services.

Find all MultihostUtility objects in the constructor.

async_start(service: str) Process

Start a systemd unit. Non-blocking call.

systemctl status $unit is called automatically if the unit can not be started. The status is then visible in the logs.

Parameters:

service (str) – Unit name.

Returns:

Running SSH process.

Return type:

Process

start(service: str, raise_on_error: bool = True) ProcessResult

Start a systemd unit. The call will wait until the operation is finished.

systemctl status $unit is called automatically if the unit can not be started. The status is then visible in the logs.

Parameters:
  • service (str) – Unit name.

  • raise_on_error (bool, optional) – Raise exception on error, defaults to True

Returns:

SSH process result.

Return type:

ProcessResult

async_stop(service: str) Process

Stop a systemd unit. Non-blocking call.

systemctl status $unit is called automatically if the unit can not be stopped. The status is then visible in the logs.

Parameters:

service (str) – Unit name.

Returns:

Running SSH process.

Return type:

Process

stop(service: str, raise_on_error: bool = True) ProcessResult

Stop a systemd unit. The call will wait until the operation is finished.

systemctl status $unit is called automatically if the unit can not be stoped. The status is then visible in the logs.

Parameters:
  • service (str) – Unit name.

  • raise_on_error (bool, optional) – Raise exception on error, defaults to True

Returns:

SSH process result.

Return type:

ProcessResult

async_restart(service: str) Process

Restart a systemd unit. Non-blocking call.

systemctl status $unit is called automatically if the unit can not be restarted. The status is then visible in the logs.

Parameters:

service (str) – Unit name.

Returns:

Running SSH process.

Return type:

Process

restart(service: str, raise_on_error: bool = True) ProcessResult

Restart a systemd unit. The call will wait until the operation is finished.

systemctl status $unit is called automatically if the unit can not be restarted. The status is then visible in the logs.

Parameters:
  • service (str) – Unit name.

  • raise_on_error (bool, optional) – Raise exception on error, defaults to True

Returns:

SSH process result.

Return type:

ProcessResult

async_reload(service: str) Process

Reload a systemd unit. Non-blocking call.

systemctl status $unit is called automatically if the unit can not be reloaded. The status is then visible in the logs.

Parameters:

service (str) – Unit name.

Returns:

Running SSH process.

Return type:

Process

reload(service: str, raise_on_error: bool = True) ProcessResult

Reload a systemd unit. The call will wait until the operation is finished.

systemctl status $unit is called automatically if the unit can not be reloaded. The status is then visible in the logs.

Parameters:
  • service (str) – Unit name.

  • raise_on_error (bool, optional) – Raise exception on error, defaults to True

Returns:

SSH process result.

Return type:

ProcessResult

async_status(service: str) Process

Get systemd unit status. Non-blocking call.

Parameters:

service (str) – Unit name.

Returns:

Running SSH process.

Return type:

Process

status(service: str, raise_on_error: bool = True) ProcessResult

Get systemd unit status. The call will wait until the operation is finished.

Parameters:
  • service (str) – Unit name.

  • raise_on_error (bool, optional) – Raise exception on error, defaults to True

Returns:

SSH process result.

Return type:

ProcessResult

async_get_property(service: str, prop: str) Process

Get property of systemd unit. Non-blocking call.

Parameters:
  • service (str) – Unit name.

  • prop (str) – Propery name.

Returns:

Running SSH process.

Return type:

Process

get_property(service: str, prop: str, raise_on_error: bool = True) str

Get property of systemd unit. The call will wait until the operation is finished.

Parameters:
  • service (str) – Unit name.

  • prop (str) – Propery name.

  • raise_on_error (bool, optional) – Raise exception on error, defaults to True

Returns:

property value as string.

Return type:

str

async_reload_daemon() Process

Reload systemd daemon to refresh unit files. Non-blocking call.

Returns:

Running SSH process.

Return type:

Process

reload_daemon(raise_on_error: bool = True) ProcessResult

Reload systemd daemon to refresh unit files. The call will wait until the operation is finished.

Parameters:

raise_on_error (bool, optional) – Raise exception on error, defaults to True

Returns:

SSH process result.

Return type:

ProcessResult

is_active(service: str) bool

Check if a systemd unit is active.

Parameters:

service (str) – Unit name.

Returns:

True if unit is active, False otherwise.

Return type:

bool