feat(storage): add -Target and -Portal parameters to New-PveStorage for iSCSI

New-PveStorage now supports configuring iSCSI storage backends natively:
  -Target: iSCSI target IQN (e.g. iqn.2024-01.com.example:storage)
  -Portal: iSCSI portal address (host:port, defaults to server:3260)

Also refactored ProcessRecord to use AddIfNotEmpty helper, reducing
cognitive complexity.

Added unit tests for all iSCSI/NFS parameter metadata and a new
SharedStorage.Tests.ps1 integration test file that tests NFS and iSCSI
storage create/verify/status/delete lifecycle against the Docker-based
storage containers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Clint Branham
2026-03-24 14:43:33 -05:00
parent ab768e114a
commit 064cc372cf
3 changed files with 246 additions and 10 deletions
@@ -171,6 +171,48 @@ Describe 'New-PveStorage' {
$isMandatory | Should -Not -BeNullOrEmpty
}
}
Context 'iSCSI/NFS parameters' {
It 'Should have Target parameter for iSCSI IQN' {
Skip-IfMissing 'New-PveStorage'
$script:Cmd.Parameters.ContainsKey('Target') | Should -BeTrue
}
It 'Target should not be Mandatory' {
Skip-IfMissing 'New-PveStorage'
$isMandatory = $script:Cmd.Parameters['Target'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -BeNullOrEmpty
}
It 'Should have Portal parameter for iSCSI portal' {
Skip-IfMissing 'New-PveStorage'
$script:Cmd.Parameters.ContainsKey('Portal') | Should -BeTrue
}
It 'Portal should not be Mandatory' {
Skip-IfMissing 'New-PveStorage'
$isMandatory = $script:Cmd.Parameters['Portal'].ParameterSets.Values |
Where-Object { $_.IsMandatory }
$isMandatory | Should -BeNullOrEmpty
}
It 'Should have Server parameter for NFS/iSCSI server' {
Skip-IfMissing 'New-PveStorage'
$script:Cmd.Parameters.ContainsKey('Server') | Should -BeTrue
}
It 'Should have Export parameter for NFS export path' {
Skip-IfMissing 'New-PveStorage'
$script:Cmd.Parameters.ContainsKey('Export') | Should -BeTrue
}
It 'Should have Shared switch parameter' {
Skip-IfMissing 'New-PveStorage'
$script:Cmd.Parameters.ContainsKey('Shared') | Should -BeTrue
$script:Cmd.Parameters['Shared'].ParameterType | Should -Be ([System.Management.Automation.SwitchParameter])
}
}
}
# ---------------------------------------------------------------------------