Merge pull request 'feat(updates): PackageIndexMissing, for a host without a package index' (#120) from feat/package-index-missing into main
driver / lint (push) Successful in 12s
driver / standard (push) Successful in 14s
driver / types (push) Successful in 53s
driver / test (3.13) (push) Successful in 1m1s
driver / test (3.12) (push) Successful in 1m7s
driver / lowest (push) Successful in 34s
driver / build (push) Successful in 28s
driver / security (push) Successful in 1m0s
CI / driver (push) Successful in 2m15s
driver / publish (push) Skipped
driver / lint (push) Successful in 12s
driver / standard (push) Successful in 14s
driver / types (push) Successful in 53s
driver / test (3.13) (push) Successful in 1m1s
driver / test (3.12) (push) Successful in 1m7s
driver / lowest (push) Successful in 34s
driver / build (push) Successful in 28s
driver / security (push) Successful in 1m0s
CI / driver (push) Successful in 2m15s
driver / publish (push) Skipped
This commit was merged in pull request #120.
This commit is contained in:
commit
3db6c6385c
4 files changed
+39
-1
No files matched your search
@@ -7,6 +7,12 @@ recorded here; their history is the git log.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- `PackageIndexMissing` (a `RuntimeError`): what `get_available_updates()` raises when
|
||||
the host holds no package index to read from -- OpenWrt's, which lives in RAM, after
|
||||
every reboot. `refresh_available_updates()` loads it again, so a caller can tell this
|
||||
from a failed read and refresh instead of reporting an error (NetOrk/netork#2527).
|
||||
|
||||
## [4.38.0] - 2026-11-13
|
||||
|
||||
### Added
|
||||
|
||||
@@ -335,7 +335,7 @@ from napalm_device_types.time_sync import (
|
||||
check_ntp_servers,
|
||||
)
|
||||
from napalm_device_types.time_sync_posix import PosixTimeSyncMixin, parse_time_sync
|
||||
from napalm_device_types.updates import UpdateMixin
|
||||
from napalm_device_types.updates import PackageIndexMissing, UpdateMixin
|
||||
from napalm_device_types.virtual_ips import (
|
||||
VIRTUAL_IPS_COMMAND,
|
||||
VirtualIpsMixin,
|
||||
@@ -505,6 +505,7 @@ __all__ = [
|
||||
"SystemdServicesMixin",
|
||||
"SystemdUnavailable",
|
||||
"parse_systemd_services",
|
||||
"PackageIndexMissing",
|
||||
"UpdateMixin",
|
||||
"VIRTUAL_IPS_COMMAND",
|
||||
"VirtualIpsMixin",
|
||||
|
||||
@@ -17,6 +17,15 @@ from typing import TYPE_CHECKING, Any
|
||||
from napalm_device_types.models import ApplyUpdatesResultDict, UpdateDict, UpdateProgressDict
|
||||
|
||||
|
||||
class PackageIndexMissing(RuntimeError):
|
||||
"""The host holds no package index to read pending updates from.
|
||||
|
||||
Not a fault: OpenWrt keeps its index in RAM and loses it on every reboot.
|
||||
:meth:`UpdateMixin.refresh_available_updates` loads it again, so a caller
|
||||
that sees this can refresh instead of reporting a failed read.
|
||||
"""
|
||||
|
||||
|
||||
class UpdateMixin:
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -37,6 +46,8 @@ class UpdateMixin:
|
||||
read -- no package index yet, an API that did not answer -- raises
|
||||
instead: netOrk keeps "pending since" per package, and an empty
|
||||
list for "don't know" would reset every one of those clocks.
|
||||
Without a package index it raises :exc:`PackageIndexMissing`, which
|
||||
:meth:`refresh_available_updates` cures.
|
||||
|
||||
Example::
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
"""The contract of :class:`~napalm_device_types.updates.UpdateMixin`."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import napalm_device_types
|
||||
from napalm_device_types.updates import PackageIndexMissing
|
||||
|
||||
|
||||
def test_a_missing_index_is_its_own_failure():
|
||||
"""A reader can tell "no index to read from" from any other failure, and a
|
||||
caller that only knows failures still catches it as one."""
|
||||
exc = PackageIndexMissing("The package index is not loaded (run apk update first)")
|
||||
|
||||
assert isinstance(exc, RuntimeError)
|
||||
assert str(exc) == "The package index is not loaded (run apk update first)"
|
||||
|
||||
|
||||
def test_it_is_exported_from_the_package():
|
||||
assert napalm_device_types.PackageIndexMissing is PackageIndexMissing
|
||||
assert "PackageIndexMissing" in napalm_device_types.__all__
|
||||
Reference in new issue
Block a user