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:
1 parent
c2d9d7e75e
commit
b792f6d210
7 files changed
+106
-7
No files matched your search
@@ -27,6 +27,7 @@ from napalm_device_types import (
|
||||
OpenSshServerMixin,
|
||||
PortSpec,
|
||||
ServicePackagesMixin,
|
||||
ServicesRestartMixin,
|
||||
StorageDriver,
|
||||
SystemdServicesMixin,
|
||||
SystemIdentityMixin,
|
||||
@@ -65,6 +66,7 @@ class ProxmoxBackupDriver(
|
||||
ServicePackagesMixin,
|
||||
ListeningSocketsMixin,
|
||||
LogSourcesMixin,
|
||||
ServicesRestartMixin,
|
||||
SystemIdentityMixin,
|
||||
SystemdServicesMixin,
|
||||
ProxmoxScheduledJobsMixin,
|
||||
|
||||
@@ -38,6 +38,7 @@ from napalm_device_types import (
|
||||
OpenSshServerMixin,
|
||||
PortSpec,
|
||||
ServicePackagesMixin,
|
||||
ServicesRestartMixin,
|
||||
SnmpAgentMixin,
|
||||
SystemdServicesMixin,
|
||||
SystemIdentityMixin,
|
||||
@@ -98,6 +99,7 @@ class ProxmoxDriver(
|
||||
ServicePackagesMixin,
|
||||
ListeningSocketsMixin,
|
||||
LogSourcesMixin,
|
||||
ServicesRestartMixin,
|
||||
SystemIdentityMixin,
|
||||
SystemdServicesMixin,
|
||||
ProxmoxScheduledJobsMixin,
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
Reference in new issue
Block a user