Я пытаюсь запустить / остановить кластер на основе Windows в C #, ниже приведен код, с которым я работаю до сих пор ... когда я получаю функцию TakeOffLine ниже, я получаю исключение "Не найдено" из System.Management.ManagementStatus.NotFound.Не уверен, что именно не найдено?Если есть (альтернативный) лучший способ сделать это, пожалуйста, дайте мне знать.
Спасибо!
using System.Management;
class App
{
public static void Main()
{
string clusterName = "clusterHex"; // cluster alias
string custerGroupResource = "clusterHex.internal.com"; // Cluster group name
ConnectionOptions options = new ConnectionOptions();
options.Authentication = System.Management.AuthenticationLevel.PacketPrivacy;
// Connect with the mscluster WMI namespace on the cluster named "MyCluster"
ManagementScope s = new ManagementScope("\\\\" + clusterName +
"\\root\\mscluster", options);
ManagementPath p = new ManagementPath("Mscluster_Clustergroup.Name='" + custerGroupResource + "'");
using (ManagementObject clrg = new ManagementObject(s, p, null))
{
// Take clustergroup off line and read its status property when done
TakeOffLine(clrg);
clrg.Get();
Console.WriteLine(clrg["Status"]);
System.Threading.Thread.Sleep(3000); // Sleep for a while
// Bring back online and get status.
BringOnLine(clrg);
clrg.Get();
Console.WriteLine(clrg["Status"]);
}
}
static void TakeOffLine(ManagementObject resourceGroup)
{
ManagementBaseObject outParams =
resourceGroup.InvokeMethod("Takeoffline", null, null);
}
static void BringOnLine(ManagementObject resourceGroup)
{
ManagementBaseObject outParams =
resourceGroup.InvokeMethod("Takeoffline", null, null);
}
}