diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c5bf83..cd8b9e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ recorded here; their history is the git log. no report and raises, never a clean reading. A driver supplies `_run_services_restart_command(command)`. - `parse_services_restart`, `SERVICES_RESTART_COMMAND`, `DELETED_CODE_PATTERN`, and the - `ServicesRestartDict` and `RestartProcessDict` shapes. + `ServicesRestartDict` and `RestartProcessDict` shapes (in `services_restart`). ## [4.43.0] - 2026-11-26 diff --git a/napalm_device_types/__init__.py b/napalm_device_types/__init__.py index 3abbcf9..cf46e4c 100644 --- a/napalm_device_types/__init__.py +++ b/napalm_device_types/__init__.py @@ -303,6 +303,8 @@ from napalm_device_types.service_packages import ( from napalm_device_types.services import ServiceControlMixin from napalm_device_types.services_restart import ( SERVICES_RESTART_COMMAND, + RestartProcessDict, + ServicesRestartDict, ServicesRestartMixin, parse_services_restart, ) @@ -524,6 +526,8 @@ __all__ = [ "SERVICE_PACKAGES_COMMAND", "SERVICES_RESTART_COMMAND", "ServicesRestartMixin", + "ServicesRestartDict", + "RestartProcessDict", "parse_services_restart", "ServicePackagesMixin", "parse_service_packages", diff --git a/napalm_device_types/models.py b/napalm_device_types/models.py index 36da4b8..66667ba 100644 --- a/napalm_device_types/models.py +++ b/napalm_device_types/models.py @@ -406,27 +406,6 @@ class ListeningSocketsDict(TypedDict): sockets: list[ListeningSocketDict] -class RestartProcessDict(TypedDict): - """A process that runs replaced code and belongs to no systemd service.""" - - pid: int - name: str # /proc//comm - - -class ServicesRestartDict(TypedDict): - """What ``ServicesRestartMixin.get_services_need_restart`` read. - - ``units`` are the systemd services, without ".service", that still run code - an update replaced on disk; empty when none does. ``processes`` are the ones - that belong to no service (a login session, systemd itself), read only by the - ``/proc`` scan; the host's own tools name services only. - """ - - source: str # "needs-restarting", "needrestart" or "maps" - units: list[str] - processes: list[RestartProcessDict] - - class NetfilterMatchDict(TypedDict): """One condition of a netfilter rule. diff --git a/napalm_device_types/services_restart.py b/napalm_device_types/services_restart.py index af630db..f8e6c1a 100644 --- a/napalm_device_types/services_restart.py +++ b/napalm_device_types/services_restart.py @@ -38,12 +38,33 @@ from __future__ import annotations import re from shlex import quote -from typing import TYPE_CHECKING +from typing import TYPE_CHECKING, TypedDict from napalm_device_types.listening import _cgroup_paths, _container, _unit -from napalm_device_types.models import RestartProcessDict, ServicesRestartDict from napalm_device_types.terminal import strip_terminal_codes + +class RestartProcessDict(TypedDict): + """A process that runs replaced code and belongs to no systemd service.""" + + pid: int + name: str # /proc//comm + + +class ServicesRestartDict(TypedDict): + """What :meth:`ServicesRestartMixin.get_services_need_restart` read. + + ``units`` are the systemd services, without ".service", that still run code + an update replaced on disk; empty when none does. ``processes`` are the ones + that belong to no service (a login session, systemd itself), read only by the + ``/proc`` scan; the host's own tools name services only. + """ + + source: str # "needs-restarting", "needrestart" or "maps" + units: list[str] + processes: list[RestartProcessDict] + + _BEGIN = "RST_BEGIN" _END = "RST_END" NEEDS_RESTARTING = "needs-restarting"