Slim MfApi stack to restart-only path.

Drop ping/list discovery, WinRM scripts, and heavy Java probing so only KnownContainers + MBean restart remain.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-24 12:32:05 +02:00
co-authored by Cursor
parent ade63d0e43
commit c73f53d740
9 changed files with 253 additions and 3157 deletions
@@ -3,7 +3,7 @@ using ZA.CoreService.ESBCertificateManager.Models;
namespace ZA.CoreService.ESBCertificateManager.Services;
/// <summary>
/// Sonic MfApi (wie SMC-Neustart) ohne WinRM/HTTP/XApi.
/// Schlanke Fassade: nur Container-Neustart über MfApi.
/// </summary>
public sealed class SonicManagementClient : IDisposable
{
@@ -16,45 +16,6 @@ public sealed class SonicManagementClient : IDisposable
_mfApi = new SonicMfApiExecutor(connection);
}
public async Task<(bool Success, string? Error, string? ResolvedPath)> CheckConnectionAsync(
CancellationToken cancellationToken = default)
{
(bool ok, string? error) = await _mfApi.TestConnectionAsync(cancellationToken);
if (ok)
{
return (true, null, $"MfApi {_connection.ConnectionUrl} Domain={_connection.DomainName}");
}
if (_connection.KnownContainers.Count > 0
&& await IsTcpReachableAsync(_connection.ConnectionUrl, cancellationToken))
{
return (true, null,
$"MfApi-Ping fehlgeschlagen, KnownContainers/TCP ok. Hinweis: {Truncate(error)}");
}
return (false, error ?? "MfApi-Verbindung fehlgeschlagen", null);
}
public async Task<(bool Success, IReadOnlyList<string> ContainerNames, string? Error)> GetContainersAsync(
CancellationToken cancellationToken = default)
{
(bool ok, IReadOnlyList<string> names, string? error) =
await _mfApi.ListContainersAsync(cancellationToken);
if (ok && names.Count > 0)
{
return (true, names, null);
}
if (_connection.KnownContainers.Count > 0)
{
return (true, _connection.KnownContainers,
ok ? null : $"Liste leer/fehlerhaft KnownContainers. {error}");
}
return (false, [], error ?? "Keine Container gefunden.");
}
public async Task<(bool Success, string Status, string? Detail)> RestartContainerAsync(
string containerName,
CancellationToken cancellationToken = default)
@@ -77,27 +38,6 @@ public sealed class SonicManagementClient : IDisposable
$"Fehler: {error}\n\n{output}");
}
private static async Task<bool> IsTcpReachableAsync(string connectionUrl, CancellationToken cancellationToken)
{
try
{
Uri uri = new(connectionUrl);
using System.Net.Sockets.TcpClient tcp = new();
using CancellationTokenSource cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
cts.CancelAfter(TimeSpan.FromSeconds(5));
await tcp.ConnectAsync(uri.Host, uri.Port > 0 ? uri.Port : 2506, cts.Token);
return true;
}
catch
{
return false;
}
}
private static string Truncate(string? s, int max = 180)
=> string.IsNullOrWhiteSpace(s) ? string.Empty
: s.Length <= max ? s : s[..max] + "…";
public void Dispose()
{
}