執行叢集節點方法

Microsoft.Windows.Cluster.Node.Action (WriteActionModuleType)

此寫入動作會執行叢集節點中的動作。

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsMicrosoft.Windows.Cluster.PrivilegedAccount
InputTypeSystem.BaseData

Member Modules:

ID Module Type TypeId RunAs 
WA WriteAction System.CommandExecuter Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
TimeoutSecondsint$Config/TimeoutSeconds$逾時 (秒)

Source Code:

<WriteActionModuleType ID="Microsoft.Windows.Cluster.Node.Action" Accessibility="Internal" RunAs="Cluster!Microsoft.Windows.Cluster.PrivilegedAccount" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="MethodName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="WA" TypeID="System!System.CommandExecuter">
<ApplicationName/>
<WorkingDirectory/>
<CommandLine>cscript ClusterNodeExecuteMethod.js "$Target/Property[Type='ClusLibrary!Microsoft.Windows.Cluster.Node']/NodeName$" "$Config/MethodName$"</CommandLine>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>ClusterNodeExecuteMethod.js</Name>
<Contents><Script>//Copyright (c) Microsoft Corporation. All rights reserved.
var oArgs = WScript.Arguments;

// Process Arguments:
// 0 - Node
// 1 - MethodName

var strComputer, MethodName;
var Trace = false;

strComputer = oArgs(0);
MethodName = oArgs(1);

try {
// there is difference between 2003 and 2008
// check if object has method to pause/resume node

var objSvc = null;

if (HasMethod("MSCluster_Service", MethodName)) {
objSvc = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\" + strComputer + "\\root\\mscluster:MSCluster_Service.Name=\"ClusterService\",SystemName=\"" + strComputer + "\"");
}
else if (HasMethod("MSCluster_Node", MethodName)) {
objSvc = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\" + strComputer + "\\root\\mscluster:MSCluster_Node.Name=\"" + strComputer + "\"");
}

if (!(objSvc == null)) {
PrintTrace("EXECUTING METHOD " + MethodName);

// Get the WMI method and setup the params
var objMethod = objSvc.Methods_.Item(MethodName);

// Execute the method and retrieve the value
var objOutParam = objSvc.ExecMethod_(objMethod.Name);
}
}
catch (e) {
PrintError(e);
}

function HasMethod(className, methodName) {
var methods = null;

try {
var objSvc = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\" + strComputer + "\\root\\mscluster:" + className);
methods = objSvc.Methods_.Item(methodName);
}
catch (e) {
}

if (methods == null) {
PrintTrace("There is no method " + methodName + " in class " + className);
return false;
}

PrintTrace("Method " + methodName + " in class " + className + " was found!");
return true;
}

function PrintTrace(msg) {
if (Trace) {
WScript.Echo(msg);
}
}

function PrintError(error) {
if (Trace) {
WScript.Echo("============================= BEGIN SCRIPT ERROR =================================\n");
WScript.Echo("Error Number : " + error.number);
WScript.Echo("Error Code : " + (error.number &amp; 0xFFFF));
WScript.Echo("Win32 Facility : " + (error.number &gt;&gt; 16 &amp; 0x1FFF));
WScript.Echo("Error Description : " + error.description + "\n");
WScript.Echo("============================== END SCRIPT ERROR ==================================\n");
}
}
</Script></Contents>
<Unicode>false</Unicode>
</File>
</Files>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="WA"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>