feat: NetworkTargetDict.uplinks, the NICs a bridge leaves through (NetOrk/netork#1325) #58
No files matched your search
@@ -18,6 +18,12 @@ recorded here; their history is the git log.
|
||||
in `get_arp_table` and `get_ipv6_neighbors_table` when the device does not say how
|
||||
old an entry is. `0.0` means "confirmed just now" and is no stand-in for it
|
||||
(NetOrk/netork#1327).
|
||||
- `NetworkTargetDict.uplinks` (optional): the physical NICs a bridge leaves the
|
||||
host through, one group per way out -- a bond's slaves together, a single NIC
|
||||
alone (`[["eno1", "eno2"]]`). A missing key means unknown, an empty list a
|
||||
bridge without uplink. NetOrk follows their LLDP neighbours to the switch port
|
||||
and its untagged VLAN; one slave's neighbour speaks for its bond
|
||||
(NetOrk/netork#1325).
|
||||
- `HostShutdownMixin.shutdown_host()`, on `DeviceTypeDriver`: shut the device itself
|
||||
down cleanly through its own means; declared, so `hasattr` says whether a driver
|
||||
can. No forced variant (NetOrk/netork#1636).
|
||||
|
||||
@@ -514,6 +514,14 @@ class ProxmoxDriver(HypervisorDriver):
|
||||
|
||||
def create_vm_snapshot(self, name, snapshot, description="", include_memory=False): ...
|
||||
|
||||
def get_network_targets(self):
|
||||
# return List[NetworkTargetDict]: bridges and vnets a new VM's NIC may
|
||||
# attach to; a bridge may name its physical NICs in `uplinks`, one group
|
||||
# per way out: [["eno1", "eno2"]] for a bond, [["eno1"]] for a single NIC,
|
||||
# no internal or VLAN ports -- leave the key out when they cannot be
|
||||
# determined
|
||||
...
|
||||
|
||||
def get_vm_cpu_types(self):
|
||||
# optional — return List[VMCpuTypeDict]: the CPU models a new VM may get
|
||||
# on this node, each with its cpuinfo flags and whether the node can run
|
||||
|
||||
@@ -613,7 +613,9 @@ class HypervisorDriver(PackageManagementMixin, HealthMetricsMixin, DeviceTypeDri
|
||||
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).
|
||||
per-kind rules). ``uplinks``, where the driver can tell, names
|
||||
the physical NICs a bridge leaves the host through, grouped:
|
||||
a bond's slaves in one group, a single NIC in its own.
|
||||
"""
|
||||
...
|
||||
|
||||
|
||||
@@ -1310,17 +1310,17 @@ class NetworkTargetDict(TypedDict):
|
||||
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``. That fixed VLAN
|
||||
is surfaced via ``fixed_vlan_tag`` instead, for display purposes.
|
||||
- OVS bridge: always vlan_aware (OVS tags per port, with no "VLAN aware" setting).
|
||||
- SDN vnet: never vlan_aware — its zone/tag fixes the VLAN (``fixed_vlan_tag``).
|
||||
``uplinks``: the physical NICs it leaves the host through, one group per way out
|
||||
(a bond's slaves together, a single NIC alone); no internal, VLAN or virtual ports.
|
||||
"""
|
||||
|
||||
name: str # Bridge, vnet or port group name, usable directly as NICConfigDict.bridge
|
||||
kind: str # "bridge", "vnet" or "portgroup" (VMware: VLAN fixed like a vnet's)
|
||||
vlan_aware: bool # True if a NICConfigDict.vlan_tag may be set on top of this target
|
||||
fixed_vlan_tag: NotRequired[int | None] # vnet only: the VLAN ID already baked into it
|
||||
uplinks: NotRequired[list[list[str]]] # NIC groups it leaves through; absent = unknown
|
||||
|
||||
|
||||
class StorageTargetDict(TypedDict):
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
"""A network target can say which physical NICs it leaves the host through.
|
||||
|
||||
A VM on a VLAN-aware bridge without a VLAN tag only gets an address when the
|
||||
switch port behind the bridge carries an untagged network. To look that port up,
|
||||
the caller needs the bridge's physical NICs: their LLDP neighbours name the
|
||||
switch and the port (NetOrk/netork#1325). They come in groups, one per way out
|
||||
of the bridge: a bond's slaves together, a single NIC alone. A bond has no
|
||||
neighbour of its own, and its slaves are one link, so one slave's neighbour
|
||||
speaks for the others when they report none.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import get_type_hints
|
||||
|
||||
from napalm_device_types.models import NetworkTargetDict
|
||||
|
||||
|
||||
def test_uplinks_is_an_optional_list_of_nic_groups():
|
||||
assert "uplinks" in NetworkTargetDict.__optional_keys__
|
||||
assert get_type_hints(NetworkTargetDict)["uplinks"] == list[list[str]]
|
||||
|
||||
|
||||
def test_contract_core_stays_required():
|
||||
assert {"name", "kind", "vlan_aware"} <= NetworkTargetDict.__required_keys__
|
||||
Reference in new issue
Block a user