[Q] How to change node state via SDK?
Closed this issue · 3 comments
Hey,
I couldn't find any example, therefore asking it here - what is the recommended way of changing HPC node state via SDK?
We can get a node via IScheduler
's OpenNodeByName(String)
, but resulting ISchedulerNode
doesn't provide any APIs for changing state.
Also, there's no API for changing node state in IScheduler
...
ty
node.exe in the command-line client tools has ways of setting nodes to "online" or "offline" - so shelling out would be a (fairly ugly ) workaround.
I thought (from some earlier errors I saw) that node.exe is compiled C# - perhaps using the SDK? - which makes me think there should be a way of doing this. But I'd also be interested to know how - if an SDK method exists, it is not easy to find.
@typhoon2k @weshinsley , may use the NodeQuery class in Microsoft.Hpc.Scheduler.NodeManagement.dll to bring nodes online/offline. E.g.
using (NodeQuery nodequery = HpcContext.GetOrAdd(scheduler, CancellationToken.None).GetNodeQueryAsync().GetAwaiter().GetResult())
{
if (nodeName != null)
{
verifyValidNode(scheduler, nodeName);
}
try
{
nodequery.TakeNodeOnline(nodeName, false);
}
catch (Exception)
{
Console.Error.WriteLine(Resources.NodeState_ErrorInvalidNodeState);
Environment.ExitCode = 1;
return;
}
}
Thanks @YutongSun !