feat: implement the HypervisorDriver VM contract #1

Merged
christianmanivong merged 2 commits from feature/hypervisor-contract into master 2026-10-01 18:59:37 +00:00
Owner

Summary

Implements the HypervisorDriver VM methods that until now were only declared, so netOrk can drive Proxmox and VMware through the same contract.

Changes

  • New vm_contract_mixin.py: start_vm, stop_vm(force), reboot_vm(force), suspend_vm, get_vm_config. They take a name or vmid, wait for the Proxmox task, and raise ValueError/RuntimeError. Forced container reboot = stop + start (LXC has no reset); suspending a container is refused.
  • get_vm_config returns a VMConfigDict (the parsing formerly in netOrk's _parse_proxmox_hw_config).
  • get_vms() reports vmid as a string ("100"), still sorted numerically.
  • power_vm unchanged.
  • Requires napalm_device_types>=2.0.0.

Related

Needs NAPALM/napalm-device-types#1. Consumed by netOrk feature/vmware-driver.

Testing

pytest: 223 passed (27 new in tests/test_vm_contract.py).

🤖 Generated with Claude Code

## Summary Implements the `HypervisorDriver` VM methods that until now were only declared, so netOrk can drive Proxmox and VMware through the same contract. ## Changes - New `vm_contract_mixin.py`: `start_vm`, `stop_vm(force)`, `reboot_vm(force)`, `suspend_vm`, `get_vm_config`. They take a name or vmid, wait for the Proxmox task, and raise `ValueError`/`RuntimeError`. Forced container reboot = stop + start (LXC has no reset); suspending a container is refused. - `get_vm_config` returns a `VMConfigDict` (the parsing formerly in netOrk's `_parse_proxmox_hw_config`). - `get_vms()` reports `vmid` as a string (`"100"`), still sorted numerically. - `power_vm` unchanged. - Requires `napalm_device_types>=2.0.0`. ## Related Needs NAPALM/napalm-device-types#1. Consumed by netOrk `feature/vmware-driver`. ## Testing `pytest`: 223 passed (27 new in `tests/test_vm_contract.py`). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
christianmanivong added 1 commit 2026-09-24 07:07:09 +00:00
start_vm, stop_vm, reboot_vm, suspend_vm and get_vm_config existed only
as declarations. netOrk called Proxmox's own power_vm and read a VM's
raw config through _node_api(), so no other hypervisor could serve the
same endpoints. These let netOrk talk to every hypervisor alike.

The power methods accept a VM's name or vmid, wait for the Proxmox task,
and raise ValueError/RuntimeError as the contract says instead of
returning a result dict. A forced reboot of a container is stop + start,
since LXC has no reset; suspending a container is refused. power_vm is
unchanged for existing callers.

get_vm_config moves the config parsing netOrk did in
_parse_proxmox_hw_config into the driver and returns a VMConfigDict:
disks with storage and size, NICs with model, MAC, bridge and VLAN, CPU
topology, firmware, machine type and PCI/USB passthrough.

get_vms reports vmid as a string ("100"), following
napalm-device-types 2.0, still ordered numerically.
christianmanivong added 1 commit 2026-09-24 08:00:14 +00:00
get_vm_snapshots, create_vm_snapshot, delete_vm_snapshot and
rollback_vm_snapshot for VMs and containers, so netOrk's snapshot view
works on Proxmox as it does on VMware. Proxmox lists the live state as a
pseudo-snapshot named "current"; it is never reported or addressable.
Containers have no RAM state, so include_memory is ignored for them.

reboot_host() restarts the node with POST /nodes/{node}/status
command=reboot instead of /sbin/reboot over SSH.
christianmanivong merged commit a9f4cd249f into master 2026-10-01 18:59:37 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-proxmox#1