feat(stagging): add version dropdowns and configurable ISO source in 0.4.0
This commit is contained in:
@@ -54,7 +54,10 @@ function Read-KisWorkbook([string]$Path) {
|
||||
foreach ($key in $sheets.Staging.Cells.Keys) {
|
||||
if ($key -notmatch '^A(\d+)$') { continue }
|
||||
$row = $Matches[1]; $name = $sheets.Staging.Cells[$key]
|
||||
if ($name -notin @('Projektname','Windows-Server-Version','Netzwerkkarte','GETAC-IP','Netzpräfix','DHCP von','DHCP bis','Medienordner','Proxmox-Medium','ESXi-Medium','Admin-E-Mail','DNS-Zone','GETAC-Name')) { continue }
|
||||
# Retain the internal keys for older KIS workbooks and scripts.
|
||||
if ($name -eq 'ISO-Name Proxmox') { $name='Proxmox-Medium' }
|
||||
if ($name -eq 'ISO-Name ESXi') { $name='ESXi-Medium' }
|
||||
if ($name -notin @('Projektname','Windows-Server-Version','Netzwerkkarte','GETAC-IP','Netzpräfix','DHCP von','DHCP bis','Medienordner','Proxmox-Medium','ESXi-Medium','ISO-Ablage','Admin-E-Mail','DNS-Zone','GETAC-Name')) { continue }
|
||||
if ($sheets.Staging.Formulas.ContainsKey("B$row")) { throw "Staging!B${row}: Eingabeformeln sind nicht erlaubt." }
|
||||
if ($settings.ContainsKey($name)) { throw "Doppelte Staging-Einstellung: $name" }
|
||||
$settings[$name] = [string]$sheets.Staging.Cells["B$row"]
|
||||
@@ -100,6 +103,26 @@ function Assert-Text([string]$Value,[string]$Pattern,[string]$Label) {
|
||||
if ([string]::IsNullOrWhiteSpace($Value) -or $Value -notmatch $Pattern) { throw "${Label}: fehlt oder ungueltiges Format." }
|
||||
}
|
||||
|
||||
function Get-IsoPath($Settings,[string]$FileName) {
|
||||
# An explicitly blank new field must never silently choose another source.
|
||||
$folder=if ($Settings.ContainsKey('ISO-Ablage')) { [string]$Settings['ISO-Ablage'] } else { [string]$Settings.Medienordner }
|
||||
$folder=$folder.Trim()
|
||||
if (-not $folder) { throw 'ISO-Ablage fehlt. Vor Schritt 03 lokalen Ordner oder UNC-Freigabe eintragen.' }
|
||||
Assert-Text $FileName '^[^\\/:*?"<>|\x00-\x1f]+\.iso$' 'ISO-Name (nur Dateiname)'
|
||||
if ($folder -match '^[a-zA-Z]:\\' -or $folder.StartsWith('\\')) {
|
||||
if ($folder -match '^[a-zA-Z]:\\') { $tail=$folder.Substring(3) }
|
||||
else {
|
||||
if ($folder -notmatch '^\\\\[^\\/:*?"<>|\x00-\x1f]+\\[^\\/:*?"<>|\x00-\x1f]+(?:\\.*)?$' -or $folder.StartsWith('\\?\') -or $folder.StartsWith('\\.\')) { throw 'ISO-Ablage: UNC-Pfad muss Server und Freigabe enthalten, z.B. \\fileserver\ISOs.' }
|
||||
$tail=$folder.Substring(2)
|
||||
}
|
||||
if ($tail -match '[/<>:"|?*\x00-\x1f]' -or $tail -match '(?:^|\\)\.{1,2}(?:\\|$)' -or $tail -match '[. ](?:\\|$)') { throw 'ISO-Ablage enthaelt ungueltige Pfadbestandteile.' }
|
||||
return $folder.TrimEnd('\')+'\'+$FileName
|
||||
}
|
||||
# Permit native absolute paths for the existing macOS/Linux validation tests.
|
||||
if ([Environment]::OSVersion.Platform -ne [PlatformID]::Win32NT -and $folder.StartsWith('/') -and $folder -notmatch '(?:^|/)\.{1,2}(?:/|$)') { return Join-Path $folder $FileName }
|
||||
throw 'ISO-Ablage: absoluten lokalen Windows-Pfad oder UNC-Freigabe verwenden, keine URL oder relativen Pfade.'
|
||||
}
|
||||
|
||||
function Get-InstallPlan($Config, [switch]$CheckMedia) {
|
||||
$s=$Config.Settings; $hosts=@($Config.Servers)
|
||||
if ($hosts.Count -eq 0) { return @() }
|
||||
@@ -147,9 +170,8 @@ function Get-InstallPlan($Config, [switch]$CheckMedia) {
|
||||
}
|
||||
default { throw "$label System muss Proxmox VE oder VMware ESXi sein." }
|
||||
}
|
||||
Assert-Text $mediaName '^[^\\/:*?"<>|]+\.iso$' "$label Installationsmedium (ISO-Dateiname)"
|
||||
$media=Join-Path $s.Medienordner $mediaName
|
||||
if ($CheckMedia -and -not (Test-Path -LiteralPath $media -PathType Leaf)) { throw "Installationsmedium fehlt: $media" }
|
||||
$media=Get-IsoPath $s $mediaName
|
||||
if ($CheckMedia -and -not (Test-Path -LiteralPath $media -PathType Leaf)) { throw "ISO fehlt oder ist mit dem aktuellen Windows-Konto nicht erreichbar: $media" }
|
||||
$result += [pscustomobject]@{ Name=$h.Servername; Mac=$mac; Platform=$platform; Version=$version; Disk=$h.Installationsdatenträger; IP=$h['Ziel-IP']; Prefix=[int]$h['Präfix']; Gateway=$h.Gateway; DNS=$dns; Media=$media; FileName=$file }
|
||||
}
|
||||
foreach ($h in $result) { if ($seenIp.ContainsKey($h.Gateway)) { throw 'Gateway darf keine ausgewaehlte Zielserver-IP sein.' } }
|
||||
|
||||
Reference in New Issue
Block a user