Dell DRAC Config Trap Destination WA

Dell.DRAC.ConfigTrapDestination.WA (WriteActionModuleType)

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
InputTypeSystem.BaseData

Member Modules:

ID Module Type TypeId RunAs 
ConfigTrapDestination WriteAction Microsoft.Windows.ScriptWriteAction Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
Timeoutint$Config/Timeout$Time OutTime Out
LogLevelint$Config/LogLevel$Log LevelLog Level

Source Code:

<WriteActionModuleType ID="Dell.DRAC.ConfigTrapDestination.WA" Accessibility="Public" Batching="false">
<Configuration>
<xsd:element minOccurs="1" name="DRAC_IPAddress" type="xsd:string"/>
<xsd:element minOccurs="1" name="Timeout" type="xsd:integer"/>
<xsd:element minOccurs="1" name="Username" type="xsd:string"/>
<xsd:element minOccurs="1" name="Password" type="xsd:string"/>
<xsd:element minOccurs="1" name="LogLevel" type="xsd:integer"/>
<xsd:element minOccurs="1" name="MS_IPAddress" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="Timeout" Selector="$Config/Timeout$" ParameterType="int"/>
<OverrideableParameter ID="LogLevel" Selector="$Config/LogLevel$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="ConfigTrapDestination" TypeID="Windows!Microsoft.Windows.ScriptWriteAction">
<ScriptName>DRAC_ConfigTrapDestination.vbs</ScriptName>
<Arguments>$Config/DRAC_IPAddress$ $Config/Timeout$ $Config/Username$ $Config/LogLevel$ $Config/MS_IPAddress$</Arguments>
<ScriptBody><Script>
'**********************************************************************************
' Script Name - DRAC_ConfigTrapDestination
' Author: Rashma
'
' Description:
' Configure the given MS IP as a Trap destination on a given DRAC IP
'
' (c) Copyright &#xA9; 2009&#x2013; 2017 Dell Inc, or its subsidiaries. All Rights Reserved
'**********************************************************************************

Option Explicit

SetLocale("en-us")

Const DebugScript = False
Dim oArgs
Dim SourceId, ManagedEntityId, oAPI, oBag, mgmtSrvName
Dim logMessage, oStdIn, strRacadmFileOutput
Dim timeout, logLevel, MS_IPAddress, DRAC_IPAddress, username, password, Index, racadmpath, racadmPort, extraArg
Dim isConfigured, isEnabled, freeIndex, Status, message, ipAddr
Dim fileSize, strOutFile, objLogFSO, objLogTextFile, strFileName

Set oArgs = WScript.Arguments

DRAC_IPAddress = oArgs(0)
timeout = oArgs(1)
username = oArgs(2)
logLevel = oArgs(3)
MS_IPAddress = oArgs(4)

'CreateLog(logLevel)
InitLogging(logLevel)

Set oStdIn = WScript.StdIn
password = oStdIn.ReadLine

MOMDebugLog 1, "-----------Entered DRAC_ConfigTrapDestination---------------"

ipAddr = split(MS_IPAddress,",")
MS_IPAddress = ipAddr(0)
logMessage = "INFO: Management Server IP =" &amp; MS_IPAddress
MOMDebugLog 1, logMessage
logMessage = "INFO: DRAC IP =" &amp; DRAC_IPAddress
MOMDebugLog 1, logMessage

isConfigured = false
freeIndex = 0
Status = "Failure"

MOMDebugLog 1, "-----------Calling GetFreeIndex()-------------------"
GetFreeIndex
DelFile(strRacadmFileOutput)

if(isConfigured = false AND freeIndex &lt;&gt; 0) Then
MOMDebugLog 1, "Given MS IPAddress is not configured. Hence, it will be configured at the free Index:" &amp; freeIndex
MOMDebugLog 1, "-------------Calling ConfigDRACTrapDst()----------------"
ConfigDRACTrapDst
DelFile(strRacadmFileOutput)
MOMDebugLog 1, "-------------Calling EnableConfiguration()--------------"
EnableConfiguration
DelFile(strRacadmFileOutput)
end if

Set oAPI = CreateMOMScriptAPI()
set oBag = CreatePropertyBag (oAPI)

MOMDebugLog 1, "Status" &amp; Status
oInstAddValue oBag, "Status" , Status

message = "Successfully configured"
if StrComp(Status, "Failure") = 0 Then
message = "Unable to configure the SNMP Trap destination:" &amp; MS_IPAddress &amp; " on the Device:" &amp; DRAC_IPAddress
message = message &amp; " This is because the device contains maximum number of SNMP Trap destinations already configured."
end if
oInstAddValue oBag, "Message", message

ReturnData oAPI, oBag
Set oAPI = Nothing

'********** SCOM Functions
'Initialize log-file according to log-level
Function InitLogging(ByRef logLevel)
' Begin Logheader
If logLevel &lt;&gt; 0 Then
strFileName = "Dell_DRAC_TrapCfg_" &amp; DRAC_IPAddress &amp; ".log"
Const ForAppending = 8
Const ForWriting = 2
Const MaxFileSize = 524288 'File Size is limited to 512 KB

dim wsShell : Set wsShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wsShell.Environment
dim tFolder : tFolder = wshSysEnv("TEMP")
dim wshPrcEnv : Set wshPrcEnv = wsShell.Environment("Process")
tFolder = Replace(tFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)

Set objLogFSO = CreateObject("Scripting.FileSystemObject")
If Not objLogFSO.FolderExists(tFolder) Then
objLogFSO.CreateFolder(tFolder)
End If
tFolder = tFolder &amp; "\DracTrapCfg"
If Not objLogFSO.FolderExists(tFolder) Then
objLogFSO.CreateFolder(tFolder)
End If
strOutFile = tFolder &amp; "\" &amp; strFileName
If Not objLogFSO.FileExists(strOutFile) Then
Set objLogTextFile = objLogFSO.CreateTextFile(strOutFile)
objLogTextFile.Close()
End If
fileSize = objLogFSO.GetFile(strOutFile).Size
If (fileSize &gt; MaxFileSize) Then
Dim dateStr, datesuffix, timesuffix, subStrLoc, newFilename
dateStr = CDate(Now())
datesuffix = ( Year(dateStr)*100 + Month(dateStr) )*100 + Day(dateStr)
timesuffix = Right((Hour(dateStr)*100+Minute(dateStr))*100+Second(dateStr)+1e7, 6)
subStrLoc = Instr(1, strOutFile,".log")
newFilename = Mid(strOutFile,1,(subStrLoc-1))
newFilename = newFilename &amp;"-"&amp; datesuffix &amp;"-"&amp;timesuffix&amp;".log"
objLogFSO.MoveFile strOutFile, newFilename
Set objLogTextFile = objLogFSO.OpentextFile(strOutFile, ForWriting, True)
Else
Set objLogTextFile = objLogFSO.OpentextFile(strOutFile, ForAppending, True)
End If
logMessage = "INFO: Script - DellDRACTrapCfg : Start()"
MOMDebugLog 1, logMessage
Err.Clear
End If
End Function
Sub MOMDebugLog (ByVal debugLevel, ByVal Message)
On Error Resume Next
DebugOut Message
If (debugLevel &gt; 0) and (debugLevel &lt;= logLevel) Then
objLogTextFile.WriteLine(Now() &amp; " ---- " &amp; Message)
Err.Clear
End If
End Sub

Function EnableConfiguration()
MOMDebugLog 1, "---------Entered EnableConfiguration()-----------"
GetRACADMPath racadmPath
If racadmPath = "" Then
LogMessage = "GetRACADMPath function Error - " &amp; rc
MOMDebugLog 1, LogMessage
Err.Clear
Exit Function
Else
LogMessage = "GetRACADMPath:: " &amp; racadmPath
MOMDebugLog 1, LogMessage
End If

Dim TypeLib, NewGUID, fileGuid
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
fileGuid= (left(NewGUID, len(NewGUID)-2))

strRacadmFileOutput = "Dell_DRAC_Trap_Cfg_enable_" &amp; DRAC_IPAddress &amp; "_" &amp; fileGuid &amp; ".txt"
Dim logStrCommand, strCommand, objLogFSO1, oFile, strLine
Const ForReading = 1

strCommand = "cmd /C " &amp; chr(34) &amp; racadmPath &amp; "\" &amp; "racadm.exe" &amp; Chr(34) &amp; " -r " &amp; DRAC_IPAddress &amp; " -u " &amp; username &amp; " -p " &amp; password &amp; " config -g cfgIpmiPet -o cfgIpmiPetAlertEnable 1 -i " &amp; Index &amp; " &gt; " &amp; strRacadmFileOutput

logStrCommand = "cmd /C " &amp; chr(34) &amp; racadmPath &amp; "\" &amp; "racadm.exe" &amp; Chr(34) &amp; " -r " &amp; DRAC_IPAddress &amp; " -u " &amp; username &amp; " -p ***** config -g cfgIpmiPet -o cfgIpmiPetAlertEnable 1 -i " &amp; Index &amp; " &gt; " &amp; strRacadmFileOutput

logMessage = "Racadm command - " &amp; logStrCommand
MOMDebugLog 1, logMessage

Dim oShell, rc, timer, RunRemoteCmd
Set oShell = CreateObject ("WScript.Shell")
rc = oShell.run (strCommand,0,true)

MOMDebugLog 1, "Racadm Immediate Shell.run status = " &amp; rc
timer = 0
Do While ((rc &lt;&gt; 0) OR (bFileExists(strRacadmFileOutput) &lt;&gt; -1))
WScript.Sleep(1000)
timer = timer + 1
If (timer &gt; timeout) Then
MOMDebugLog 1, "Exit RunCmd. Reason: RemoteRacadm command not responding. Exiting section"
RunRemoteCmd = -1
DelFile(strRacadmFileOutput)
RunRemoteCmd = -1
logMessage = "RunRemoteCMD error: " &amp; rc
MOMDebugLog 1, logMessage
Err.Clear
Exit Function
End If
Loop
If Not bFileExists(strRacadmFileOutput) Then
logMessage = "strRacadmFileOutput does not exist - " &amp; strRacadmFileOutput
MOMDebugLog 1, logMessage
Exit Function
end if
MOMDebugLog 1, "-----Successfully enabled. Exiting EnableConfiguration()-------"
End Function

Function GetFreeIndex()
MOMDebugLog 1, "--------Entered GetFreeIndex()---------------"
GetRACADMPath racadmPath
If racadmPath = "" Then
LogMessage = "GetRACADMPath function Error - " &amp; rc
MOMDebugLog 1, LogMessage
Err.Clear
Exit Function
Else
LogMessage = "GetRACADMPath:: " &amp; racadmPath
MOMDebugLog 1, LogMessage
End If

Dim TypeLib, NewGUID, fileGuid
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
fileGuid= (left(NewGUID, len(NewGUID)-2))

strRacadmFileOutput = "Dell_DRAC_Trap_Cfg_" &amp; DRAC_IPAddress &amp; "_" &amp; fileGuid &amp; ".txt"
Dim logStrCommand, strCommand, objLogFSO1, oFile, strLine
Const ForReading = 1

strCommand = "cmd /C " &amp; chr(34) &amp; racadmPath &amp; "\" &amp; "racadm.exe" &amp; Chr(34) &amp; " -r " &amp; DRAC_IPAddress &amp; " -u " &amp; username &amp; " -p " &amp; password &amp; " getconfig -f config -g cfgIpmiPet &gt; " &amp; strRacadmFileOutput

logStrCommand = "cmd /C " &amp; chr(34) &amp; racadmPath &amp; "\" &amp; "racadm.exe" &amp; Chr(34) &amp; " -r " &amp; DRAC_IPAddress &amp; " -u " &amp; username &amp; " -p ****" &amp; " getconfig -f config -g cfgIpmiPet &gt; " &amp; strRacadmFileOutput

logMessage = "Racadm command - " &amp; logStrCommand
MOMDebugLog 1, logMessage

Dim oShell, rc, timer, RunRemoteCmd
Set oShell = CreateObject ("WScript.Shell")
rc = oShell.run (strCommand,0,true)

MOMDebugLog 1, "Racadm Immediate Shell.run status = " &amp; rc
timer = 0
Do While ((rc &lt;&gt; 0) OR (bFileExists(strRacadmFileOutput) &lt;&gt; -1))
WScript.Sleep(1000)
timer = timer + 1
If (timer &gt; timeout) Then
MOMDebugLog 1, "Exit RunCmd. Reason: RemoteRacadm command not responding. Exiting section"
RunRemoteCmd = -1
DelFile(strRacadmFileOutput)
RunRemoteCmd = -1
logMessage = "RunRemoteCMD error: " &amp; rc
MOMDebugLog 1, logMessage
Err.Clear
Exit Function
End If
Loop
If Not bFileExists(strRacadmFileOutput) Then
logMessage = "strRacadmFileOutput does not exist - " &amp; strRacadmFileOutput
MOMDebugLog 1, logMessage
Exit Function
end if

' Logic to Parse the file
Dim cfgIpmiPetIndex, cfgIpmiPetAlertDestIpAddr, cfgIpmiPetAlertEnable
Set objLogFSO1 = CreateObject("Scripting.FileSystemObject")
Set oFile = objLogFSO1.OpenTextFile(strRacadmFileOutput, ForReading, False)
Dim PetIndex, AlertDestIpAddr, AlertEnable, lineItems, tmpStr
Dim isFirstIndex, isSecondIndex, isThirdIndex, isFourthIndex
Do While Not oFile.AtEndOfStream
strLine = Trim(oFile.ReadLine)
'MOMDebugLog 1, "***strLine:" &amp; strLine
If Instr(Lcase(strLine),"error") Then
LogMessage = " ERROR: Error in RemoteRacadm Output " &amp; strLine
MOMDebugLog 1, LogMessage
Err.Clear
ElseIf Instr(LCase(strLine),Lcase("ERROR: Unable to")) Then
LogMessage = " ERROR: LOGIN IP/PORT/CREDENTIAL issue: " &amp; strLine
MOMDebugLog 1, LogMessage
Exit Function
ElseIf Instr(LCase(strLine),Lcase("cfgIpmiPetIndex")) Then
strLine = Trim(strLine)
lineItems = split(strLine,"=")
if InStr(lineItems(0), "cfgIpmiPetIndex") &gt; 0 then
cfgIpmiPetIndex = Left(lineItems(1), Len(lineItems(1))-1) ' remove \r or \n
MOMDebugLog 1, "cfgIpmiPetIndex:" &amp; cfgIpmiPetIndex
end if
cfgIpmiPetIndex = CInt(cfgIpmiPetIndex)
if(cfgIpmiPetIndex = 1) Then
isFirstIndex = true
elseif(cfgIpmiPetIndex = 2) Then
isSecondIndex = true
elseif(cfgIpmiPetIndex = 3) Then
isThirdIndex = true
elseif(cfgIpmiPetIndex = 4) Then
isFourthIndex = true
end if
ElseIf Instr(LCase(strLine),Lcase("cfgIpmiPetAlertDestIpAddr")) Then
strLine = Trim(strLine)
lineItems = split(strLine,"=")
cfgIpmiPetAlertDestIpAddr = Left(lineItems(1), Len(lineItems(1))-1) ' remove \r or \n
MOMDebugLog 1, "cfgIpmiPetAlertDestIpAddr:" &amp; cfgIpmiPetAlertDestIpAddr &amp;":"
ElseIf Instr(LCase(strLine),Lcase("cfgIpmiPetAlertEnable")) Then
strLine = Trim(strLine)
lineItems = split(strLine,"=")
cfgIpmiPetAlertEnable = Left(lineItems(1), Len(lineItems(1))-1) ' remove \r or \n
MOMDebugLog 1, "cfgIpmiPetAlertEnable:" &amp; cfgIpmiPetAlertEnable
end if

if(StrComp(cfgIpmiPetAlertDestIpAddr, MS_IPAddress) = 0) Then
isConfigured = true
EXIT function
elseif(StrComp(cfgIpmiPetAlertDestIpAddr, "0.0.0.0") = 0) Then
freeIndex = cfgIpmiPetIndex
MOMDebugLog 1, "1.cfgIpmiPetAlertDestIpAddr:" &amp; cfgIpmiPetAlertDestIpAddr &amp; ",cfgIpmiPetIndex:" &amp; cfgIpmiPetIndex
MOMDebugLog 1, "0.0.0.0: set freeIndex=" &amp; freeIndex
EXIT function
end if
Loop

if(isFirstIndex = false) Then
freeIndex = 1
elseif(isSecondIndex = false) Then
freeIndex = 2
elseif(isThirdIndex = false) Then
freeIndex = 3
elseif(isFourthIndex = false) Then
freeIndex = 4
end if
MOMDebugLog 1, "------Exiting GetFreeIndex():freeIndex:" &amp; freeIndex

End Function

Function ConfigDRACTrapDst()
MOMDebugLog 1, "---------Entered ConfigDRACTrapDst()-----------"
Index = freeIndex
GetRACADMPath racadmPath
If racadmPath = "" Then
LogMessage = "GetRACADMPath function Error - " &amp; rc
MOMDebugLog 1, LogMessage
Err.Clear
Exit Function
Else
LogMessage = "GetRACADMPath:: " &amp; racadmPath
MOMDebugLog 1, LogMessage
End If

Dim TypeLib, NewGUID, fileGuid
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
fileGuid= (left(NewGUID, len(NewGUID)-2))

strRacadmFileOutput = "Dell_DRAC_Trap_Cfg_" &amp; DRAC_IPAddress &amp; "_" &amp; fileGuid &amp; ".txt"
Dim logStrCommand, strCommand, objLogFSO1, oFile, strLine
Const ForReading = 1

strCommand = "cmd /C " &amp; chr(34) &amp; racadmPath &amp; "\" &amp; "racadm.exe" &amp; Chr(34) &amp; " -r " &amp; DRAC_IPAddress &amp; " -u " &amp; username &amp; " -p " &amp; password &amp; " config -g cfgIpmiPet -o cfgIpmiPetAlertDestIpAddr " &amp; MS_IPAddress &amp; " -i " &amp; Index &amp; " &gt; " &amp; strRacadmFileOutput

logStrCommand = "cmd /C " &amp; chr(34) &amp; racadmPath &amp; "\" &amp; "racadm.exe" &amp; Chr(34) &amp; " -r " &amp; DRAC_IPAddress &amp; " -u " &amp; username &amp; " -p " &amp; "****" &amp; " config -g cfgIpmiPet -o cfgIpmiPetAlertDestIpAddr " &amp; MS_IPAddress &amp; " -i " &amp; Index &amp; " &gt; " &amp; strRacadmFileOutput

logMessage = "Racadm command - " &amp; logStrCommand
MOMDebugLog 1, logMessage

Dim oShell, rc, timer, RunRemoteCmd
Set oShell = CreateObject ("WScript.Shell")
rc = oShell.run (strCommand,0,true)

MOMDebugLog 1, "Racadm Immediate Shell.run status = " &amp; rc
timer = 0
Do While ((rc &lt;&gt; 0) OR (bFileExists(strRacadmFileOutput) &lt;&gt; -1))
WScript.Sleep(1000)
timer = timer + 1
If (timer &gt; timeout) Then
MOMDebugLog 1, "Exit RunCmd. Reason: RemoteRacadm command not responding. Exiting section"
RunRemoteCmd = -1
DelFile(strRacadmFileOutput)
RunRemoteCmd = -1
logMessage = "RunRemoteCMD error: " &amp; rc
MOMDebugLog 1, logMessage
Err.Clear
Exit Function
End If
Loop
If Not bFileExists(strRacadmFileOutput) Then
logMessage = "strRacadmFileOutput does not exist - " &amp; strRacadmFileOutput
MOMDebugLog 1, logMessage
Exit Function
end if

' Logic to Parse the file
Dim cfgIpmiPetIndex, cfgIpmiPetAlertDestIpAddr, cfgIpmiPetAlertEnable
Set objLogFSO1 = CreateObject("Scripting.FileSystemObject")
Set oFile = objLogFSO1.OpenTextFile(strRacadmFileOutput, ForReading, False)
Dim PetIndex, AlertDestIpAddr, AlertEnable, lineItems, tmpStr
Dim isFirstIndex, isSecondIndex, isThirdIndex, isFourthIndex
Do While Not oFile.AtEndOfStream
strLine = Trim(oFile.ReadLine)
'MOMDebugLog 1, "strLine:" &amp; strLine
If Instr(Lcase(strLine),"error") Then
LogMessage = " ERROR: Error in RemoteRacadm Output " &amp; strLine
MOMDebugLog 1, LogMessage
Err.Clear
ElseIf Instr(LCase(strLine),Lcase("ERROR: Unable to")) Then
LogMessage = " ERROR: LOGIN IP/PORT/CREDENTIAL issue: " &amp; strLine
MOMDebugLog 1, LogMessage
Exit Function
ElseIf Instr(LCase(strLine),Lcase("ERROR: Invalid")) Then
LogMessage = " ERROR: Invalid index value issue: " &amp; strLine
MOMDebugLog 1, LogMessage
Exit Function
ElseIf Instr(LCase(strLine),Lcase("ERROR: Login failed")) Then
LogMessage = " ERROR: Login failed issue: " &amp; strLine
MOMDebugLog 1, LogMessage
Exit Function
ElseIf Instr(LCase(strLine),Lcase("Object value modified successfully")) Then
LogMessage = " Object value modified successfully " &amp; strLine
MOMDebugLog 1, LogMessage
Status = "Success"
end if
Loop
Status = "Success"
MOMDebugLog 1, "-------Exiting ConfigDRACTrapDst()--------"
End Function
Function CreateMOMScriptAPI
If DebugScript = False Then
Set CreateMOMScriptAPI = CreateObject("MOM.ScriptAPI")
Else
Set CreateMOMScriptAPI = New RegExp
End If
logMessage = "INFO: New MOM.ScriptAPI"
MOMDebugLog 1, logMessage
End Function

Function CreatePropertyBag(ByRef oAPI)
If DebugScript = False Then
set CreatePropertyBag = oAPI.CreatePropertyBag()
Else
Set CreatePropertyBag = New RegExp
End If
logMessage = "INFO: New Monitor Data"
MOMDebugLog 1, logMessage
End Function

Sub oInstAddValue(ByRef oBag, prop, val)
If DebugScript = False Then
Call oBag.AddValue(prop, val)
End If
logMessage = "INFO: Set " &amp; prop &amp; " = " &amp; val
MOMDebugLog 1, logMessage
End Sub

Sub ReturnData (ByRef oAPI, ByRef oBag)
If DebugScript = False Then
Call oAPI.Return(oBag)
End If
logMessage = "INFO: Returning Monitor Data"
MOMDebugLog 1, logMessage
End Sub

Function CreateDiscoveryData(ByRef oAPI, ByRef SourceId, ByRef ManagedEntityId)
If DebugScript = False Then
set CreateDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
Else
Set CreateDiscoveryData = New RegExp
End If
logMessage = "INFO: New Discovery Data"
MOMDebugLog 1, logMessage
End Function

Function ReturnDiscoveryData (ByRef oAPI, ByRef oDiscoveryData)
If DebugScript = False Then
Call oAPI.Return(oDiscoveryData)
End If
logMessage = "INFO: Returning Discovery Data"
MOMDebugLog 1, logMessage
End Function

Sub oInstAddProperty(ByRef oInst, prop, val)
If DebugScript = False Then
Call oInst.AddProperty(prop, val)
End If
logMessage = "INFO: Set " &amp; prop &amp; " = " &amp; val
MOMDebugLog 1, logMessage
End Sub

Function CreateClassInstance(ByRef oDiscoveryData, classid)
If DebugScript = False Then
set CreateClassInstance = oDiscoveryData.CreateClassInstance(classid)
Else
Set CreateClassInstance = New RegExp
End If
logMessage = "INFO: New Class Instance" &amp; classid
MOMDebugLog 1, logMessage
End Function

Sub AddInstanceToDiscoveryData(ByRef oDiscoveryData, ByRef oInst)
If DebugScript = False Then
Call oDiscoveryData.AddInstance(oInst)
End If
logMessage = "INFO: AddInstance to Discovery Data"
MOMDebugLog 1, logMessage
End Sub


Function DebugOut(message)
If DebugScript Then WScript.Echo message
End Function


Function CreateLog(ByRef logLevel)
' Begin Logheader
If logLevel &lt;&gt; 0 Then
Dim fileSize, strOutFile
Const ForAppending = 8
Const ForWriting = 2
Const MaxFileSize = 524288 'File Size is limited to 512 KB

dim wsShell : Set wsShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wsShell.Environment
dim tFolder : tFolder = wshSysEnv("TEMP")
dim wshPrcEnv : Set wshPrcEnv = wsShell.Environment("Process")
tFolder = Replace(tFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)

Set objLogFSO = CreateObject("Scripting.FileSystemObject")
If Not objLogFSO.FolderExists(tFolder) Then
objLogFSO.CreateFolder(tFolder)
End If
strOutFile = tFolder &amp; "\DRACLogs\"&amp; "DRAC_ConfigTrapDestination_" &amp; DRAC_IPAddress &amp; ".txt"
If Not objLogFSO.FileExists(strOutFile) Then
Set objLogTextFile = objLogFSO.CreateTextFile(strOutFile)
objLogTextFile.Close()
End If
fileSize = objLogFSO.GetFile(strOutFile).Size
If (fileSize &gt; MaxFileSize) Then
Set objLogTextFile = objLogFSO.OpentextFile(strOutFile, ForWriting, True)
Else
Set objLogTextFile = objLogFSO.OpentextFile(strOutFile, ForAppending, True)
End If
logMessage = "INFO: Script - Script : Start()"
MOMDebugLog 1, logMessage
Err.Clear
End If
End Function


'******************************************************************************
'GetRACADMPath
'Function which sets the RACADM executable path either using OMSA or DRAC Tools
'******************************************************************************

Function GetRACADMPath(ByRef o_sPath)
On Error Resume Next

'Registry Entry for 32 and 64 bit OMSA RACADM Path
Const RACADM_REG_INSTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Dell Computer Corporation\OpenManage\Remote Access Card Managed Node\PATH"
Const RACADM64_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432node\Dell Computer Corporation\OpenManage\Remote Access Card Managed Node\PATH"
'Registry Entry for 32 and 64 bit DRAC Tools RACADM Path
Const REM_RACADM_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Dell Computer Corporation\OpenManage\Remote Access Card Management Station\Path"
Const REM_RACADM64_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Dell Computer Corporation\OpenManage\Remote Access Card Management Station\Path"

'Default Location having RACADM executable for OMSA and Drac Tools
Const DEF_RACADM_PATH = "C:\Program Files\Dell\SysMgt\rac5"

Dim installerPath
installerPath = ""

If (GetRACADMInstallPath (RACADM_REG_INSTALL_PATH, RACADM64_REG_INTALL_PATH, installerPath) = True) Then
o_sPath = installerPath
LogMessage = "Got RACADM path from OMSA"
MOMDebugLog 1, LogMessage
ElseIf (GetRACADMInstallPath (REM_RACADM_REG_INTALL_PATH, REM_RACADM64_REG_INTALL_PATH, installerPath) = True) Then
o_sPath = installerPath
LogMessage = "Got RACADM path from DRAC TOOLS"
MOMDebugLog 1, LogMessage
ElseIf (VerifyInstallPath(DEF_RACADM_PATH) = True) Then
o_sPath = DEF_RACADM_PATH
LogMessage = "Got RACADM path using the Default RACADM path : " &amp; DEF_RACADM_PATH
MOMDebugLog 1, LogMessage
Else
LogMessage = "Did Not Get RACADM Path from either OMSA or DRAC Tools"
MOMDebugLog 1, LogMessage
End If

If Err &lt;&gt; 0 Then
GetRACADMPath = Err.Number
Err.Clear
End If

End Function

'*********************************************************************
'GetRACADMInstallPath
'This Function sets the RACADM installer path using the Registry Key
'*********************************************************************

Function GetRACADMInstallPath (ByVal RACADM32RegistryKey, ByVal RACADM64RegistryKey, ByRef o_sPath)
On Error Resume Next

Dim installPath
installPath = ""
If (GetPathFromRegistry (RACADM32RegistryKey, installPath) = True) Then
o_sPath = installPath
GetRACADMInstallPath = True
LogMessage = "Got RACADM path from RACADM 32 bit Registry Key entry : " &amp; installPath
MOMDebugLog 1, LogMessage
ElseIf (GetPathFromRegistry (RACADM64RegistryKey, installPath) = True) Then
o_sPath = installPath
GetRACADMInstallPath = True
LogMessage = "Got RACADM path from RACADM 64 bit Registry Key entry : " &amp; installPath
MOMDebugLog 1, LogMessage
Else
GetRACADMInstallPath = False
LogMessage = "Unable to get RACADM path for Registry Entries"
MOMDebugLog 1, LogMessage
End If

If Err &lt;&gt; 0 Then
GetRACADMInstallPath = Err.Number
Err.Clear
End If

On Error Goto 0

End Function

'****************************************************************************
'GetPathFromRegistry
'Function to fetch the RACADM executable path using the RACADM Registry Key
'****************************************************************************

Function GetPathFromRegistry (ByVal strRacadmKey, ByRef installPath)
On Error Resume Next
Dim oShell, pathFromRegistry, newInstallPath

pathFromRegistry = ""
Set oShell = CreateObject ("WScript.Shell")
pathFromRegistry = oShell.RegRead(strRacadmKey)

'Appending 5 to the path since the RACADM executable was placed under the RAC5 directory from OM 6.0
newInstallPath = pathFromRegistry &amp; "5"
If pathFromRegistry &lt;&gt; "" Then
If (VerifyInstallPath(pathFromRegistry) = True) Then
installPath = pathFromRegistry
GetPathFromRegistry = True
ElseIf (VerifyInstallPath(newInstallPath) = True) Then
installPath = newInstallPath
GetPathFromRegistry = True
Else
GetPathFromRegistry = False
End If
Else
GetPathFromRegistry = False
If Err &lt;&gt; 0 Then
LogMessage = "RACADM Registry is empty for Key :" &amp; strRacadmKey
MOMDebugLog 1, LogMessage
Err.Clear
End If
End If
Set oShell = Nothing

End Function

'*********************************************************************************
'VerifyInstallPath
'The Function tells if the RACADM executable exists in the specified path or not
'*********************************************************************************

Function VerifyInstallPath (path)
On Error Resume Next
Dim installPath

installPath = path &amp; "\racadm.exe"
If (bFileExists(installPath)) Then
VerifyInstallPath = True
else
VerifyInstallPath = False
End If

End Function
'*****************************************************************
'bFileExists
'Routine to determine if a file exists (omconfig/omreport)
'*****************************************************************
Function bFileExists(filespec1)
On Error Resume Next
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
bFileExists = (fso.FileExists(filespec1))
Set fso = Nothing
On Error Goto 0
End Function
'*****************************************************************
'DelFile
'Routine to delete the OMSA Report file
'*****************************************************************
Function DelFile(ByVal filespec2)
On Error Resume Next
Dim fso, oFile
If bFileExists(filespec2) Then
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile filespec2, True
Set fso = Nothing
End If
If Err &lt;&gt; 0 Then
DelFile = Err.Number
Err.Clear
End If
On Error Goto 0
End Function
'*****************************************************************
'RemoveWhiteSpaces
'Routine to
'*****************************************************************
Function RemoveWhiteSpace(ByVal strText)
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = "\s+"
RegEx.MultistrLine = True
RegEx.Global = True
strText = RegEx.Replace(strText, " ")
RemoveWhiteSpace = strText
End Function

</Script></ScriptBody>
<SecureInput>$Config/Password$</SecureInput>
<TimeoutSeconds>$Config/Timeout$</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="ConfigTrapDestination"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>