feat: shutdown_host and begin_stop_vm, shutting down without waiting
driver / lint (pull_request) Successful in 18s
driver / standard (pull_request) Successful in 20s
driver / test (3.10) (pull_request) Failing after 6s
driver / types (pull_request) Successful in 1m4s
driver / test (3.12) (pull_request) Successful in 1m8s
driver / test (3.11) (pull_request) Successful in 1m13s
driver / test (3.13) (pull_request) Successful in 1m1s
driver / lowest (pull_request) Successful in 43s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Failing after 2m41s
driver / publish (pull_request) Skipped
driver / lint (pull_request) Successful in 18s
driver / standard (pull_request) Successful in 20s
driver / test (3.10) (pull_request) Failing after 6s
driver / types (pull_request) Successful in 1m4s
driver / test (3.12) (pull_request) Successful in 1m8s
driver / test (3.11) (pull_request) Successful in 1m13s
driver / test (3.13) (pull_request) Successful in 1m1s
driver / lowest (pull_request) Successful in 43s
driver / build (pull_request) Successful in 29s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Failing after 2m41s
driver / publish (pull_request) Skipped
HostShutdownMixin.shutdown_host(), on DeviceTypeDriver: a device shuts itself down cleanly through its own means; declared, so hasattr says whether a driver can. There is no forced variant. VmStopRequestMixin.begin_stop_vm(name): ask for a VM's clean shutdown and return at once, for a caller that waits on a timer and reads get_vm_status instead of blocking in stop_vm. No role demands it. For netOrk's graph workflows, which switch a hypervisor off when CI has nothing for it (NetOrk/netork#1636).
This commit is contained in:
1 parent
87dbdfac66
commit
4d3574cd60
8 files changed
+142
-3
No files matched your search
@@ -0,0 +1,27 @@
|
||||
"""shutdown_host: the contract for shutting the device itself down cleanly.
|
||||
|
||||
netOrk's graph workflows switch a hypervisor off when it has nothing to do
|
||||
(NetOrk/netork#1636): through its own API, never by pulling the power. Like
|
||||
``reboot_host`` it is declared, not implemented, so ``hasattr`` tells netOrk
|
||||
whether a driver can.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
|
||||
from napalm_device_types import DeviceTypeDriver, HostShutdownMixin
|
||||
|
||||
|
||||
def test_every_device_type_driver_carries_the_declaration():
|
||||
assert issubclass(DeviceTypeDriver, HostShutdownMixin)
|
||||
|
||||
|
||||
def test_declared_not_implemented():
|
||||
assert not hasattr(DeviceTypeDriver, "shutdown_host")
|
||||
|
||||
|
||||
def test_declaration_documents_the_contract():
|
||||
source = inspect.getsource(HostShutdownMixin)
|
||||
assert "def shutdown_host(self) -> None" in source
|
||||
assert "RuntimeError" in source
|
||||
@@ -0,0 +1,28 @@
|
||||
"""begin_stop_vm: ask for a VM's clean shutdown and return at once.
|
||||
|
||||
``stop_vm`` blocks until the VM is stopped, with a limit of the driver's own.
|
||||
A caller that keeps its waits as timers (netOrk's graph workflows,
|
||||
NetOrk/netork#1636) asks with ``begin_stop_vm`` and reads ``get_vm_status``
|
||||
until the VM is stopped. A driver mixes it in when it can; no role demands it.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
|
||||
from napalm_device_types import HypervisorDriver, VmStopRequestMixin
|
||||
|
||||
|
||||
def test_no_role_demands_it():
|
||||
assert not issubclass(HypervisorDriver, VmStopRequestMixin)
|
||||
|
||||
|
||||
def test_declared_not_implemented():
|
||||
assert not hasattr(VmStopRequestMixin, "begin_stop_vm")
|
||||
|
||||
|
||||
def test_declaration_documents_the_contract():
|
||||
source = inspect.getsource(VmStopRequestMixin)
|
||||
assert "def begin_stop_vm(self, name: str) -> None" in source
|
||||
assert "ValueError" in source
|
||||
assert "RuntimeError" in source
|
||||
Reference in new issue
Block a user