Merge feature/network-target-vlan-tag: expose fixed VLAN tag for SDN vnets
This commit is contained in:
@@ -415,6 +415,15 @@ class ProxmoxVMProvisionMixin:
|
|||||||
if not name:
|
if not name:
|
||||||
continue
|
continue
|
||||||
# A vnet's VLAN is already fixed by its zone/tag — no separate vlan_tag applies.
|
# A vnet's VLAN is already fixed by its zone/tag — no separate vlan_tag applies.
|
||||||
targets.append({"name": name, "kind": "vnet", "vlan_aware": False})
|
tag = vnet.get("tag")
|
||||||
|
fixed_vlan_tag = int(tag) if tag is not None else None
|
||||||
|
targets.append(
|
||||||
|
{
|
||||||
|
"name": name,
|
||||||
|
"kind": "vnet",
|
||||||
|
"vlan_aware": False,
|
||||||
|
"fixed_vlan_tag": fixed_vlan_tag,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return targets
|
return targets
|
||||||
|
|||||||
@@ -472,3 +472,42 @@ def test_get_network_targets_sdn_vnet_never_vlan_aware():
|
|||||||
assert len(targets) == 2
|
assert len(targets) == 2
|
||||||
assert all(t["kind"] == "vnet" for t in targets)
|
assert all(t["kind"] == "vnet" for t in targets)
|
||||||
assert all(t["vlan_aware"] is False for t in targets)
|
assert all(t["vlan_aware"] is False for t in targets)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_network_targets_vnet_exposes_fixed_vlan_tag():
|
||||||
|
"""A vnet's fixed_vlan_tag surfaces its SDN tag for display purposes."""
|
||||||
|
mixin = ProxmoxVMProvisionMixin()
|
||||||
|
mixin._get_node_network = MagicMock(return_value=[])
|
||||||
|
mixin._get_sdn_vnets = MagicMock(
|
||||||
|
return_value=[{"vnet": "vnet0", "zone": "zone-vlan", "tag": 10}]
|
||||||
|
)
|
||||||
|
|
||||||
|
targets = mixin.get_network_targets()
|
||||||
|
|
||||||
|
assert targets[0]["fixed_vlan_tag"] == 10
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_network_targets_vnet_without_tag_has_none_fixed_vlan_tag():
|
||||||
|
"""A vnet with no tag (e.g. VXLAN/EVPN zone) reports fixed_vlan_tag=None."""
|
||||||
|
mixin = ProxmoxVMProvisionMixin()
|
||||||
|
mixin._get_node_network = MagicMock(return_value=[])
|
||||||
|
mixin._get_sdn_vnets = MagicMock(
|
||||||
|
return_value=[{"vnet": "vnet2", "zone": "zone-vxlan"}]
|
||||||
|
)
|
||||||
|
|
||||||
|
targets = mixin.get_network_targets()
|
||||||
|
|
||||||
|
assert targets[0]["fixed_vlan_tag"] is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_network_targets_bridge_has_no_fixed_vlan_tag():
|
||||||
|
"""Bridges never carry a single fixed VLAN tag — only vnets do."""
|
||||||
|
mixin = ProxmoxVMProvisionMixin()
|
||||||
|
mixin._get_node_network = MagicMock(
|
||||||
|
return_value=[{"iface": "vmbr0", "type": "bridge", "bridge_vlan_aware": 1}]
|
||||||
|
)
|
||||||
|
mixin._get_sdn_vnets = MagicMock(return_value=[])
|
||||||
|
|
||||||
|
targets = mixin.get_network_targets()
|
||||||
|
|
||||||
|
assert "fixed_vlan_tag" not in targets[0] or targets[0]["fixed_vlan_tag"] is None
|
||||||
|
|||||||
Reference in New Issue
Block a user