Implements bringOffline for codex nodes

This commit is contained in:
benbierens 2023-09-13 12:09:44 +02:00
parent 53bb9968ff
commit d1895bab02
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 33 additions and 33 deletions

View File

@ -13,8 +13,11 @@ namespace CodexPlugin
public class CodexNodeGroup : ICodexNodeGroup
{
public CodexNodeGroup(IPluginTools tools, RunningContainers[] containers, ICodexNodeFactory codexNodeFactory)
private readonly CodexStarter starter;
public CodexNodeGroup(CodexStarter starter, IPluginTools tools, RunningContainers[] containers, ICodexNodeFactory codexNodeFactory)
{
this.starter = starter;
Containers = containers;
Nodes = containers.Containers().Select(c => CreateOnlineCodexNode(c, tools, codexNodeFactory)).ToArray();
Version = new CodexDebugVersionResponse();
@ -30,11 +33,8 @@ namespace CodexPlugin
public void BringOffline()
{
//lifecycle.CodexStarter.BringOffline(this);
//var result = Setup;
starter.BringOffline(this);
// Clear everything. Prevent accidental use.
//Setup = null!;
Nodes = Array.Empty<OnlineCodexNode>();
Containers = null!;
}

View File

@ -54,27 +54,27 @@ namespace CodexPlugin
public void BringOffline(CodexNodeGroup group)
{
//LogStart($"Stopping {group.Describe()}...");
//var workflow = CreateWorkflow();
//foreach (var c in group.Containers)
//{
// StopCrashWatcher(c);
// workflow.Stop(c);
//}
//LogEnd("Stopped.");
Log($"Stopping {group.Describe()}...");
var workflow = pluginTools.CreateWorkflow();
foreach (var c in group.Containers)
{
StopCrashWatcher(c);
workflow.Stop(c);
}
Log("Stopped.");
}
public void DeleteAllResources()
{
//var workflow = CreateWorkflow();
//workflow.DeleteTestResources();
}
//public void DeleteAllResources()
//{
// //var workflow = CreateWorkflow();
// //workflow.DeleteTestResources();
//}
public void DownloadLog(RunningContainer container, ILogHandler logHandler, int? tailLines)
{
//var workflow = CreateWorkflow();
//workflow.DownloadContainerLog(container, logHandler, tailLines);
}
//public void DownloadLog(RunningContainer container, ILogHandler logHandler, int? tailLines)
//{
// //var workflow = CreateWorkflow();
// //workflow.DownloadContainerLog(container, logHandler, tailLines);
//}
//private IMetricsAccessFactory CollectMetrics(CodexSetup codexSetup, RunningContainers[] containers)
//{
@ -114,7 +114,7 @@ namespace CodexPlugin
private CodexNodeGroup CreateCodexGroup(RunningContainers[] runningContainers, CodexNodeFactory codexNodeFactory)
{
var group = new CodexNodeGroup(pluginTools, runningContainers, codexNodeFactory);
var group = new CodexNodeGroup(this, pluginTools, runningContainers, codexNodeFactory);
try
{
@ -151,12 +151,12 @@ namespace CodexPlugin
pluginTools.GetLog().Log(message);
}
//private void StopCrashWatcher(RunningContainers containers)
//{
// foreach (var c in containers.Containers)
// {
// c.CrashWatcher?.Stop();
// }
//}
private void StopCrashWatcher(RunningContainers containers)
{
foreach (var c in containers.Containers)
{
c.CrashWatcher?.Stop();
}
}
}
}

View File

@ -21,9 +21,9 @@ namespace Tests.BasicTests
{
var primary = Ci.SetupCodexNode();
//var setup = primary.BringOffline();
primary.BringOffline();
//primary = BringOnline(setup)[0];
primary = Ci.SetupCodexNode();
PerformOneClientTest(primary);
}