<DataSourceModuleType ID="Dell.Operations.Server.TemplateMethod.ServerHealthCookDownDSMT" Accessibility="Public">
<Configuration>
<xsd:element minOccurs="1" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element minOccurs="1" name="LogLevel" type="xsd:integer"/>
<xsd:element name="RemoteAccessIP" type="xsd:string"/>
<xsd:element name="RemoteConfig" type="xsd:string"/>
<xsd:element minOccurs="1" name="Username" type="xsd:string"/>
<xsd:element minOccurs="1" name="Password" type="xsd:string"/>
<xsd:element minOccurs="1" name="TemplateScriptConfiguration" type="xsd:string"/>
<xsd:element minOccurs="1" name="ProfileDictionaryScript" type="xsd:string"/>
<xsd:element minOccurs="1" name="ComponentInstanceFactoryScript" type="xsd:string"/>
<xsd:element minOccurs="1" name="ServerHealthScript" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="LogLevel" Selector="$Config/LogLevel$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="PBP" TypeID="Windows!Microsoft.Windows.TimedScript.PropertyBagProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>ServerHealthDSMT.vbs</ScriptName>
<Arguments>$Config/LogLevel$ $Config/RemoteAccessIP$ $Config/RemoteConfig$</Arguments>
<ScriptBody><Script>
'**********************************************************************************
' Script Name - Dell Server Discovery DSMT
' Author: Anirban Kundu, Sriram Venkatesh
'
' Description:
' Discovers all Dell Server Devices using the Agent-free SMASH object as a target and
' issuing WSMan commands to the OOBHelper
'
' (c) Copyright © 2009– 2017 Dell Inc, or its subsidiaries. All Rights Reserved
'**********************************************************************************
Option Explicit
SetLocale("en-us")
Const DebugScript = False
Dim scriptArgs
Set scriptArgs = WScript.Arguments
'If scriptArgs.Count < 4 Then
' Wscript.Quit -1
'End If
Dim logLevel
logLevel = scriptArgs(0)
Dim remoteIp
remoteIp = scriptArgs(1)
Dim remoteConfig
remoteConfig = scriptArgs(2)
Dim RunAsAccount_Username
Dim RunAsAccount_Password
Dim o_MOMApiHelper
If RunAsAccount_Password = "" Or RunAsAccount_Username = "" Then
Set o_MOMApiHelper = New MOMAPIHelper
Call o_MOMApiHelper.CreateMOMScriptAPI()
Call o_MOMApiHelper.LogSCOMEvent("In the SMASH Device Monitoring Profile, Run As Account have not been associated with the corresponding Dell Server having the ip address : " & remoteIp , 498, 2)
Call o_MOMApiHelper.CreatePropertyBag()
Call o_MOMApiHelper.AddInstValue ("ComponentType", "Dummy")
Call o_MOMApiHelper.AddInstValue ("InstanceIndex", "Dummy")
Call o_MOMApiHelper.AddInstValue ("Status", "Dummy")
Call o_MOMApiHelper.AddInstValue ("Status Code", "Dummy")
Call o_MOMApiHelper.AddInstValue ("Status Code Value", "Dummy")
Call o_MOMApiHelper.AddDataItem()
Call o_MOMApiHelper.ReturnDataItems()
Call o_MOMApiHelper.destroyCOMObjects()
Set o_MOMApiHelper = Nothing
Wscript.Quit
End If
Function GetCredentials(ByRef r_username, ByRef r_password)
On Error Resume Next
Dim oStdIn: Set oStdIn = WScript.StdIn
r_password = oStdIn.ReadLine
r_username = "$Config/Username$"
End Function
Dim remoteConfigArray
remoteConfigArray = Split(remoteConfig,";")
Dim principalName
If DebugScript = False Then
principalName = GetMSName("HKEY_LOCAL_MACHINE\Software\Dell Computer Corporation\Dell Management Pack Suites\MSHostname")
If(StrComp(principalName, "") = 0) Then
principalName = GetMSName()
End If
Else
principalName = "DummySystem"
End If
'**************************************************************************************************
'Template method inclusion mechanism
'The following lines will expand the variables holding the VBScript classes and methods
'**************************************************************************************************
$Config/TemplateScriptConfiguration$
Dim log
Set log = New Logger
Call log.CreateLog(protParameterObj.getProtocolParameterValue("IPAddress"))
log.MOMDebugLog 1, "RunAsAccount_Username>>> " & RunAsAccount_Username
'##################################################
Function GetMSName
Dim StrRegKeyCompName, StrRegKeyTCPIP, WSHShell, StrHostname, StrDomainName, StrFQDN
StrRegKeyCompName = "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\"
StrRegKeyTCPIP = "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\"
Set WSHShell = CreateObject("WScript.Shell")
StrHostname = WSHShell.RegRead (StrRegKeyTCPIP & "Hostname")
StrDomainName = WSHShell.RegRead (StrRegKeyTCPIP & "Domain")
StrFQDN = StrHostName & "." & StrDomainName
GetMSName = StrFQDN
End Function
'##################################################
Function GetHostName
Dim objNTInfo
Dim GetComputerName
Set objNTInfo = CreateObject("WinNTSystemInfo")
GetHostName = lcase(objNTInfo.ComputerName)
End Function
'##################################################
Function GetMSName (strRegistryKey )
Dim WSHShell, value
On Error Resume Next
Set WSHShell = CreateObject("WScript.Shell")
GetMSName = WSHShell.RegRead( strRegistryKey )
If(strcomp(GetMSName,"") = 0) Then
GetMSName = GetHostName
end if
set WSHShell = nothing
End Function
'##################################################
'*****************************************************************
'Logger class
'Used for generating debug logs
'*****************************************************************
Class Logger
Private objLogTextFile
Private Sub Class_Initialize
End Sub
Function DebugOut(message)
If DebugScript Then WScript.Echo message
End Function
'*****************************************************************
'GetMDFileGUID
'Routine to generate unique GUIDs for the LOG files
'*****************************************************************
Function GetMDFileGUID(ByRef o_guid)
Dim TypeLib, NewGUID
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
o_guid = (left(NewGUID, len(NewGUID)-2))
Set TypeLib = Nothing
End Function
Function CreateLog(myIP)
Dim FileSystemObject
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
' Begin Logheader
If logLevel <> 0 Then
Dim fileSize, strOutFile, newFilename, dateStr, datesuffix, timesuffix, subStrLoc, hyphenIP
Const ForAppending = 8
Const ForWriting = 2
Const MaxFileSize = 524288 'File Size is limited to 512 KB
Dim strFileName, guidLOG
dim wsShell : Set wsShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wsShell.Environment
dim tFolder : tFolder = wshSysEnv("TEMP")
dim oobLogsFolder : oobLogsFolder = "DellOOBServer_Logs"
dim wshPrcEnv : Set wshPrcEnv = wsShell.Environment("Process")
tFolder = Replace(tFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)
hyphenIP = myIP
If ( InStr(hyphenIP,".") > 0 ) Then
hyphenIP = Replace(hyphenIP,".","_")
End If
If ( InStr(hyphenIP,":") > 0 ) Then
hyphenIP = Replace(hyphenIP,":","_")
End If
GetMDFileGUID guidLOG
strFileName = "Health_DellServer_" & hyphenIP & "_" & guidLOG & ".log"
If Not FileSystemObject.FolderExists(tFolder) Then
FileSystemObject.CreateFolder(tFolder)
End If
If Not FileSystemObject.FolderExists(tFolder & "\" & oobLogsFolder) Then
FileSystemObject.CreateFolder(tFolder & "\" & oobLogsFolder)
End If
strOutFile = tFolder & "\" & oobLogsFolder & "\" & strFileName
DebugOut "Logging to " & strOutFile
If Not FileSystemObject.FileExists(strOutFile) Then
Set objLogTextFile = FileSystemObject.CreateTextFile(strOutFile)
objLogTextFile.Close()
End If
fileSize = FileSystemObject.GetFile(strOutFile).Size
If (fileSize > 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 & "-" & datesuffix & "-" & timesuffix & ".log"
DebugOut "MoveFile " & strOutFile & " to " & 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 logLevel <> 0 Then
If (debugLevel > 0) and (debugLevel <= logLevel) Then
objLogTextFile.WriteLine(Now() & " ---- " & Message)
Err.Clear
End If
End If
End Sub
Function CloseLog()
If logLevel <> 0 Then
objLogTextFile.Close
Set objLogTextFile = Nothing
End If
End Function
End Class
'*******************************************************************************************************
'ServerClassification class
'Provides functions for classification of Dell Servers based on Manufactutrer, Generation, Server Type
'*******************************************************************************************************
Private Sub Class_Initialize
m_Protocol = ""
Set m_ProfileClassDict = CreateObject("Scripting.Dictionary")
m_ProfileClassDict.CompareMode = vbTextCompare
m_Manufacturer = ""
m_ServerType = ""
m_ServerGeneration = ""
End Sub
Public Function setProtocol(ByRef protocol)
m_Protocol = protocol
End Function
Public Function setProtocolParamaterObject(ByRef ProtParameterObj)
Set m_ProtParameterObj = ProtParameterObj
End Function
Public Function setProfileClasses(ByRef profClass)
Dim message
If (m_ProfileClassDict.Exists(profClass)) Then
message = "Profile Class exist"
Else
m_ProfileClassDict.Add profClass, "NA"
message = "Profile Class does not exist"
End If
End Function
Public Function destroyCOMObjects()
m_ProfileClassDict.RemoveAll
Set m_ProfileClassDict = Nothing
Set m_ProtParameterObj = Nothing
End Function
End Class
'**************************************************************************************************
'AttributeValueMapping class
'Provides functions for mapping the Component attribute values fetched from the DeviceHelper dll
'**************************************************************************************************
Class AttributeValueMapping
Private m_ValueMappingDictionary
Private Sub Class_Initialize
Set m_ValueMappingDictionary = CreateObject("Scripting.Dictionary")
m_ValueMappingDictionary.CompareMode = vbTextCompare
End Sub
Public Function setValueMappingDictionary(ByRef nativeValue, userReadableString)
Dim message
If (m_ValueMappingDictionary.Exists(nativeValue)) Then
message = "Attribute value mapping exists"
Else
m_ValueMappingDictionary.Add nativeValue, userReadableString
message = "Attribute value mapping inserted"
End If
End Function
Public Function getValueMappingFromDictionary (ByRef nativeValue)
Dim userString
userString = m_ValueMappingDictionary.Item(nativeValue)
If (Len(userString) > 0) Then
getValueMappingFromDictionary = userString
End If
End Function
Public Function destroyCOMObjects()
m_ValueMappingDictionary.RemoveAll
Set m_ValueMappingDictionary = Nothing
End Function
End Class
'**************************************************************************************************
'AttributeProperty class
'Provides functions for setting and getting Profile Dictionary attribute properties
'**************************************************************************************************
Class AttributeProperty
Private Sub Class_Initialize
m_Protocol = "Not Available"
m_ClassName = "Not Available"
m_ProtocolAttributeName = "Same"
m_IsAttributeMapping = "No"
m_AttributeMappingObject = Null
End Sub
Public Function setProtocol(ByRef protocol)
m_Protocol = protocol
End Function
Public Function getProtocol()
getProtocol = m_Protocol
End Function
Public Function setProtocolAttributeName(ByRef protocolAttrName)
m_ProtocolAttributeName = protocolAttrName
End Function
Public Function getProtocolAttributeName()
getProtocolAttributeName = m_ProtocolAttributeName
End Function
Public Function setClassName(ByRef className)
m_ClassName = className
End Function
Public Function getClassName()
getClassName = m_ClassName
End Function
Public Function setAttributeValueMappingObject()
If IsNull(m_AttributeMappingObject) Then
Set m_AttributeMappingObject = New AttributeValueMapping
m_IsAttributeMapping = "Yes"
End If
End Function
Public Function setAttributeValueMapping(ByRef value, readableString)
m_AttributeMappingObject.setValueMappingDictionary value, readableString
End Function
Public Function getIsAttributeMapping()
getIsAttributeMapping = m_IsAttributeMapping
End Function
Public Function getAttributeValueMapping(ByRef value)
getAttributeValueMapping = m_AttributeMappingObject.getValueMappingFromDictionary(value)
End Function
Public Function destroyCOMObjects()
m_AttributeMappingObject.RemoveAll
set m_AttributeMappingObject = Nothing
End Function
End Class
'**************************************************************************************************
'ProfileInformation class
'Provides functions for setting and getting the Profile Dictionary
'**************************************************************************************************
Class ProfileInformation
Private Sub Class_Initialize
m_ProfileName = "Not Available"
m_AttributePropertyObject = Null
Set m_AttributeDictionary = CreateObject("Scripting.Dictionary")
m_AttributeDictionary.CompareMode = vbTextCompare
End Sub
Public Function setProfileName(ByRef name)
m_ProfileName = name
End Function
Public Function getProfileName()
getProfileName = m_ProfileName
End Function
Public Function setAttributePropertyObject(ByRef attrPropObject)
Set m_AttributePropertyObject = attrPropObject
End Function
Public Function getAttributePropertyObject(ByRef attrName)
If (m_AttributeDictionary.Exists(attrName)) Then
Set getAttributePropertyObject = m_AttributeDictionary.Item(attrName)
Else
getAttributePropertyObject = Nothing
End If
End Function
Public Function setAttributeDictionary(ByRef attributeName)
Dim message
If (m_AttributeDictionary.Exists(attributeName)) Then
message = "Attribute Name Exists in Attribute Dictionary"
Else
If Not IsNull(m_AttributePropertyObject) Then
m_AttributeDictionary.Add attributeName, m_AttributePropertyObject
message = "Attribute inserted into the Attribute Dictionary"
End If
message = "Attribute not inserted as the attribute property object is NULL"
End If
End Function
Public Function getAttributeDictionary()
Set getAttributeDictionary = m_AttributeDictionary
End Function
Public Function populateProfileClassNameList()
Dim attrPropObjList, attrPropObj, classNameListDict, className
Set classNameListDict = CreateObject("Scripting.Dictionary")
classNameListDict.CompareMode = vbTextCompare
attrPropObjList = m_AttributeDictionary.Items
For Each attrPropObj In attrPropObjList
className = attrPropObj.getClassName()
If Not (classNameListDict.Exists(className)) Then
classNameListDict.Add className, "NA"
End If
Next
m_ProfileClassNameList = classNameListDict.Keys
m_ProfileClassNameListCount = classNameListDict.Count
classNameListDict.RemoveAll
Set classNameListDict = Nothing
End Function
Public Function getProfileClassNameList()
getProfileClassNameList = m_ProfileClassNameList
End Function
Public Function getProfileClassNameListCount()
getProfileClassNameListCount = m_ProfileClassNameListCount
End Function
Public Function destroyCOMObjects()
m_AttributeDictionary.RemoveAll
set m_AttributeDictionary = Nothing
set m_AttributePropertyObject = Nothing
End Function
End Class
'**************************************************************************************************
'ProtocolInfo class
'Encapsulates a Protocol in the form of a dictionary
'**************************************************************************************************
Class ProtocolInfo
Private Sub Class_Initialize
m_ProtocolName = ""
Set m_ProtocolParameterDict = CreateObject("Scripting.Dictionary")
m_ProtocolParameterDict.CompareMode = vbTextCompare
End Sub
Public Function setProtocolName(ByRef name)
m_ProtocolName = name
End Function
Public Function getProtocolName()
getProtocolName = m_ProtocolName
End Function
Public Function setProtocolParameterDictionary(ByRef parameter, value)
Dim message
If (m_ProtocolParameterDict.Exists(parameter)) Then
message = "Protocol parameter exists"
Else
m_ProtocolParameterDict.Add parameter, value
message = "Protocol parameter inserted"
End If
End Function
Public Function getProtocolParameterValue(ByRef parameter)
Dim value
value = m_ProtocolParameterDict.Item(parameter)
getProtocolParameterValue = value
End Function
Public Function destroyCOMObjects()
m_ProtocolParameterDict.RemoveAll
set m_ProtocolParameterDict = Nothing
End Function
End Class
'*******************************************************************************************************************
'ProfileDictionaryReader class
'This class parses the ProfileDictionary and collects the Profile class names that will be used to query the device
'*******************************************************************************************************************
Class ProfileDictionaryReader
Private Sub Class_Initialize
Set m_ProtocolListDict = CreateObject("Scripting.Dictionary")
m_ProtocolListDict.CompareMode = vbTextCompare
Set m_ClassNameListDict = CreateObject("Scripting.Dictionary")
m_ClassNameListDict.CompareMode = vbTextCompare
End Sub
Public Function setListofProtocolAndClassNames(ByRef profileDict)
Dim profileInfoComponentObj, profileInfoComponentList, attrPropObj, attrPropObjList, protocol, profAttrDict, className
profileInfoComponentList = profileDict.Items
For Each profileInfoComponentObj In profileInfoComponentList
Set profAttrDict = profileInfoComponentObj.getAttributeDictionary()
attrPropObjList = profAttrDict.Items
For Each attrPropObj In attrPropObjList
protocol = attrPropObj.getProtocol()
className = attrPropObj.getClassName()
If Not (m_ProtocolListDict.Exists(protocol)) Then
m_ProtocolListDict.Add protocol, "NA"
End If
If Not (m_ClassNameListDict.Exists(className)) Then
m_ClassNameListDict.Add className, "NA"
End If
Next
Next
m_ProtocolList = m_ProtocolListDict.Keys
m_ProtocolListCount = m_ProtocolListDict.Count
m_ClassNameList = m_ClassNameListDict.Keys
m_ClassNameListCount = m_ClassNameListDict.Count
End Function
Public Function getProtocolList()
getProtocolList = m_ProtocolList
End Function
Public Function getProtocolListCount()
getProtocolListCount = m_ProtocolListCount
End Function
Public Function getClassNameList()
getClassNameList = m_ClassNameList
End Function
Public Function getClassNameListCount()
getClassNameListCount = m_ClassNameListCount
End Function
Public Function destroyCOMObjects()
m_ProtocolListDict.RemoveAll
m_ClassNameListDict.RemoveAll
set m_ProtocolListDict = Nothing
set m_ClassNameListDict = Nothing
End Function
End Class
'**************************************************************************************************
'WSMANProtocolHelper class
'This class encapsulates the functionality for communicating to the device
'Provides functions for loading the DeviceHelper dll
'**************************************************************************************************
Class WSMANProtocolHelper
Public Function getProtocolName()
getProtocolName = m_Protocol
End Function
Public Function setUserName(ByRef userName)
m_UserName = userName
End Function
Public Function getUserName()
getUserName = m_UserName
End Function
Public Function setPassword(ByRef password)
m_Password = password
End Function
Public Function getPassword()
getPassword = m_Password
End Function
Public Function setProtocolHelperName(ByRef protHelpName)
m_ProtocolHelperName = protHelpName
End Function
Public Function getProtocolHelperName()
getProtocolHelperName = m_ProtocolHelperName
End Function
Public Function setIPAddress(ByRef ipAddr)
m_IpAddress = ipAddr
End Function
Public Function getIPAddress()
getIPAddress = m_IpAddress
End Function
Public Function setPort(ByRef port)
m_Port = port
End Function
Public Function getPort()
getPort = m_Port
End Function
Public Function setEncoding(ByRef encoding)
m_Encoding = encoding
End Function
Public Function getEncoding()
getEncoding = m_Encoding
End Function
Public Function setSkipCACheck(ByRef CACheck)
m_SkipCACheck = CACheck
End Function
Public Function getSkipCACheck()
getSkipCACheck = cbool(m_SkipCACheck)
End Function
Public Function setSkipCNCheck(ByRef CNCheck)
m_SkipCNCheck = CNCheck
End Function
Public Function getSkipCNCheck()
getSkipCNCheck = cbool(m_SkipCNCheck)
End Function
Public Function setTimeout(ByRef timeout)
m_Timeout = timeout
End Function
Public Function getTimeout()
getTimeout = m_Timeout
End Function
Public Function createWSMANProtocolHelperObject()
Set m_protocolHelperObject = CreateObject( getProtocolHelperName() )
m_protocolHelperObject.UserName = getUserName()
m_protocolHelperObject.Password = getPassword()
m_protocolHelperObject.IpAddress = getIPAddress()
m_protocolHelperObject.Port = getPort()
m_protocolHelperObject.SkipCNCheck = getSkipCNCheck()
m_protocolHelperObject.SkipCACheck = getSkipCACheck()
m_protocolHelperObject.Encoding = getEncoding()
m_protocolHelperObject.TimeOut = getTimeout()
set createWSMANProtocolHelperObject = m_protocolHelperObject
End Function
Public Function destroyCOMObjects()
Set m_protocolHelperObject = Nothing
End Function
End Class
'**************************************************************************************************
'ProtocolFactory class
'Implements the Factory design pattern
'Provides function for getting the appropriate ProtocolHelper object based on the type of protocol
'**************************************************************************************************
Class ProtocolFactory
Private m_ProtocolHelperObject
Private Sub Class_Initialize
m_ProtocolHelperObject = Null
End Sub
Public Function getProtocolHelperObject(ByRef protocol, protocolParamterObj)
If protocol = "wsman" And protocolParamterObj.getProtocolName() = "wsman" Then
Dim protocolHelperClassObject
Set protocolHelperClassObject = New WSMANProtocolHelper
Dim protHelpName
protHelpName = "OOBHelper.Wsman"
protocolHelperClassObject.setUserName( protocolParamterObj.getProtocolParameterValue("UserName") )
protocolHelperClassObject.setPassword( protocolParamterObj.getProtocolParameterValue("Password") )
protocolHelperClassObject.setProtocolHelperName(protHelpName)
protocolHelperClassObject.setIPAddress( protocolParamterObj.getProtocolParameterValue("IPAddress") )
protocolHelperClassObject.setPort( protocolParamterObj.getProtocolParameterValue("Port") )
protocolHelperClassObject.setEncoding( protocolParamterObj.getProtocolParameterValue("Encoding") )
protocolHelperClassObject.setSkipCACheck( protocolParamterObj.getProtocolParameterValue("SkipCACheck") )
protocolHelperClassObject.setSkipCNCheck( protocolParamterObj.getProtocolParameterValue("SkipCNCheck") )
protocolHelperClassObject.setTimeout( protocolParamterObj.getProtocolParameterValue("Timeout") )
Set m_ProtocolHelperObject = protocolHelperClassObject.createWSMANProtocolHelperObject()
protocolHelperClassObject.destroyCOMObjects()
Set protocolHelperClassObject = Nothing
End If
set getProtocolHelperObject = m_ProtocolHelperObject
End Function
Public Function destroyCOMObjects()
m_ProtocolHelperObject.ClearProfileDictionary()
set m_ProtocolHelperObject = Nothing
End Function
End Class
'**************************************************************************************************
'Component class
'This class objects are sent to OOB MP for creating and submitting SCOM objects
'**************************************************************************************************
Class Component
Private Sub Class_Initialize
m_MgmtConsoleClassName = ""
Set m_AttributeValueDict = CreateObject("Scripting.Dictionary")
m_AttributeValueDict.CompareMode = vbTextCompare
End Sub
Public Function setMgmtConsoleClassName(ByRef name)
m_MgmtConsoleClassName = name
End Function
Public Function getMgmtConsoleClassName()
getMgmtConsoleClassName = m_MgmtConsoleClassName
End Function
Public Function setAttributeValue(ByRef name, value)
Dim message
If (m_AttributeValueDict.Exists(name)) Then
message = "Attribute Name exists"
Else
m_AttributeValueDict.Add name, value
message = "Attribute Name Value inserted"
End If
End Function
Public Function getAttributevalue(ByRef name)
If (m_AttributeValueDict.Exists(name)) Then
getAttributevalue = m_AttributeValueDict.Item(name)
Else
getAttributeValue = Nothing
End If
End Function
Public Function getAttributeValueDict()
Set getAttributeValueDict = m_AttributeValueDict
End Function
Public Function destroyCOMObjects()
m_AttributeValueDict.RemoveAll
set m_AttributeValueDict = Nothing
End Function
End Class
'*************************************************************************************************************
'InventoryDataParser class
'This class parses the output returned by the DeviceHelper dll and prepares Component class objects
'The DiscoveryHelper class then uses the Component class objects to create scom class instance and properties
'*************************************************************************************************************
Class InventoryDataParser
Private Sub Class_Initialize
m_componentInventoryProfileHandle = Null
Set m_componentObjectListDict = CreateObject("Scripting.Dictionary")
m_componentObjectListDict.CompareMode = vbTextCompare
m_count = 0
End Sub
Public Function setComponentInventoryProfileHandle(ByRef handle)
Set m_componentInventoryProfileHandle = handle
End Function
Public Function populateComponentObjects(ByRef profileDict)
Dim i, mgmtConsoleClassNames, componentProfileObject, profClassList, j, profileInstanceList, profileInstance, componentObj, profAttrDict, attributeNamesList, attributeName, attributeValue
Dim profileClassDict, attrPropObj, protAttrName, newProfileInstance, newAttrPropObj, newProtAttrName, newProfileInstanceList
mgmtConsoleClassNames = profileDict.Keys
If Not m_componentInventoryProfileHandle Is Nothing Then
For i=0 to profileDict.Count -1
If profileDict.Exists(mgmtConsoleClassNames(i)) Then
Set componentProfileObject = profileDict.Item(mgmtConsoleClassNames(i))
profClassList = componentProfileObject.getProfileClassNameList()
Set profileClassDict = CreateObject("Scripting.Dictionary")
profileClassDict.CompareMode = vbTextCompare
For j=0 to componentProfileObject.getProfileClassNameListCount() -1
If Not profileClassDict.Exists(profClassList(j)) Then
Set profileInstanceList = m_componentInventoryProfileHandle.Item(profClassList(j))
For Each profileInstance In profileInstanceList
Set componentObj = New Component
componentObj.setMgmtConsoleClassName(mgmtConsoleClassNames(i))
Set profAttrDict = componentProfileObject.getAttributeDictionary()
attributeNamesList = profAttrDict.Keys
For Each attributeName In attributeNamesList
Set attrPropObj = componentProfileObject.getAttributePropertyObject(attributeName)
If attrPropObj.getClassName() = profClassList(j) Then
If Not profileClassDict.Exists(attrPropObj.getClassName()) Then
profileClassDict.Add attrPropObj.getClassName(), "Used"
End If
protAttrName = attrPropObj.getProtocolAttributeName()
If (protAttrName = "Same") Then
'In case the attribute name returned from wsman is same as what is used in Mgmt Console
attributeValue = profileInstance.getProfileAttributeValue(attributeName)
Else
'In case the attribute name returned from wsman is different than what is used in Mgmt Console
attributeValue = profileInstance.getProfileAttributeValue(protAttrName)
End If
'For Attribute Values which might have a additional mapping to another string
If attrPropObj.getIsAttributeMapping() = "Yes" Then
attributeValue = attrPropObj.getAttributeValueMapping(attributeValue)
End If
'If proper attribute value received then set the proper name value
If Not attributeValue = "NA" Then
If attributeValue = "" Then
attributeValue = "Not Available"
End If
call componentObj.setAttributeValue(attributeName,attributeValue)
Else
attributeValue = "Not Applicable"
call componentObj.setAttributeValue(attributeName,attributeValue)
End If
Else
Set newProfileInstanceList = m_componentInventoryProfileHandle.Item(attrPropObj.getClassName())
If Not profileClassDict.Exists(attrPropObj.getClassName()) Then
profileClassDict.Add attrPropObj.getClassName(), "Used"
End If
For Each newProfileInstance In newProfileInstanceList
Set newAttrPropObj = componentProfileObject.getAttributePropertyObject(attributeName)
If newAttrPropObj.getClassName() = attrPropObj.getClassName() Then
newProtAttrName = newAttrPropObj.getProtocolAttributeName()
If (newProtAttrName = "Same") Then
'In case the attribute name returned from wsman is same as what is used in Mgmt Console
attributeValue = newProfileInstance.getProfileAttributeValue(attributeName)
Else
'In case the attribute name returned from wsman is different than what is used in Mgmt Console
attributeValue = newProfileInstance.getProfileAttributeValue(newProtAttrName)
End If
'For Attribute Values which might have a additional mapping to another string
If newAttrPropObj.getIsAttributeMapping() = "Yes" Then
attributeValue = newAttrPropObj.getAttributeValueMapping(attributeValue)
End If
'If proper attribute value received then set the proper name value
If Not attributeValue = "NA" Then
If attributeValue = "" Then
attributeValue = "Not Available"
End If
call componentObj.setAttributeValue(attributeName,attributeValue)
Else
attributeValue = "Not Applicable"
call componentObj.setAttributeValue(attributeName,attributeValue)
End If
End If
Next
End If
Next
addComponentObjects(componentObj)
Next
End If
Next
End If
Next
End If
End Function
Public Function addComponentObjects(ByRef obj)
m_componentObjectListDict.Add m_count, obj
m_count = m_count + 1
End Function
Public Function getComponentObjects()
getComponentObjects = m_componentObjectListDict.Items
End Function
Public Function destroyCOMObjects()
m_componentObjectListDict.RemoveAll
set m_componentObjectListDict = Nothing
If Not m_componentInventoryProfileHandle Is Nothing Then
m_componentInventoryProfileHandle.RemoveAll
set m_componentInventoryProfileHandle = Nothing
End If
End Function
End Class
'**************************************************************************************************
'MOMAPIHelper class
'This class provides wrapper functions for calls made to MOM API functions
'**************************************************************************************************
Class MOMAPIHelper
Private oDiscoveryData
Private oAPI
Private oBag
Public Function CreateMOMScriptAPI
If DebugScript = False Then
Set oAPI = CreateObject("MOM.ScriptAPI")
Else
log.DebugOut "Creating MOM Script API"
Set oAPI = New RegExp
End If
End Function
Public Function CreatePropertyBag
If DebugScript = False Then
set oBag = oAPI.CreatePropertyBag()
Else
Set oBag = New RegExp
End If
End Function
Public Sub AddInstValue(prop, val)
If DebugScript = False Then
Call oBag.AddValue(prop, val)
End If
End Sub
Public Sub AddDataItem()
If DebugScript = False Then
Call oAPI.AddItem(oBag)
End If
End Sub
Public Sub ReturnDataItems
If DebugScript = False Then
Call oAPI.ReturnItems
End If
End Sub
Function LogSCOMEvent(eventMessage, alertNum, alertLevel)
If DebugScript = False Then
Call oAPI.LogScriptEvent("ServerHealthDSMT.vbs", alertNum, alertLevel, eventMessage)
End If
End Function
Public Function destroyCOMObjects()
Set oAPI = Nothing
Set oBag = Nothing
End Function
End Class
'******************************************************************************************************
'ComponentObjectListFilter class
'This class filters the Component Objects and sends it as a list for a specific Management Class Name
'******************************************************************************************************
Class ComponentObjectListFilter
Private Sub Class_Initialize
Set m_componentTypeObjectDict = CreateObject("Scripting.Dictionary")
m_componentTypeObjectDict.CompareMode = vbTextCompare
counter = 0
End Sub
Public Function fetchRequestedComponentObjectList(ByRef compObjList, mgmtClassName)
Dim compObj, message
For Each compObj in compObjList
If Not IsNull(compObj) Then
If compObj.getMgmtConsoleClassName() = mgmtClassName Then
log.MOMDebugLog 1, "key added to filter object: " & counter & "mgmtClassName: " & mgmtClassName
m_componentTypeObjectDict.Add counter, compObj
counter = counter + 1
message = "Component Object inserted into the Dictionary"
End If
message = "Component Object not inserted as the attribute property object is NULL"
End If
Next
m_componentTypeObjectList = m_componentTypeObjectDict.Items
fetchRequestedComponentObjectList = m_componentTypeObjectList
End Function
Public Function destroyCOMObjects()
m_componentTypeObjectDict.RemoveAll
set m_componentTypeObjectDict = Nothing
End Function
End Class
'**************************************************************************************************
'Template method inclusion mechanism
'The following lines will expand the variables holding the VBScript classes and methods
'**************************************************************************************************
$Config/ProfileDictionaryScript$
$Config/ComponentInstanceFactoryScript$
$Config/ServerHealthScript$
creatorFactory.RemoveAll
set creatorFactory = Nothing
Call log.CloseLog() </Script></ScriptBody>
<SecureInput>$Config/Password$</SecureInput>
<TimeoutSeconds>1200</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="PBP"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>