Cisco.Ucs.LoadFaultCache.WriteActionModuleType (WriteActionModuleType)

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
InputTypeSystem.BaseData

Member Modules:

ID Module Type TypeId RunAs 
PowerShellWriteAction WriteAction Microsoft.Windows.PowerShellWriteAction Default

Overrideable Parameters:

IDParameterTypeSelector
Loggingstring$Config/Logging$

Source Code:

<WriteActionModuleType ID="Cisco.Ucs.LoadFaultCache.WriteActionModuleType" Accessibility="Public" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Logging" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TypeId" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="WebProxyUrl" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="Logging" Selector="$Config/Logging$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="PowerShellWriteAction" TypeID="Windows!Microsoft.Windows.PowerShellWriteAction">
<ScriptName>Cisco.Ucs.LoadFaultCache.WriteAction.ps1</ScriptName>
<ScriptBody><Script>Param (
$Logging,
$TypeId,
$WebProxyUrl
)

######
# Declaring Constants
######
########################################################################################
Set-Variable -Name cCODE -Value "19900"
Set-Variable -Name cLOGINGCODE -Value "19901"
Set-Variable -Name cAUTHFAILCODE -Value "19903"
Set-Variable -Name cCONFAILCODE -Value "19904"

Set-Variable -Name cERROR -Value "1"
Set-Variable -Name cWARNING -Value "2"
Set-Variable -Name cINFORMATION -Value "4"

Set-Variable -Name cSTATEDATA -Value "3"

Set-Variable -Name cSERVICENAME -Value "CiscoUcsMonitoringService"
########################################################################################

######
# Declaring Variables
######
#Referring MOM API
$oScriptAPI = New-Object -ComObject 'MOM.ScriptAPI'


######
# Checking status of the service
######
Function CheckService($serviceName, $machineName)
{
$machineName = $machineName.Split("/")[2].Split(":")[0]
$sAgentService = Get-Service -Name $serviceName -ComputerName $machineName -ErrorAction SilentlyContinue | Where-Object {$_.Status -eq "Running"}

if ($sAgentService -eq $null){
return $false
}

return $true
}

######
# Getting Valid XML Document
######
Function GetXmlDocument($sXmlString)
{
$oXmlDocument = New-Object System.Xml.XmlDocument

If ($oXmlDocument.LoadXml($sXmlString))
{
LogEvent ("Microsoft.XMLDOM Parse error: " + [string]($oXmlDocument.ParseError)) $cERROR $cCODE

$oXmlDocument = $Null
}
return $oXmlDocument
}

######
# Getting XML Attribute Values
######
Function GetXmlAttribute($oNode, $sAttributeName)
{
$oAttribute = $oNode.Attributes.GetNamedItem($sAttributeName)

$oValue = $null

If ($oAttribute)
{
$oValue = $oAttribute.Value
}

return $oValue
}
###
# Generate General Events
###
Function LogEvent ($sMessage, $iEventType, $iErrorEventId)
{
$oScriptAPI.LogScriptEvent("Cisco.Ucs.LoadFaultCache.WriteAction.ps1", $iErrorEventId, $iEventType, $sMessage)
}

######
# Main Method
######
Function Main
{
$startTime = (Get-Date)

If ([string]::IsNullOrEmpty($WebProxyUrl))
{
LogEvent "Service Connection error" $cERROR $cCODE
Exit
}

if (!(CheckService $cSERVICENAME $WebProxyUrl))
{
LogEvent "Service Not Found or Not Running." $cERROR $cCODE
Exit
}

$oPropertyBag = $null

Try
{
If ($Logging -eq "true")
{
$evtArgs = "Connecting to Cisco UCS Monitoring Service..."
LogEvent "$evtArgs" $cINFORMATION $cCODE
}

$oConnection = New-WebServiceProxy $WebProxyUrl
If ($oConnection -eq $null)
{
LogEvent "Connection to Cisco UCS Monitoring Service failed." $cERROR $cCODE
Exit
}

If ($Logging -eq "true")
{
$evtArgs = "Connection successful."
LogEvent "$evtArgs" $cINFORMATION $cCODE
}

$oXmlDocument = $oConnection.PopulateFaultCache($TypeId)
}
Catch [system.exception]
{
LogEvent $_.Exception.Message $cERROR $cCODE
Exit
}
$oXmlDocument = $null
$oConnectionHandle = $null
$oConnection = $null

$endTime = (Get-Date)
If ($Logging -eq "true"){
$totalTimes = ($endTime - $startTime).TotalMilliseconds
LogEvent ("Total time: " + $totalTimes + " Milliseconds") $cINFORMATION $cCODE
}
}
Main
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>Logging</Name>
<Value>$Config/Logging$</Value>
</Parameter>
<Parameter>
<Name>TypeId</Name>
<Value>$Config/TypeId$</Value>
</Parameter>
<Parameter>
<Name>WebProxyUrl</Name>
<Value>$Config/WebProxyUrl$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="PowerShellWriteAction"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>