Dell MD Storage Array Seed Discovery creation

Dell.Storage.MDStorageArray.ABBXMLStorageDiscovery (DataSourceModuleType)

Seed Discovery Cycle

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IPConfigFilePathstring$Config/IPConfigFilePath$IP Config File PathIP Config File Path for the Seed Discovery Cycle
APIVersionCheckstring$Config/APIVersionCheck$API version CheckChecking version of the API for the Seed Discovery Cycle
LogLevelint$Config/LogLevel$LogLevelLogLevel for the Seed Discovery Cycle
IntervalSecondsint$Config/IntervalSeconds$Interval SecondsInterval in Seconds for the Seed Discovery Cycle

Source Code:

<DataSourceModuleType ID="Dell.Storage.MDStorageArray.ABBXMLStorageDiscovery" Accessibility="Internal">
<Configuration>
<xsd:element name="IntervalSeconds" type="xsd:integer"/>
<xsd:element name="Computer" type="xsd:string"/>
<xsd:element name="LogLevel" type="xsd:integer"/>
<xsd:element name="APIVersionCheck" type="xsd:string"/>
<xsd:element name="IPConfigFilePath" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" ParameterType="int" Selector="$Config/IntervalSeconds$"/>
<OverrideableParameter ID="LogLevel" ParameterType="int" Selector="$Config/LogLevel$"/>
<OverrideableParameter ID="APIVersionCheck" ParameterType="string" Selector="$Config/APIVersionCheck$"/>
<OverrideableParameter ID="IPConfigFilePath" ParameterType="string" Selector="$Config/IPConfigFilePath$"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>RBODABBDiscover.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Config/Computer$ $Config/LogLevel$ $Config/APIVersionCheck$ "$Config/IPConfigFilePath$"</Arguments>
<ScriptBody><Script>

'**********************************************************************************
' Script Name - Dell RBOD Discovery using IP Listing File
' Author: Vaideeswaran Ganesan, Sriram Venkatesh, Anirban Kundu
'
' Description:
' Discover all Dell RBOD Device using the IP Listing File
'
' (c) Copyright Dell Inc. 2014 - All rights reserved
'**********************************************************************************
Option Explicit
On Error Resume Next
SetLocale("en-us")

Const DebugScript = False

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

Dim FileSystemObject
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")


Dim oArgs
Set oArgs = WScript.Arguments
if oArgs.Count &lt; 6 Then
Wscript.Quit -1
End If

Dim SourceID, ManagedEntityId, TargetComputer, logLevel, apiVerCheck, ipCfgFilePath
Dim oAPI, oDiscoveryData, oInst, logMessage, index, objLogTextFile
Dim eventMessage
Dim RBOD_IP_ARR, UNIQUE_RBOD_IP_ARR, rbod_ip, hyphenIP

SourceId = oArgs(0)
ManagedEntityId = oArgs(1)
TargetComputer = oArgs(2)
logLevel=oArgs(3) + 0
apiVerCheck=oArgs(4)
ipCfgFilePath = ""
For index=5 to (oArgs.Count-1)
ipCfgFilePath = ipCfgFilePath &amp; " " &amp; oArgs(index)
Next
ipCfgFilePath = Trim(ipCfgFilePath)

'##################################################
Dim glb_registryEntryPresent
glb_registryEntryPresent = False
Function GetRegistryEntry (strRegistryKey )
Dim WSHShell
On Error Resume Next
Set WSHShell = CreateObject("WScript.Shell")
' Clear the global Err object so that we can capture error when registry entry not found
Err.clear
GetRegistryEntry = WSHShell.RegRead( strRegistryKey )
If Err.number &lt;&gt; 0 then
' This condition will be success only if registry entry itself is not present (Err gets populated when exception occurs).
' If registry entry is not found (can happen in case if suite is uninstalled, MDMP remains in SCOM), check the below boolean and generate Alert 300
glb_registryEntryPresent = False
Else
' No error during calling RegRead()
glb_registryEntryPresent = True
End If
Err.clear
'Clean up resources
set WSHShell = nothing
End Function
Function CreateABBOutputFolder
dim wsShell : Set wsShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wsShell.Environment
dim tFolder : tFolder = wshSysEnv("TEMP")
dim abbOutputFolder : abbOutputFolder = "Dell_MDStorageArray_ABBOutput"
dim wshPrcEnv : Set wshPrcEnv = wsShell.Environment("Process")
tFolder = Replace(tFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)

If Not FileSystemObject.FolderExists(tFolder) Then
FileSystemObject.CreateFolder(tFolder)
End If
If Not FileSystemObject.FolderExists(tFolder &amp; "\" &amp; abbOutputFolder) Then
FileSystemObject.CreateFolder(tFolder &amp; "\" &amp; abbOutputFolder)
End If
'Clean up resources
set wsShell = nothing
CreateABBOutputFolder = tFolder &amp; "\" &amp; abbOutputFolder
End Function
'##################################################
Dim ABB_OUTPUT_FOLDER_PATH
ABB_OUTPUT_FOLDER_PATH = CreateABBOutputFolder

Dim registryEntryPATHValue
registryEntryPATHValue = GetRegistryEntry("HKEY_LOCAL_MACHINE\Software\Dell\Dell MD Storage Array Management Pack Suite\Path")
'registryEntryPATHValue would point to C:\Program Files\Dell Management Packs\MDStorage Mgmt Suite\&lt;version&gt;\ in a typical default installation of MDMP&lt;version&gt; suite

Dim ABB_FOLDER_PATH
'Default ABB folder path is assigned as empty
ABB_FOLDER_PATH = ""
If(strcomp(registryEntryPATHValue,"") = 0) Then
'If registry entry present, but value is empty, we set glb_registryEntryPresent to FALSE
glb_registryEntryPresent = False
Else
glb_registryEntryPresent = True
ABB_FOLDER_PATH = registryEntryPATHValue &amp; "Library"
End If

If ipCfgFilePath = "" Then
ipCfgFilePath = ABB_FOLDER_PATH &amp; "\dell_MDStorageArray_ip.cfg"
End If

Const ABB_CFG_NAME = "\Dell_MDStorageArray_ABBConfig.cfg"
Const ABB_EXE_NAME = "\dellabb.exe"

CreateLog

logMessage = "------------------------------------------------------"
MOMDebugLog 1, logMessage
logMessage = "INFO: Script - Dell MD Storage Discovery : Start()"
MOMDebugLog 1, logMessage
logMessage = "INFO: Script - Arguments: Computer, IPConfigFilePath = " &amp; targetComputer &amp; ", " &amp; ipCfgFilePath
MOMDebugLog 1, logMessage

Set oAPI = CreateMOMScriptAPI
If CheckEnvironment Then
Set oDiscoveryData = CreateDiscoveryData
ParseRBOD_IPCfg()
ReturnDiscoveryData oDiscoveryData
End If

Set oDiscoveryData = Nothing
Set oAPI = Nothing

logMessage = "INFO : Script - Dell MD Storage Discovery : End()"
MOMDebugLog 1, logMessage
logMessage = "------------------------------------------------------"
MOMDebugLog 1, logMessage

If logLevel &lt;&gt; 0 Then
objLogTextFile.Close
Set objLogTextFile = Nothing
End If

Function ParseRBOD_IPCfg()
' Function to parse the IPs from the user input cfg file

Dim a, objTextFile, strLine
a=0
Const ForReading = 1
DebugOut "Opening: " &amp; ipCfgFilePath
Set objTextFile = FileSystemObject.OpenTextFile(ipCfgFilePath, ForReading)
Do Until objTextFile.AtEndOfStream
strLine = objTextFile.Readline
RBOD_IP_ARR = Split(strLine,";")
Loop
For Each rbod_ip In RBOD_IP_ARR
If(Instr(UNIQUE_RBOD_IP_ARR,rbod_ip)=0) Then
logMessage = "INFO : Discover RBOD IP: " &amp; rbod_ip
MOMDebugLog 1, logMessage
UNIQUE_RBOD_IP_ARR = UNIQUE_RBOD_IP_ARR &amp; "," &amp; rbod_ip
hyphenIP = rbod_ip
If ( InStr(hyphenIP,".") &gt; 0 ) Then
hyphenIP = Replace(hyphenIP,".","_")
End If
If ( InStr(hyphenIP,":") &gt; 0 ) Then
hyphenIP = Replace(hyphenIP,":","_")
End If
set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.Storage.MDStorageArray.RBODDeviceSeed']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", hyphenIP)
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/Name$", "MD Storage Array")
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/Description$", "MD Array Seed Object")
call oInst.AddProperty("$MPElement[Name='Dell.Storage.MDStorageArray.RBODDeviceSeed']/monitorip$", rbod_ip)
call oInst.AddProperty("$MPElement[Name='Dell.Storage.MDStorageArray.RBODDeviceSeed']/APIVersionCheck$", apiVerCheck)
call oDiscoveryData.AddInstance(oInst)
End If
Next
End Function

'************** Functions list defns
Function CheckFileExists(sFileName)
If (FileSystemObject.FileExists(sFileName)) Then
CheckFileExists = True
Else
CheckFileExists = False
End If
End Function

Function CheckFolderExists(sFolderName)
If (FileSystemObject.FolderExists(sFolderName)) Then
CheckFolderExists = True
Else
CheckFolderExists = False
End If
End Function

Function GetVersion(sFilePathAndName)
Dim abbVersion
abbVersion = FileSystemObject.GetFileVersion(sFilePathAndName)
If Len(abbVersion) = 0 Then
MOMDebugLog 1, "INFO : No DellABB version information found, baselining the version to 4.0."
abbVersion = "4.0.0.0"
End If
GetVersion = abbVersion
End Function

Function IsDellABBCompatibleVersion(sABBVersion, mpVersion)
Dim eventMessage, arrABBVersion, arrMPVersion, iFirstArraySize, iSecondArraySize, i, minArraySize

arrABBVersion = Split(sABBVersion, "." )
arrMPVersion = Split(mpVersion, "." )
iFirstArraySize = UBound(arrABBVersion) + 1
iSecondArraySize = UBound(arrMPVersion) + 1

If iFirstArraySize &lt;= iSecondArraySize Then
minArraySize = iFirstArraySize
Else
minArraySize = iSecondArraySize
End If

If minArraySize &gt;= 2 Then
For i=0 to minArraySize - 1
If CInt(arrABBVersion(i)) &lt; CInt(arrMPVersion(i)) Then
eventMessage = "Lower version of DellABB.exe (" &amp; sABBVersion &amp; ") found. Expecting DellABB.exe (" &amp; mpVersion &amp; ")."
MOMDebugLog 1, "INFO : IsDellABBCompatibleVersion = False, " &amp; eventMessage
LogSCOMEvent eventMessage, 298, 1
IsDellABBCompatibleVersion = False
Exit Function
ElseIf CInt(arrABBVersion(i)) &gt; CInt(arrMPVersion(i)) Then
eventMessage = "Higher version of DellABB.exe (" &amp; sABBVersion &amp; ") found. Expecting DellABB.exe (" &amp; mpVersion &amp; ")."
MOMDebugLog 1, "INFO : IsDellABBCompatibleVersion = False, " &amp; eventMessage
LogSCOMEvent eventMessage, 298, 1
IsDellABBCompatibleVersion = False
Exit Function
End If
Next
eventMessage = "DellABB version matches correctly with the Management Pack version."
MOMDebugLog 1, "INFO : IsDellABBCompatibleVersion = True, " &amp; eventMessage
IsDellABBCompatibleVersion = True
Exit Function
End If
eventMessage = "Wrong version information retrieved from DellABB.exe."
MOMDebugLog 1, "INFO : IsDellABBCompatibleVersion = False, " &amp; eventMessage
IsDellABBCompatibleVersion = False
End Function

Function CreateLog
' Begin Logheader
If logLevel &lt;&gt; 0 Then
Dim fileSize, strOutFile, newFilename, dateStr, datesuffix, timesuffix, subStrLoc
Const strFileName = "Discovery_DellMDStorageArray.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 mdmpFolder : mdmpFolder = "Dell_MDStorageArray_ManagementPack_Logs"
dim wshPrcEnv : Set wshPrcEnv = wsShell.Environment("Process")
tFolder = Replace(tFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)

If Not FileSystemObject.FolderExists(tFolder) Then
FileSystemObject.CreateFolder(tFolder)
End If
If Not FileSystemObject.FolderExists(tFolder &amp; "\" &amp; mdmpFolder) Then
FileSystemObject.CreateFolder(tFolder &amp; "\" &amp; mdmpFolder)
End If
strOutFile = tFolder &amp; "\"&amp; mdmpFolder &amp; "\" &amp; strFileName
DebugOut "Logging to " &amp; strOutFile
If Not FileSystemObject.FileExists(strOutFile) Then
Set objLogTextFile = FileSystemObject.CreateTextFile(strOutFile)
objLogTextFile.Close()
End If
fileSize = FileSystemObject.GetFile(strOutFile).Size
If (fileSize &gt; MaxFileSize) Then
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,".")
newFilename = Mid(strOutFile,1,(subStrLoc-1))
newFilename = newFilename &amp;"-"&amp; datesuffix &amp;"-"&amp;timesuffix&amp;".log"
DebugOut "MoveFile " &amp; strOutFile &amp; " to " &amp; newFilename
FileSystemObject.MoveFile strOutFile, newFilename
Set objLogTextFile = FileSystemObject.OpentextFile(strOutFile, ForWriting, True)
Else
Set objLogTextFile = FileSystemObject.OpentextFile(strOutFile, ForAppending, True)
End If
Err.Clear
End If

End Function

Sub MOMDebugLog (ByVal debugLevel, ByVal Message)
DebugOut Message
If (debugLevel &gt; 0) and (debugLevel &lt;= logLevel) Then
objLogTextFile.WriteLine(Now() &amp; " ---- " &amp; Message)
Err.Clear
End If
End Sub
' End of Logheader

'**************

Function CheckEnvironment
CheckEnvironment = False

If glb_registryEntryPresent = False Then
' add event to eventlog on ABB Toolset path not present
eventMessage = "ABB Toolset Folder not found on the OpsMgr Management Server. Please install/repair the Dell MD Storage Array Management Pack Suite 6.1 to get the ABB Toolset and to monitor the MD Storage Arrays using Dell MD Storage Array Management Pack 6.1."
LogSCOMEvent eventMessage, 300, 2
Exit Function
End If

If Not CheckFolderExists (ABB_FOLDER_PATH) Then
' add event to eventlog on ABB Toolset path not present
eventMessage = "ABB Toolset Folder not found on the OpsMgr Management Server. Please install/repair the Dell MD Storage Array Management Pack Suite 6.1 to get the ABB Toolset and to monitor the MD Storage Arrays using Dell MD Storage Array Management Pack 6.1."
LogSCOMEvent eventMessage, 300, 2
Exit Function
End If

If Not FileSystemObject.FolderExists(ABB_OUTPUT_FOLDER_PATH &amp; "\TMP") Then
FileSystemObject.CreateFolder(ABB_OUTPUT_FOLDER_PATH &amp; "\TMP")
DebugOut "Creating Folder :" &amp; ABB_OUTPUT_FOLDER_PATH &amp; "\TMP"
End If

If Not FileSystemObject.FolderExists(ABB_OUTPUT_FOLDER_PATH &amp; "\data") Then
FileSystemObject.CreateFolder(ABB_OUTPUT_FOLDER_PATH &amp; "\data")
DebugOut "Creating Folder :" &amp; ABB_OUTPUT_FOLDER_PATH &amp; "\data"
End If

' add event to eventlog in case if the ipcfg file, abb cfg file or abb.exe is missing
eventMessage = ""
dim comma : comma = ""
If Not CheckFileExists(ABB_FOLDER_PATH &amp; ABB_EXE_NAME) Then
eventMessage = eventMessage &amp; comma &amp; ABB_FOLDER_PATH &amp; ABB_EXE_NAME
comma = ", "
End If
If Not CheckFileExists(ABB_FOLDER_PATH &amp; ABB_CFG_NAME) Then
eventMessage = eventMessage &amp; comma &amp; ABB_FOLDER_PATH &amp; ABB_CFG_NAME
comma = ", "
End If
If Not CheckFileExists(ipCfgFilePath) Then
eventMessage = eventMessage &amp; comma &amp; ipCfgFilePath
End If

If Len(eventMessage) &gt; 1 Then
eventMessage = "File(s): " &amp; eventMessage &amp; " not found on the OpsMgr Management Server. Please install/repair the Dell MD Storage Array Management Pack Suite 6.1 to get the ABB Toolset. Ensure the IP listing file (dell_MDStorageArray_ip.cfg (or overridden path setting)) is present in the installed library folder (ABB Toolset folder) or in the overridden IP Config file path location."
LogSCOMEvent eventMessage, 300, 2
Exit Function
End If

logMessage = "INFO : ABB executable and config file exists on Management Server"
MOMDebugLog 1, logMessage
logMessage = "INFO : IP Config File Path : " &amp; ipCfgFilePath
MOMDebugLog 1, logMessage

If Not IsDellABBCompatibleVersion(GetVersion(ABB_FOLDER_PATH &amp; ABB_EXE_NAME), "6.1.0.0") Then
' IMPORTANT: We dont stop the discovery process here but rather continue to discover and monitor using the non-compatible dellabb.exe(lower version or higher version).
' The user will hence experience some missing attributes/added attributes/added components, but the MP code is made to be both backward and forward compatible with dellabb.exe
' Generate the event to eventlog on ABB not compatible
' Return true to start discovery using the non-compatible dellabb.exe
logMessage = "INFO : DellABB is not compatible with management pack. Still proceeding with the Discovery"
MOMDebugLog 1, logMessage
End If
CheckEnvironment = True
End Function


'********** SCOM Functions
Function CreateMOMScriptAPI
If DebugScript = False Then
Set CreateMOMScriptAPI = CreateObject("MOM.ScriptAPI")
Else
DebugOut "Creating MOM Script API"
Set CreateMOMScriptAPI = New RegExp
End If

End Function
Function CreateDiscoveryData
If DebugScript = False Then
set CreateDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
Else
DebugOut "Creating instance of Discovery Data"
Set CreateDiscoveryData = New RegExp
End If
End Function

Function ReturnDiscoveryData (oDiscoveryData)
If DebugScript = False Then
Call oAPI.Return(oDiscoveryData)
Else
DebugOut "Returning Discovery Data"
End If

End Function
Function LogSCOMEvent(eventMessage, alertNum, alertLevel)
If DebugScript = False Then
Call oAPI.LogScriptEvent("RBODABBDiscover.vbs",alertNum,alertLevel,eventMessage)
Call oAPI.Return(oDiscoveryData)
End If
logMessage = "Generate EVENT: " &amp; eventMessage
MOMDebugLog 1, logMessage
End Function
Sub oInst_AddProperty(prop, value)
DebugOut prop &amp; " = " &amp; value
End Sub
</Script></ScriptBody>
<TimeoutSeconds>1200</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>