feat: VM provisioning, and reboot_host on ESXi #1

Merged
christianmanivong merged 1 commits from feature/host-reboot-snapshots-provisioning into main 2026-10-01 18:59:37 +00:00
Owner

Summary

VM provisioning (netOrk #307) and host reboot (netOrk #308) for both drivers.

Changes

  • create_vm_from_cloud_init from netOrk's catalog images:

    1. Download with checksum check (one retry).
    2. qemu-img conversion to a streamOptimized VMDK, cached per URL.
    3. OVF import over NFC.
    4. MACs pinned, disk grown, NoCloud seed ISO attached as a CD-ROM on a new SATA controller.
    5. Power-on.

    If anything fails after the import, the VM is removed again.

  • destroy_vm, get_vm_status, get_network_targets (port groups, kind="portgroup", fixed VLAN), get_image_storages.

  • Placement as a pure function, the same for standalone ESXi and vCenter.

  • reboot_host on ESXi (maintenance mode only). vCenter has no reboot.

  • GUEST_AGENT_PACKAGES = ("open-vm-tools",).

  • New dependencies: pycdlib, PyYAML, requests. Where the driver runs it needs qemu-img and HTTPS to the ESXi hosts; through vCenter the NFC upload goes straight to the host.

Related

Needs NAPALM/napalm-device-types#1. Consumed by netOrk PR #311.

Testing

  • 286 tests, including end-to-end against vcsim (ESXi + vCenter): provisioning with MAC, disk growth, status, config, removal.
  • vcsim surfaced two real bugs, both fixed and now pinned by tests: chunked upload with Content-Length gets a 500, and a device edit without its backing crashes vcsim.
  • ruff and mypy clean.
  • Unverified until netOrk#305: whether each distro's cloud kernel has the PVSCSI/VMXNET3 drivers.

🤖 Generated with Claude Code

## Summary VM provisioning (netOrk #307) and host reboot (netOrk #308) for both drivers. ## Changes - `create_vm_from_cloud_init` from netOrk's catalog images: 1. Download with checksum check (one retry). 2. `qemu-img` conversion to a streamOptimized VMDK, cached per URL. 3. OVF import over NFC. 4. MACs pinned, disk grown, NoCloud seed ISO attached as a CD-ROM on a new SATA controller. 5. Power-on. If anything fails after the import, the VM is removed again. - `destroy_vm`, `get_vm_status`, `get_network_targets` (port groups, `kind="portgroup"`, fixed VLAN), `get_image_storages`. - Placement as a pure function, the same for standalone ESXi and vCenter. - `reboot_host` on ESXi (maintenance mode only). vCenter has no reboot. - `GUEST_AGENT_PACKAGES = ("open-vm-tools",)`. - New dependencies: `pycdlib`, `PyYAML`, `requests`. Where the driver runs it needs `qemu-img` and HTTPS to the ESXi hosts; through vCenter the NFC upload goes straight to the host. ## Related Needs NAPALM/napalm-device-types#1. Consumed by netOrk PR #311. ## Testing - 286 tests, including end-to-end against vcsim (ESXi + vCenter): provisioning with MAC, disk growth, status, config, removal. - vcsim surfaced two real bugs, both fixed and now pinned by tests: chunked upload with Content-Length gets a 500, and a device edit without its backing crashes vcsim. - ruff and mypy clean. - Unverified until netOrk#305: whether each distro's cloud kernel has the PVSCSI/VMXNET3 drivers. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
christianmanivong added 1 commit 2026-09-24 08:00:34 +00:00
create_vm_from_cloud_init takes the same qcow2/raw cloud images netOrk
offers for Proxmox. ESXi can neither boot nor download them, so the
driver does both: download with checksum check and one retry, convert
with qemu-img to a streamOptimized VMDK (cached by URL), import through
a minimal OVF descriptor over NFC, pin requested MACs, grow the disk,
and attach a NoCloud seed ISO placed next to the VM's files. NoCloud
rather than guestinfo because it needs nothing in the guest; the
user-data installs open-vm-tools, which the driver declares as its
guest agent. A failure after the import removes the VM again.

Placement is a pure decision over inventory rows: a connected host
outside maintenance mode that sees the datastore and every port group,
with the resource pool and VM folder found by walking up to the
datacenter -- one path for a standalone host and for a vCenter.

Two faults vcsim surfaced and the tests now pin: a chunked upload body
next to a Content-Length is refused with 500, so the disk goes up as a
sized file object that also reports lease progress; and a device edit
replaces the device as sent, so disk and NIC edits start from the live
objects, backing included (vcsim panicked on a disk without one).

destroy_vm, get_vm_status, get_network_targets (port groups with their
fixed VLAN) and get_image_storages complete the contract.

reboot_host on ESXi uses RebootHost_Task and refuses outside
maintenance mode: force=True would cut power to running VMs.

Tested against vcsim in ESXi and vCenter mode, end to end.
christianmanivong merged commit 25bad821ab into main 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-vmware#1