orangeqs.juice.orchestration.systemd#

Systemd utilities.

Module Contents#

Classes#

FailedUnit

A systemd unit that failed, with its log.

Functions#

collect_failed_units

Find the failed units and get the last lines of the log of their last run.

daemon_reload

Reload the systemd daemon.

restart_services

Restart multiple systemd services.

start_services

Start a systemd service.

enable_services

Enable a systemd service.

Data#

TAIL_LINES

Number of log lines of a failed unit to show to the user.

API#

orangeqs.juice.orchestration.systemd.TAIL_LINES#

30

Number of log lines of a failed unit to show to the user.

class orangeqs.juice.orchestration.systemd.FailedUnit#

A systemd unit that failed, with its log.

Attributes#

  • name (str): Full name of the unit, for example juice-foo-build.service.

  • tail (list[str]): The last lines of the log of the last run of the unit.

name: str#

None

tail: list[str]#

None

exception orangeqs.juice.orchestration.systemd.UnitFailedError(message: str, units: list[orangeqs.juice.orchestration.systemd.FailedUnit])#

Bases: RuntimeError

One or more systemd units failed to start or restart.

Parameters#

  • message (str): Short description of the failure.

  • units (list[FailedUnit]): The units that failed, with their logs.

orangeqs.juice.orchestration.systemd.collect_failed_units(service_names: list[str]) → list[orangeqs.juice.orchestration.systemd.FailedUnit]#

Find the failed units and get the last lines of the log of their last run.

Parameters#

  • service_names (list[str]): The units to check.

Returns#

  • (list[FailedUnit]): The units that failed. Empty if no unit has failed.

orangeqs.juice.orchestration.systemd.daemon_reload() → None#

Reload the systemd daemon.

orangeqs.juice.orchestration.systemd.restart_services(service_names: str | list[str]) → None#

Restart multiple systemd services.

Raises#

  • (UnitFailedError): If one or more units failed. It contains the log of each failed unit.

  • (RuntimeError): If systemctl failed for another reason.

orangeqs.juice.orchestration.systemd.start_services(service_names: str | list[str]) → None#

Start a systemd service.

Raises#

  • (UnitFailedError): If one or more units failed. It contains the log of each failed unit.

  • (RuntimeError): If systemctl failed for another reason.

orangeqs.juice.orchestration.systemd.enable_services(service_names: str | list[str]) → None#

Enable a systemd service.