fix: report which services are enabled, and whether an action worked #8

Merged
christianmanivong merged 1 commits from feat/systemd-services-mixin into master 2026-10-05 11:12:15 +00:00
Owner

Closes #6. Builds on NAPALM/napalm-device-types#5 (2.2.0, SystemdServicesMixin).

This drops the driver's own get_services() and manage_service(), which had two problems:

  • The parser read the PRESET column (enabled was always false).
  • || true reported every action as a success.

The shared mixin replaces them. The driver keeps only _run_service_command, its exec path as root.

Checked against a real node (PVE 9.2, netOrk test server)

  • Listing: 1.7 s, the same as before. 63 services are now correctly enabled, and the running state is identical.
  • Leaner list: 280 → 172 entries, because templates, static and alias unit files are no longer listed.
  • Failed action: manage_service("<missing unit>", "restart") returned a failure with systemctl's message, where it used to report success.

Tests (no CI in this repo, run locally)

$ PYTHONPATH=.:../napalm-device-types pytest -q tests
279 passed

ruff and mypy report nothing that master does not already report.

Closes #6. Builds on NAPALM/napalm-device-types#5 (2.2.0, `SystemdServicesMixin`). This drops the driver's own `get_services()` and `manage_service()`, which had two problems: - The parser read the PRESET column (`enabled` was always false). - `|| true` reported every action as a success. The shared mixin replaces them. The driver keeps only `_run_service_command`, its exec path as root. ## Checked against a real node (PVE 9.2, netOrk test server) - **Listing:** 1.7 s, the same as before. 63 services are now correctly `enabled`, and the running state is identical. - **Leaner list:** 280 → 172 entries, because templates, static and alias unit files are no longer listed. - **Failed action:** `manage_service("<missing unit>", "restart")` returned a failure with systemctl's message, where it used to report success. ## Tests (no CI in this repo, run locally) ``` $ PYTHONPATH=.:../napalm-device-types pytest -q tests 279 passed ``` ruff and mypy report nothing that `master` does not already report.
christianmanivong added 1 commit 2026-10-05 11:12:15 +00:00
get_services() read list-unit-files' second column, which since systemd 245
is followed by a preset column -- "enabled  enabled" never equalled
"enabled", so every service on every node was reported disabled (#6).
manage_service() ended in "|| true" and returned success whatever happened.

Both now come from napalm-device-types' SystemdServicesMixin (2.2.0): the
enabled state is UnitFileState from systemctl show, MainPID comes along in
the same round trip, and an action reports systemctl's exit status. The
driver keeps only _run_service_command(), its exec path as root. The exit
status marker keeps the output non-empty, so _exec_ssh_command's SSH fallback
on an empty API answer can no longer run an action twice.

The listing no longer includes templates, static unit files and aliases that
are not loaded (on a PVE 9 node: 280 entries -> 172).

Closes #6
christianmanivong merged commit 1881ee7330 into master 2026-10-05 11:12:15 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-proxmox#8