feat(services-restart): which services on the node still run replaced code, as root (NetOrk/netork#2750)

Both drivers mix in napalm-device-types' ServicesRestartMixin. The command
goes over the exec path, root's login as a rule, behind an id -u guard: a
login other than root would see only its own processes and read as
clean, so it prints nothing and the read raises. A running VM's QEMU is
listed as a process; an LXC container's processes are left out by the
parse, since a container updates itself. No stdin.
This commit is contained in:
Christian Manivong committed 2026-11-26 18:55:13 +01:00
1 parent c2d9d7e75e
commit b792f6d210
7 files changed
+106 -7

No files matched your search

+12 -5
View File
@@ -1,11 +1,11 @@
"""What a Proxmox VE node and a Proxmox Backup Server share as Debian hosts.
The transports for napalm-device-types' host readers (kernel facts, service
packages, system identity, listening sockets, systemd services, host status,
apt's proxy), packages and APT updates, the subscription, root file writes,
and restarting or shutting the host down. All of it is the same on both
products: the same ``/nodes/{node}/apt``, ``/subscription`` and ``/status``
endpoints, and root's shell over the driver's own SSH session.
packages, system identity, listening sockets, the services that still run replaced
code, systemd services, host status, apt's proxy), packages and APT updates, the
subscription, root file writes, and restarting or shutting the host down. All of it
is the same on both products: the same ``/nodes/{node}/apt``, ``/subscription`` and
``/status`` endpoints, and root's shell over the driver's own SSH session.
"""
from __future__ import annotations
@@ -91,6 +91,13 @@ class ProxmoxHostMixin:
which runs as root either way."""
return str(self._exec_ssh_command(command))
def _run_services_restart_command(self, command: str) -> str:
"""The transport for ``ServicesRestartMixin.get_services_need_restart``: the exec
path, which is root's login as a rule. Run only as root: a reading of the login's
own processes would read as clean, so another login prints nothing and the parse
raises (NetOrk/netork#2750). No stdin."""
return str(self._exec_ssh_command(f'[ "$(id -u)" = 0 ] && {command}'))
def get_packages(self) -> list[PackageDict]:
"""Return installed Debian packages with available-update info.