From 97cab9754b6912b1006b9a0e9e0fe5035e440e43 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Tue, 7 Jul 2026 00:53:06 +0200 Subject: [PATCH] Revert "Merge feature/generic-vm-provisioning: generalize create_vm_from_cloud_init interface" This reverts commit 7d18c125794ba85898cfe7efb9179eccb784fe1f, reversing changes made to 7f0dd789b023ce8de62f90dc0c01465c2e8c72ed. --- napalm_device_types/hypervisor.py | 37 ++++++++++++++++--------------- napalm_device_types/models.py | 9 -------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/napalm_device_types/hypervisor.py b/napalm_device_types/hypervisor.py index 1a4abaa..a3d1f8b 100644 --- a/napalm_device_types/hypervisor.py +++ b/napalm_device_types/hypervisor.py @@ -15,7 +15,6 @@ from napalm_device_types.base import DeviceTypeDriver from napalm_device_types._ucd_metrics import IF_SKIP_DEFAULT, collect_ucd_metrics from napalm_device_types.models import ( HealthMetricsDict, - NICConfigDict, PackageDict, SnapshotDict, StorageVolumeDict, @@ -550,36 +549,39 @@ class HypervisorDriver(DeviceTypeDriver): template: str, cpu: int, memory: int, - nics: List[NICConfigDict], + mgmt_bridge: str, + mgmt_vlan_tag: int | None, + capture_bridge: str, + capture_vlan_tags: List[int], cloud_init_config: Dict[str, Any], ssh_public_keys: List[str] | None = None, - disk_resize_gb: int | None = None, - timeout: int = 180, + timeout: int = 120, ) -> VMProvisionResultDict: """ Create a new virtual machine from a Cloud-Init template. - Clones a pre-existing VM template, configures virtual network interfaces, - and injects Cloud-Init configuration via a storage snippet or similar - mechanism. The resulting VM is left in a running state. + Clones a pre-existing VM template, configures dual NICs (management + + capture), and injects Cloud-Init configuration via a storage snippet or + similar mechanism. The resulting VM is left in a running state. Args: name (string) - new VM display name template (string) - hypervisor-internal ID/name of the template VM to clone cpu (int) - number of virtual CPUs to assign memory (int) - RAM to assign in megabytes - nics (list[NICConfigDict]) - list of network interface configurations. - First NIC is primary (DHCP by default); subsequent NICs are optional. - Each entry specifies bridge, optional vlan_tag (access) or trunk_vlan_tags, - and dhcp flag. + mgmt_bridge (string) - network bridge for management NIC (net0) + mgmt_vlan_tag (int | None) - VLAN tag for net0 (None → untagged) + capture_bridge (string) - network bridge for packet capture NIC (net1). + Must support ``vlan-aware`` and trunk mode. + capture_vlan_tags (list[int]) - VLAN tags to place on net1 (trunk). + Packets matching any of these VLANs are visible to the guest. cloud_init_config (dict) - user-data dict (will be rendered to YAML). - Should include hostname, bootstrap_token, runcmd, and any custom config. + Should include: ``bootstrap_token``, ``central_url``, ``satellite_id``, + ``runcmd`` for custom startup sequence. ssh_public_keys (list[str] | None) - SSH public keys to inject into guest. If None or empty, no SSH key injection is performed. - disk_resize_gb (int | None) - resize root disk to this size in GB. - If None, disk remains template size. Default None. timeout (int) - maximum seconds to wait for provisioning completion - (clone, config, start). Default 180. + (clone, config, start). Default 120. Returns: VMProvisionResultDict - ``{"vmid": str, "name": str, "node": str}`` @@ -646,9 +648,8 @@ class HypervisorDriver(DeviceTypeDriver): Returns: VMStatusDict - ``{"status": str, "ip_address": str, "hostname": str, - "mac_address": str}``. ip_address, hostname, and mac_address refer to - the primary NIC (first interface) and are only present if the VM is - running and has network info available. + "mac_address": str}``. ip_address, hostname, and mac_address are only + present if the VM is running and has network info available. Raises: RuntimeError - if the VM does not exist or if wait_for_ip=True and diff --git a/napalm_device_types/models.py b/napalm_device_types/models.py index 5c3f317..afe5807 100644 --- a/napalm_device_types/models.py +++ b/napalm_device_types/models.py @@ -706,15 +706,6 @@ class HealthMetricsDict(TypedDict): interfaces: NotRequired[Dict[str, HealthMetricsIfaceDict]] -class NICConfigDict(TypedDict): - """Network interface configuration for VM provisioning.""" - - bridge: str # Bridge or network name - vlan_tag: NotRequired[int | None] # Access VLAN (None = untagged) - trunk_vlan_tags: NotRequired[list[int]] # Trunk VLAN list (alternative to vlan_tag) - dhcp: NotRequired[bool] # Enable DHCP (default True for first NIC, False for others) - - class VMProvisionResultDict(TypedDict): """Return value of ``create_vm_from_cloud_init()`` — provisioned VM identifier."""