feat(updates): the update history of an apt host from apt's own log (NetOrk/netork#2728)
get_update_history through napalm-device-types' AptHistoryMixin, over run_command as the login user. Another package manager raises NotImplementedError. Requires napalm-device-types 4.47.0.
This commit is contained in:
1 parent
670e62e0f0
commit
66b6068ebf
5 files changed
+126
-6
No files matched your search
@@ -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