feat: VLAN-aware bridges via New-PveNetwork and Set-PveNetwork

PveNetwork already deserialised bridge_vlan_aware as BridgeVlanAware, so a
VLAN-aware bridge could be read back but never created or changed. Both write
paths now take a -BridgeVlanAware switch.

Clearing the flag does not use bridge_vlan_aware=0. PVE merges the supplied
keys onto the stored stanza and accepts that 0 without acting on it, so the
obvious form is a silent no-op: an integration run against PVE 9 issued it and
Get-PveNetwork still reported 1. The endpoint's delete list is what actually
removes the key. The API schema advertises a plain boolean and gives no hint of
this, which is why the behaviour is pinned by an integration test rather than
inferred.

Set-PveNetwork guards the switch on BoundParameters so an update that omits it
leaves the flag alone; the create path follows the existing -Autostart form.
Only bridge_vlan_aware is added. bridge_vids is an independent parameter that
PVE defaults to 2-4094, and the issue asks only for the flag.

Coverage: the integration suite pins create, disable, re-enable, and that an
unrelated Set leaves the flag alone -- that last one kills a mutant that drops
the BoundParameters guard, which every other test survives. A model test pins
the read path the assertions depend on. The Pester unit tests assert only
parameter metadata; the defect is server-side, so nothing offline can catch it.

Closes #92
This commit is contained in:
goodolclint-claude[bot]
2026-09-01 22:53:26 -05:00
parent fc3c7ffff4
commit 2dff02f2bd
8 changed files with 131 additions and 2 deletions
@@ -42,6 +42,10 @@ namespace PSProxmoxVE.Cmdlets.Network
[Parameter(Mandatory = false, HelpMessage = "IPv4 gateway address.")]
public string? Gateway { get; set; }
/// <summary>Enable VLAN-aware bridging (802.1Q) on this bridge.</summary>
[Parameter(Mandatory = false, HelpMessage = "Enable VLAN-aware bridging on this bridge.")]
public SwitchParameter BridgeVlanAware { get; set; }
/// <summary>Bridge ports (space-separated interface names, for bridge type).</summary>
[Parameter(Mandatory = false, HelpMessage = "Bridge ports (space-separated interface names).")]
public string? BridgePorts { get; set; }
@@ -85,6 +89,7 @@ namespace PSProxmoxVE.Cmdlets.Network
if (!string.IsNullOrEmpty(Netmask)) data["netmask"] = Netmask!;
if (!string.IsNullOrEmpty(Gateway)) data["gateway"] = Gateway!;
if (!string.IsNullOrEmpty(BridgePorts)) data["bridge_ports"] = BridgePorts!;
if (BridgeVlanAware.IsPresent) data["bridge_vlan_aware"] = "1";
if (!string.IsNullOrEmpty(BondSlaves)) data["slaves"] = BondSlaves!;
if (VlanId.HasValue) data["vlan-id"] = VlanId.Value.ToString();
if (Mtu.HasValue) data["mtu"] = Mtu.Value.ToString();
@@ -52,6 +52,10 @@ namespace PSProxmoxVE.Cmdlets.Network
[Parameter(Mandatory = false, HelpMessage = "IPv6 gateway address.")]
public string? Gateway6 { get; set; }
/// <summary>Enable or disable VLAN-aware bridging (802.1Q) on this bridge.</summary>
[Parameter(Mandatory = false, HelpMessage = "Enable or disable VLAN-aware bridging on this bridge.")]
public SwitchParameter BridgeVlanAware { get; set; }
/// <summary>Bridge ports (space-separated interface names).</summary>
[Parameter(Mandatory = false, HelpMessage = "Bridge ports (space-separated interface names).")]
public string? BridgePorts { get; set; }
@@ -93,6 +97,13 @@ namespace PSProxmoxVE.Cmdlets.Network
if (Netmask6.HasValue) data["netmask6"] = Netmask6.Value.ToString();
if (!string.IsNullOrEmpty(Gateway6)) data["gateway6"] = Gateway6!;
if (!string.IsNullOrEmpty(BridgePorts)) data["bridge_ports"] = BridgePorts!;
// PVE merges the supplied keys onto the stored stanza, and accepts
// bridge_vlan_aware=0 without acting on it.
if (MyInvocation.BoundParameters.ContainsKey(nameof(BridgeVlanAware)))
{
if (BridgeVlanAware.IsPresent) data["bridge_vlan_aware"] = "1";
else data["delete"] = "bridge_vlan_aware";
}
if (!string.IsNullOrEmpty(BondSlaves)) data["slaves"] = BondSlaves!;
if (Mtu.HasValue) data["mtu"] = Mtu.Value.ToString();
if (Autostart.IsPresent) data["autostart"] = "1";