feat(updates): the update history of an apt host from apt's own log, 0.29.0 (NetOrk/netork#2728)
driver / lint (pull_request) Successful in 22s
driver / standard (pull_request) Successful in 22s
driver / lowest (pull_request) Successful in 35s
driver / types (pull_request) Successful in 1m8s
driver / test (3.12) (pull_request) Successful in 1m10s
driver / test (3.13) (pull_request) Successful in 1m3s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 1m6s
CI / driver (pull_request) Successful in 2m4s
driver / publish (pull_request) Skipped
driver / lint (pull_request) Successful in 22s
driver / standard (pull_request) Successful in 22s
driver / lowest (pull_request) Successful in 35s
driver / types (pull_request) Successful in 1m8s
driver / test (3.12) (pull_request) Successful in 1m10s
driver / test (3.13) (pull_request) Successful in 1m3s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 1m6s
CI / driver (pull_request) Successful in 2m4s
driver / publish (pull_request) Skipped
get_update_history through napalm-device-types' AptHistoryMixin, over run_command as the login user. Another package manager raises NotImplementedError. Carried over from #88 onto 0.28.0.
This commit is contained in:
1 parent
a352c7f16b
commit
b170adf8ed
5 files changed
+125
-6
No files matched your search
@@ -1,8 +1,9 @@
|
||||
"""What napalm-device-types implements for any POSIX host over ``run_command``.
|
||||
"""What napalm-device-types implements for a Linux host over ``run_command``.
|
||||
|
||||
The driver supplies ``run_command``; the readings, their parses and the writes are
|
||||
the mixins': scheduled jobs (cron, anacron, systemd timers) and time sync (chrony,
|
||||
systemd-timesyncd, ``timedatectl``). Their default paths are Debian's, which a
|
||||
the mixins': scheduled jobs (cron, anacron, systemd timers), time sync (chrony,
|
||||
systemd-timesyncd, ``timedatectl``), and on an apt host the update history from
|
||||
apt's own log (``_update_history``). Their default paths are Debian's, which a
|
||||
Linux host shares.
|
||||
"""
|
||||
|
||||
@@ -10,6 +11,8 @@ from __future__ import annotations
|
||||
|
||||
from napalm_device_types import PosixScheduledJobsMixin, PosixTimeSyncMixin
|
||||
|
||||
from napalm_linux._update_history import LinuxUpdateHistoryMixin
|
||||
|
||||
class LinuxPosixMixin(PosixScheduledJobsMixin, PosixTimeSyncMixin):
|
||||
"""Scheduled jobs and time sync of the host, over the driver's ``run_command``."""
|
||||
|
||||
class LinuxPosixMixin(PosixScheduledJobsMixin, PosixTimeSyncMixin, LinuxUpdateHistoryMixin):
|
||||
"""Scheduled jobs, time sync and the update history, over the driver's ``run_command``."""
|
||||
@@ -0,0 +1,28 @@
|
||||
"""The host's past package transactions (``UpdateMixin.get_update_history``, NetOrk/netork#2728).
|
||||
|
||||
On an apt host, napalm-device-types' ``AptHistoryMixin``: apt's history log over
|
||||
``run_command``, as the login user, and as root only for a file the login user
|
||||
may not read. dnf, yum, apk and pacman keep histories of their own that this
|
||||
driver does not read yet: ``NotImplementedError``, never an empty list.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from napalm_device_types import AptHistoryMixin, UpdateHistoryDict
|
||||
|
||||
|
||||
class LinuxUpdateHistoryMixin(AptHistoryMixin):
|
||||
"""``get_update_history`` on the hosts whose package manager the driver detected as apt."""
|
||||
|
||||
_pkg_manager: str | None
|
||||
|
||||
def get_update_history(self, since: int | None = None) -> list[UpdateHistoryDict]:
|
||||
"""apt's transactions on the host, newest first, from *since* (unix seconds) on.
|
||||
|
||||
:raises NotImplementedError: on a host whose package manager is not apt.
|
||||
"""
|
||||
if self._pkg_manager != "apt":
|
||||
raise NotImplementedError(
|
||||
f"No update history is read for package manager {self._pkg_manager!r}"
|
||||
)
|
||||
return super().get_update_history(since)
|
||||
Reference in new issue
Block a user