mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-09-03 18:55:33 +00:00
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:
@@ -3,6 +3,13 @@
|
||||
BeforeAll {
|
||||
. $PSScriptRoot/_IntegrationHelper.ps1
|
||||
Connect-TestPve
|
||||
|
||||
function Get-PveBridge99 {
|
||||
$bridge = Get-PveNetwork -Node $script:Node |
|
||||
Where-Object { $_.Iface -eq 'vmbr99' }
|
||||
$bridge | Should -Not -BeNullOrEmpty
|
||||
$bridge
|
||||
}
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
@@ -42,6 +49,7 @@ Describe 'Network — Integration' -Tag 'Integration' {
|
||||
-Iface 'vmbr99' `
|
||||
-Type 'bridge' `
|
||||
-Autostart `
|
||||
-BridgeVlanAware `
|
||||
-ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
|
||||
@@ -53,6 +61,35 @@ Describe 'Network — Integration' -Tag 'Integration' {
|
||||
Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It 'Should report the new bridge as VLAN aware' {
|
||||
if (Skip-IfNoTarget) { return }
|
||||
|
||||
$bridge = Get-PveBridge99
|
||||
$bridge.BridgeVlanAware | Should -Be 1
|
||||
}
|
||||
|
||||
It 'Should disable VLAN awareness via Set-PveNetwork' {
|
||||
if (Skip-IfNoTarget) { return }
|
||||
|
||||
(Get-PveBridge99).BridgeVlanAware | Should -Be 1
|
||||
|
||||
Set-PveNetwork -Node $script:Node -Iface 'vmbr99' -Type 'bridge' `
|
||||
-BridgeVlanAware:$false -ErrorAction Stop
|
||||
|
||||
(Get-PveBridge99).BridgeVlanAware | Should -BeIn @($null, 0)
|
||||
}
|
||||
|
||||
It 'Should re-enable VLAN awareness via Set-PveNetwork' {
|
||||
if (Skip-IfNoTarget) { return }
|
||||
|
||||
(Get-PveBridge99).BridgeVlanAware | Should -BeIn @($null, 0)
|
||||
|
||||
Set-PveNetwork -Node $script:Node -Iface 'vmbr99' -Type 'bridge' `
|
||||
-BridgeVlanAware -ErrorAction Stop
|
||||
|
||||
(Get-PveBridge99).BridgeVlanAware | Should -Be 1
|
||||
}
|
||||
|
||||
It 'Should update bridge comments' {
|
||||
if (Skip-IfNoTarget) { return }
|
||||
|
||||
@@ -64,6 +101,12 @@ Describe 'Network — Integration' -Tag 'Integration' {
|
||||
-ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
|
||||
It 'Should leave VLAN awareness alone when the switch is not passed' {
|
||||
if (Skip-IfNoTarget) { return }
|
||||
|
||||
(Get-PveBridge99).BridgeVlanAware | Should -Be 1
|
||||
}
|
||||
|
||||
It 'Should remove the bridge' {
|
||||
if (Skip-IfNoTarget) { return }
|
||||
|
||||
|
||||
@@ -117,6 +117,15 @@ Describe 'New-PveNetwork' {
|
||||
}
|
||||
}
|
||||
|
||||
Context 'VLAN-aware bridge' {
|
||||
It 'Should expose BridgeVlanAware as a switch' {
|
||||
Skip-IfMissing 'New-PveNetwork'
|
||||
$script:Cmd.Parameters.ContainsKey('BridgeVlanAware') | Should -BeTrue
|
||||
$script:Cmd.Parameters['BridgeVlanAware'].ParameterType |
|
||||
Should -Be ([System.Management.Automation.SwitchParameter])
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Required parameters' {
|
||||
It 'Node should be Mandatory' {
|
||||
Skip-IfMissing 'New-PveNetwork'
|
||||
@@ -162,6 +171,15 @@ Describe 'Set-PveNetwork' {
|
||||
}
|
||||
}
|
||||
|
||||
Context 'VLAN-aware bridge' {
|
||||
It 'Should expose BridgeVlanAware as a switch' {
|
||||
Skip-IfMissing 'Set-PveNetwork'
|
||||
$script:Cmd.Parameters.ContainsKey('BridgeVlanAware') | Should -BeTrue
|
||||
$script:Cmd.Parameters['BridgeVlanAware'].ParameterType |
|
||||
Should -Be ([System.Management.Automation.SwitchParameter])
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Required parameters' {
|
||||
It 'Node should be Mandatory' {
|
||||
Skip-IfMissing 'Set-PveNetwork'
|
||||
|
||||
Reference in New Issue
Block a user