feat(kernel): the live patches the running kernel carries, in the kernel facts, 4.52.0 (NetOrk/netork#2701) #139

Merged
christianmanivong merged 6 commits from feature/live-kernel-patches into main 2026-11-28 09:59:40 +00:00
4 changed files with 42 additions and 26 deletions
Showing only changes of commit 3f35d05a73 - Show all commits

No files matched your search

+6 -4
View File
@@ -33,8 +33,8 @@ import gzip
import zlib
from typing import TYPE_CHECKING
from napalm_device_types.kernel_models import KernelFactsDict
from napalm_device_types.livepatch import live_patches, parse_canonical_status
from napalm_device_types.models import KernelFactsDict
_BEGIN = "KFACTS_BEGIN"
_END = "KFACTS_END"
@@ -212,7 +212,9 @@ class KernelFactsMixin:
if patches["canonical"] is not None:
return facts
try:
patches["canonical"] = parse_canonical_status(run(LIVEPATCH_STATUS_COMMAND))
except Exception: # noqa: BLE001 - root refused or the client failed: not read
pass
status = run(LIVEPATCH_STATUS_COMMAND)
except Exception: # noqa: BLE001 - root refused or the client failed
# Not read: ``canonical`` stays None, as without a driver that gains root.
return facts
patches["canonical"] = parse_canonical_status(status)
return facts
+34
View File
@@ -0,0 +1,34 @@
"""The shape of the kernel facts (``KernelFactsMixin.get_kernel_facts``).
A module of its own rather than in :mod:`napalm_device_types.models`, which re-exports
it: the reading grew its live patches (NetOrk/netork#2701), and ``models`` is at its
recorded size.
"""
from __future__ import annotations
from typing import NotRequired
from typing_extensions import TypedDict
from napalm_device_types.livepatch import LivePatchesDict
class KernelFactsDict(TypedDict):
"""What the running kernel has built and loaded (``KernelFactsMixin.get_kernel_facts``).
``None`` means *could not be read*; an empty list means *read, and there is
nothing*. The difference is what lets a consumer say "this module cannot be
loaded on this kernel" rather than "we did not look".
Module names are normalised by :func:`napalm_device_types.kernel.module_name`:
no path, no ``.ko`` suffix, ``-`` folded to ``_``.
"""
release: str # uname -r
loaded: list[str] | None # /proc/modules
builtin: list[str] | None # modules.builtin -- compiled into the kernel image
available: list[str] | None # modules.dep -- shipped as loadable modules
config: dict[str, str] | None # build configuration, set options only; quotes stripped
#: The live patches the kernel carries (NetOrk/netork#2701, ``livepatch``).
live_patches: NotRequired[LivePatchesDict]
+1 -21
View File
@@ -21,7 +21,7 @@ from napalm_device_types.access_point_models import SSIDBridgeDict as SSIDBridge
from napalm_device_types.access_point_models import SSIDDict as SSIDDict
from napalm_device_types.access_point_models import WirelessClientDict as WirelessClientDict
from napalm_device_types.access_point_models import WirelessConfigDict as WirelessConfigDict
from napalm_device_types.livepatch import LivePatchesDict
from napalm_device_types.kernel_models import KernelFactsDict as KernelFactsDict
from napalm_device_types.snmp_health_profile import SnmpHealthProfile as SnmpHealthProfile
from napalm_device_types.snmp_health_profile import SnmpInterfacesSpec as SnmpInterfacesSpec
from napalm_device_types.snmp_health_profile import SnmpMemorySpec as SnmpMemorySpec
@@ -274,26 +274,6 @@ class NATTranslationDict(TypedDict):
age: float
class KernelFactsDict(TypedDict):
"""What the running kernel has built and loaded (``KernelFactsMixin.get_kernel_facts``).
``None`` means *could not be read*; an empty list means *read, and there is
nothing*. The difference is what lets a consumer say "this module cannot be
loaded on this kernel" rather than "we did not look".
Module names are normalised by :func:`napalm_device_types.kernel.module_name`:
no path, no ``.ko`` suffix, ``-`` folded to ``_``.
"""
release: str # uname -r
loaded: list[str] | None # /proc/modules
builtin: list[str] | None # modules.builtin -- compiled into the kernel image
available: list[str] | None # modules.dep -- shipped as loadable modules
config: dict[str, str] | None # build configuration, set options only; quotes stripped
#: The live patches the kernel carries (NetOrk/netork#2701, ``livepatch``).
live_patches: NotRequired[LivePatchesDict]
class ListeningSocketDict(TypedDict):
"""A TCP socket that listens, or a UDP socket that is bound, on the host.
+1 -1
View File
@@ -31,7 +31,7 @@
},
"mypy_relaxed": [],
"python_file_lines": {
"napalm_device_types/models.py": 1353
"napalm_device_types/models.py": 1336
},
"untyped_public": []
}