feat(access-point): declared AP writes and a DHCP lease reader, 4.54.0 (NetOrk/netork#695) #142

Merged
christianmanivong merged 4 commits from feature/ap-dhcp-contracts-695 into main 2026-11-29 22:03:14 +00:00
3 changed files with 47 additions and 1 deletions
Showing only changes of commit 059d97f6de - Show all commits

No files matched your search

+7
View File
@@ -7,6 +7,13 @@ recorded here; their history is the git log.
## [Unreleased]
### Added
- `UpdateMixin.apply_updates(packages, *, log=None)`: an optional keyword-only `log` that
receives each line of the package manager's output as the host prints it
(NetOrk/netork#1112), as `harden_ssh_server(..., log=...)` does. A driver that cannot
stream does not call it and returns the output at the end, as before; `output` holds the
whole output either way. Drivers without it keep conforming.
## [4.53.0] - 2026-11-28
### Added
+11 -1
View File
@@ -12,6 +12,7 @@ this class in can never shadow a working implementation from a sibling base.
from __future__ import annotations
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, Literal
from typing_extensions import TypedDict
@@ -182,7 +183,12 @@ class UpdateMixin:
"""
...
def apply_updates(self, packages: list[str]) -> ApplyUpdatesResultDict:
def apply_updates(
self,
packages: list[str],
*,
log: Callable[[str], None] | None = None,
) -> ApplyUpdatesResultDict:
"""
Upgrades the given packages to the newest available version.
@@ -193,6 +199,10 @@ class UpdateMixin:
:param packages: List of package names to upgrade. Each name must
match ``^[a-zA-Z0-9_\\-\\+\\.]+$``; a :exc:`ValueError` is raised
for any name that does not conform.
:param log: Receives each line of the package manager's output as the
host prints it, so a caller can follow a long run. A driver that
cannot stream does not call it and returns the output at the end,
as without it; ``output`` holds the whole output either way.
:returns: A dict with:
* success (bool) – ``True`` if the package manager exited without error
+29
View File
@@ -2,6 +2,9 @@
from __future__ import annotations
import ast
import inspect
import napalm_device_types
from napalm_device_types.updates import PackageIndexMissing
@@ -18,3 +21,29 @@ def test_a_missing_index_is_its_own_failure():
def test_it_is_exported_from_the_package():
assert napalm_device_types.PackageIndexMissing is PackageIndexMissing
assert "PackageIndexMissing" in napalm_device_types.__all__
def _declared_apply_updates():
"""``UpdateMixin.apply_updates`` as declared (under ``TYPE_CHECKING``, so read from source)."""
from napalm_device_types import updates
for node in ast.walk(ast.parse(inspect.getsource(updates))):
if isinstance(node, ast.FunctionDef) and node.name == "apply_updates":
return node
raise AssertionError("apply_updates is not declared")
def test_apply_updates_takes_a_log_callback_by_keyword_only():
"""A caller can follow the host's output as it comes (NetOrk/netork#1112); the
positional signature stays as it was, so existing drivers keep conforming."""
node = _declared_apply_updates()
assert [a.arg for a in node.args.args] == ["self", "packages"]
assert [a.arg for a in node.args.kwonlyargs] == ["log"]
(default,) = node.args.kw_defaults
assert isinstance(default, ast.Constant) and default.value is None
assert ast.unparse(node.args.kwonlyargs[0].annotation) == "Callable[[str], None] | None"
def test_apply_updates_still_hides_at_runtime():
assert not hasattr(napalm_device_types.UpdateMixin, "apply_updates")