Merge feature/network-targets: add get_network_targets() interface

This commit is contained in:
2026-07-07 09:09:57 +02:00
2 changed files with 36 additions and 0 deletions
+19
View File
@@ -16,6 +16,7 @@ from napalm_device_types._ucd_metrics import IF_SKIP_DEFAULT, collect_ucd_metric
from napalm_device_types.models import (
HealthMetricsDict,
NICConfigDict,
NetworkTargetDict,
PackageDict,
SnapshotDict,
StorageVolumeDict,
@@ -655,3 +656,21 @@ class HypervisorDriver(DeviceTypeDriver):
timeout is exceeded.
"""
raise NotImplementedError
def get_network_targets(self) -> List[NetworkTargetDict]:
"""
List the network targets a new VM's NIC may attach to.
Returns only targets that are actually valid ``NICConfigDict.bridge``
values — real bridges (Linux or OVS) and SDN network segments (vnets).
Physical NICs, bonds, and other non-bridge interface types are excluded,
since VMs cannot attach directly to them on any hypervisor this interface
supports.
Returns:
List[NetworkTargetDict] - each entry's ``vlan_aware`` flag tells the
caller whether a ``NICConfigDict.vlan_tag`` may additionally be set
for a NIC using that target (see ``NetworkTargetDict`` for the
per-kind rules).
"""
raise NotImplementedError
+17
View File
@@ -730,3 +730,20 @@ class VMStatusDict(TypedDict):
ip_address: NotRequired[str] # Management NIC IP (absent if VM has no IP or is stopped)
hostname: NotRequired[str] # Hostname resolved from IP (if available)
mac_address: NotRequired[str] # MAC of management NIC
class NetworkTargetDict(TypedDict):
"""A selectable network target for a new VM's NIC (``NICConfigDict.bridge``).
Distinguishes real bridges (Linux or OVS) from SDN network segments (vnets),
and tells the caller whether a separate ``vlan_tag`` may be applied on top:
- Linux bridge: vlan_aware reflects the bridge's own ``bridge_vlan_aware`` flag.
- OVS bridge: always vlan_aware (OVS bridges tag per-port regardless of a
dedicated "VLAN aware" setting).
- SDN vnet: never vlan_aware — the VLAN is already fixed by the vnet's zone/tag,
so a NIC attached to it must not also carry a ``vlan_tag``.
"""
name: str # Bridge or vnet name, usable directly as NICConfigDict.bridge
kind: str # "bridge" or "vnet"
vlan_aware: bool # True if a NICConfigDict.vlan_tag may be set on top of this target