feat: get_service_packages, which packages a systemd service is (NetOrk/netork#1236)
CI / test (3.10) (pull_request) Successful in 41s
CI / test (3.11) (pull_request) Successful in 40s
CI / test (3.12) (pull_request) Successful in 32s
CI / test (3.10) (push) Successful in 29s
CI / test (3.11) (push) Successful in 27s
CI / test (3.12) (push) Successful in 34s

Mixes in napalm-device-types' ServicePackagesMixin. The transport runs the
shared read-only command on an exec channel under sh, without sudo: it is
about 1 kB, past what the PTY takes reliably, and written for sh whatever
the login shell. Requires napalm-device-types 4.20.0; version 0.12.0.
This commit is contained in:
Christian Manivong committed 2026-10-19 17:40:06 +02:00
1 parent c725f4882c
commit a2bfa709f9
4 files changed
+50 -2

No files matched your search

+11
View File
@@ -47,6 +47,7 @@ from napalm_device_types import (
OSDriver,
PackageProxyMixin,
ServiceClustersMixin,
ServicePackagesMixin,
SnmpAgentMixin,
SystemIdentityMixin,
SystemdServicesMixin,
@@ -294,6 +295,7 @@ class LinuxDriver(
EnsurePackageMixin,
PackageProxyMixin,
KernelFactsMixin,
ServicePackagesMixin,
ListeningSocketsMixin,
VirtualIpsMixin,
ServiceClustersMixin,
@@ -1164,6 +1166,15 @@ class LinuxDriver(
"""The transport for ``KernelFactsMixin.get_kernel_facts``: read-only, no sudo."""
return self._send(command, read_timeout=60)
def _run_service_packages_command(self, command: str) -> str:
"""The transport for ``ServicePackagesMixin.get_service_packages``.
An exec channel rather than the PTY -- the command is about 1 kB -- under
``sh``, which it is written for, whatever the login shell. Read-only, so
never through sudo.
"""
return self.run_command(f"sh -c {_shlex_quote(command)}", timeout=120).stdout
# ------------------------------------------------------------------
# ListeningSocketsMixin – the transport for get_listening_sockets
# ------------------------------------------------------------------