Fix empty Sonic discovery: KnownContainers fallback and clearer domain status.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -39,6 +39,12 @@ public sealed class SonicConnection
|
||||
/// </summary>
|
||||
public string SonicHome { get; init; } = @"C:\Sonic\MQ10.0";
|
||||
|
||||
/// <summary>
|
||||
/// Bekannte Container-Namen dieser Domain (Fallback, wenn Remote-Discovery nichts findet).
|
||||
/// z.B. [ "ESB", "DomainManager" ] oder vollqualifiziert [ "proalpha-test.ESB" ].
|
||||
/// </summary>
|
||||
public List<string> KnownContainers { get; init; } = [];
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// HTTP REST API (ManagementMode = HttpApi)
|
||||
// ---------------------------------------------------------------
|
||||
@@ -127,21 +133,63 @@ public sealed class SonicConnection
|
||||
"""
|
||||
$ErrorActionPreference = 'Continue'
|
||||
$sonicHome = '{sonicHome}'
|
||||
$names = @()
|
||||
$domain = '{domain}'
|
||||
$names = New-Object System.Collections.Generic.List[string]
|
||||
|
||||
# Windows-Dienste mit Sonic/ESB im Namen
|
||||
$names += @(Get-Service -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.DisplayName -match 'Sonic|ESB|MQ' -or $_.Name -match 'Sonic|ESB|MQ' } |
|
||||
Select-Object -ExpandProperty Name)
|
||||
|
||||
# Container-Cache-Ordner unter SonicHome (Domain.Container.cache)
|
||||
if (Test-Path -LiteralPath $sonicHome) {
|
||||
$names += @(Get-ChildItem -LiteralPath $sonicHome -Directory -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Name -like '*.cache' } |
|
||||
ForEach-Object { $_.Name -replace '\.cache$', '' })
|
||||
function Add-Name([string]$n) {
|
||||
if ([string]::IsNullOrWhiteSpace($n)) { return }
|
||||
$n = $n.Trim()
|
||||
if (-not $names.Contains($n)) { [void]$names.Add($n) }
|
||||
}
|
||||
|
||||
$names | Where-Object { $_ } | Sort-Object -Unique
|
||||
if (-not (Test-Path -LiteralPath $sonicHome)) {
|
||||
Write-Output "WARN:SonicHomeNichtGefunden:$sonicHome"
|
||||
}
|
||||
else {
|
||||
Write-Output "INFO:SonicHomeOk:$sonicHome"
|
||||
|
||||
# *.cache Ordner (Domain.Container.cache) – 1–2 Ebenen
|
||||
Get-ChildItem -LiteralPath $sonicHome -Directory -ErrorAction SilentlyContinue |
|
||||
ForEach-Object {
|
||||
if ($_.Name -like '*.cache') {
|
||||
Add-Name ($_.Name -replace '\.cache$', '')
|
||||
}
|
||||
Get-ChildItem -LiteralPath $_.FullName -Directory -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Name -like '*.cache' } |
|
||||
ForEach-Object { Add-Name ($_.Name -replace '\.cache$', '') }
|
||||
}
|
||||
|
||||
# container.xml / Containers-Verzeichnisse
|
||||
Get-ChildItem -LiteralPath $sonicHome -Recurse -Filter 'container.xml' -File -ErrorAction SilentlyContinue |
|
||||
Select-Object -First 40 |
|
||||
ForEach-Object {
|
||||
$parent = Split-Path $_.DirectoryName -Leaf
|
||||
Add-Name $parent
|
||||
}
|
||||
}
|
||||
|
||||
# Windows-Dienste
|
||||
Get-Service -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.DisplayName -match 'Sonic|ESB|MQ|Aurea' -or $_.Name -match 'Sonic|ESB|MQ|Aurea' } |
|
||||
ForEach-Object {
|
||||
Add-Name $_.Name
|
||||
Add-Name $_.DisplayName
|
||||
}
|
||||
|
||||
# Prozess-Hinweise (laufende Container)
|
||||
Get-CimInstance Win32_Process -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.CommandLine -match 'sonic|mf\.framework|container\.xml' } |
|
||||
ForEach-Object {
|
||||
if ($_.CommandLine -match '([A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+)\.cache') {
|
||||
Add-Name $Matches[1]
|
||||
}
|
||||
}
|
||||
|
||||
if ($names.Count -eq 0 -and -not [string]::IsNullOrWhiteSpace($domain)) {
|
||||
Write-Output "WARN:KeineContainerGefunden Domain=$domain SonicHome=$sonicHome"
|
||||
}
|
||||
|
||||
$names | Sort-Object -Unique
|
||||
""";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user