feat(services-restart): the services that still run replaced code (NetOrk/netork#2700) #132

Merged
christianmanivong merged 5 commits from feature/services-need-restart into main 2026-11-26 18:31:38 +00:00
4 changed files with 28 additions and 24 deletions
Showing only changes of commit 494b9ed046 - Show all commits

No files matched your search

+1 -1
View File
@@ -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
+4
View File
@@ -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",
-21
View File
@@ -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/<pid>/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.
+23 -2
View File
@@ -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/<pid>/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"