Explain SMC-only install: no stopcontainer.bat, fallback to MfApi.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -200,11 +200,49 @@ public sealed class SonicManagementClient : IDisposable
|
||||
|
||||
if (UsesScripts)
|
||||
{
|
||||
// LocalCmd / WinRm: bevorzugter Doku-Weg über die .bat-Dateien (ohne extra Java-Suche).
|
||||
if (Mode == SonicManagementMode.LocalCmd)
|
||||
{
|
||||
return await new SonicBinRestartExecutor(_connection)
|
||||
.RestartAsync(containerName, cancellationToken);
|
||||
(bool binOk, string binStatus, string? binDetail) =
|
||||
await new SonicBinRestartExecutor(_connection)
|
||||
.RestartAsync(containerName, cancellationToken);
|
||||
|
||||
if (binOk)
|
||||
{
|
||||
return (true, binStatus, binDetail);
|
||||
}
|
||||
|
||||
// Reine SMC/Client-Installation ohne Server-bin → wie die Console selbst
|
||||
// über ConnectionUrl + SMC-Login (MfApi) neu starten.
|
||||
bool batsMissing = binDetail?.Contains("stopcontainer", StringComparison.OrdinalIgnoreCase) == true
|
||||
|| binStatus.Contains("SonicBin", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (batsMissing)
|
||||
{
|
||||
SonicMfApiExecutor mf = new(_connection);
|
||||
(bool mfOk, string? mfOut, string? mfErr) =
|
||||
await mf.RestartAsync(containerName, cancellationToken);
|
||||
if (mfOk)
|
||||
{
|
||||
await Task.Delay(
|
||||
TimeSpan.FromSeconds(Math.Clamp(_connection.PostRestartDelaySeconds, 0, 120)),
|
||||
cancellationToken);
|
||||
return (true, $"Container '{containerName}' neugestartet (SMC/MfApi)",
|
||||
$"Kein stopcontainer.bat unter SonicHome – SMC-Verbindung genutzt.\n{mfOut}");
|
||||
}
|
||||
|
||||
return (false, "Neustart fehlgeschlagen",
|
||||
"Ursache: Unter SonicHome fehlen stopcontainer.bat/startcontainer.bat.\n" +
|
||||
"Das ist typisch, wenn nur die Sonic Management Console (Client) installiert ist –\n" +
|
||||
"die Scripts liegen auf dem Sonic-SERVER.\n\n" +
|
||||
$"SonicBin: {binDetail}\n\n" +
|
||||
$"SMC/MfApi-Fallback: {mfErr}\n{mfOut}\n\n" +
|
||||
"Was tun:\n" +
|
||||
"1) SonicHome auf den Server-Pfad setzen (Ordner mit bin\\stopcontainer.bat), ODER\n" +
|
||||
"2) Java + Client-JARs unter SonicHome\\lib bereitstellen (wie SMC),\n" +
|
||||
" ConnectionUrl/User/Pass = dieselben Werte wie beim SMC-Login.");
|
||||
}
|
||||
|
||||
return (false, binStatus, binDetail);
|
||||
}
|
||||
|
||||
return await RestartViaScriptAsync(containerName, cancellationToken);
|
||||
|
||||
Reference in New Issue
Block a user