Merge remote-tracking branch 'origin/main' into feat/health-profile-unknown
driver / standard (pull_request) Successful in 19s
driver / lint (pull_request) Successful in 18s
driver / types (pull_request) Successful in 1m7s
driver / test (3.12) (pull_request) Successful in 1m8s
driver / test (3.13) (pull_request) Successful in 1m9s
driver / lowest (pull_request) Successful in 40s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 1m11s
CI / driver (pull_request) Successful in 2m57s
driver / publish (pull_request) Skipped

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
christianmanivong committed 2026-11-01 23:56:39 +01:00
commit e98d4763f3
6 files changed
+97 -10

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
"""A provisioning that failed after the hypervisor gave the VM its id says
which VM it left behind, so the caller can remove it (NAPALM/napalm-proxmox#28)."""
from __future__ import annotations
import pickle
import pytest
from napalm_device_types import VMProvisionIncomplete
from napalm_device_types.provisioning import VMProvisionIncomplete as from_module
def _raise_from(cause: Exception) -> VMProvisionIncomplete:
try:
try:
raise cause
except Exception as exc:
raise VMProvisionIncomplete(str(exc), vmid="101", node="pve1") from exc
except VMProvisionIncomplete as caught:
return caught
def test_it_is_exported_from_the_package_root():
assert VMProvisionIncomplete is from_module
def test_it_names_the_vm_left_behind():
caught = _raise_from(RuntimeError("disk import failed"))
assert (caught.vmid, caught.node) == ("101", "pve1")
def test_it_keeps_the_failure_and_its_words():
cause = RuntimeError("disk import failed")
caught = _raise_from(cause)
assert caught.__cause__ is cause
assert str(caught) == "disk import failed"
def test_a_caller_catching_runtime_error_still_catches_it():
# The contract has create_vm_from_cloud_init raise RuntimeError on failure.
with pytest.raises(RuntimeError):
raise VMProvisionIncomplete("start failed", vmid="7", node="n")
def test_vmid_and_node_are_keyword_only():
with pytest.raises(TypeError):
VMProvisionIncomplete("failed", "101", "pve1") # type: ignore[misc]
def test_it_survives_pickling_as_a_task_result_would():
caught = pickle.loads(pickle.dumps(VMProvisionIncomplete("failed", vmid="101", node="pve1")))
assert (str(caught), caught.vmid, caught.node) == ("failed", "101", "pve1")