feat: guest uid, credential expiry and update history contracts (NetOrk/netork#2728)
VMDict.uid is an identity of the guest that survives a migration, a restore and a changed vmid. CredentialExpiryMixin reads when the credential a driver logs in with expires. UpdateMixin.get_update_history lists the package manager's past transactions. resume_vm documents that the guest clock is set after a resume where the platform can.
This commit is contained in:
1 parent
818016b717
commit
07fc7d0dd3
7 files changed
+249
-1
No files matched your search
@@ -0,0 +1,68 @@
|
||||
"""Contracts Proxmox VE 9.3 made worth having, kept neutral (NetOrk/netork#2728).
|
||||
|
||||
A guest identity that survives a changed ID, the expiry of the credential a
|
||||
driver logs in with, and what a host's package manager did in the past: each a
|
||||
shape every driver of its kind can fill, with the platform's own calls left to
|
||||
the driver.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import typing
|
||||
from typing import get_type_hints
|
||||
|
||||
from napalm_device_types import (
|
||||
CredentialExpiryDict,
|
||||
CredentialExpiryMixin,
|
||||
UpdateHistoryDict,
|
||||
UpdateHistoryPackageDict,
|
||||
UpdateMixin,
|
||||
)
|
||||
from napalm_device_types.models import VMDict
|
||||
|
||||
|
||||
def test_a_vm_may_carry_an_identity_that_outlives_its_vmid():
|
||||
assert "uid" in get_type_hints(VMDict)
|
||||
assert "uid" in VMDict.__optional_keys__
|
||||
|
||||
|
||||
def test_a_credential_expiry_names_the_credential_and_when_it_ends():
|
||||
assert set(get_type_hints(CredentialExpiryDict)) == {"kind", "name", "expires"}
|
||||
kinds = typing.get_args(get_type_hints(CredentialExpiryDict)["kind"])
|
||||
assert set(kinds) == {"api-token", "account"}
|
||||
|
||||
|
||||
def test_credential_expiry_is_a_contract_not_a_placeholder():
|
||||
assert not hasattr(CredentialExpiryMixin, "get_credential_expiry")
|
||||
|
||||
|
||||
def test_an_update_transaction_is_its_packages_and_who_asked_for_it():
|
||||
assert set(get_type_hints(UpdateHistoryDict)) == {
|
||||
"id",
|
||||
"start",
|
||||
"end",
|
||||
"packages",
|
||||
"requested_by",
|
||||
"command",
|
||||
"error",
|
||||
}
|
||||
assert set(get_type_hints(UpdateHistoryPackageDict)) == {
|
||||
"name",
|
||||
"action",
|
||||
"old_version",
|
||||
"new_version",
|
||||
}
|
||||
actions = typing.get_args(get_type_hints(UpdateHistoryPackageDict)["action"])
|
||||
assert set(actions) == {
|
||||
"install",
|
||||
"reinstall",
|
||||
"upgrade",
|
||||
"downgrade",
|
||||
"remove",
|
||||
"purge",
|
||||
"disappear",
|
||||
}
|
||||
|
||||
|
||||
def test_update_history_is_declared_next_to_pending_updates():
|
||||
assert not hasattr(UpdateMixin, "get_update_history")
|
||||
Reference in new issue
Block a user