'#################################################################################################################################
'**********************************************************************************
' GLOBAL VARIABLES
'**********************************************************************************
Const DebugScript = False
Dim scriptArgs
Dim SourceId
Dim ManagedEntityId
Dim logLevel
Dim doDiscoveryFlag
Dim iDRACNicEnableFlag
Dim suppressDiscoveryEvents
Dim principalName, msIPAddress, SendMSFQN
Dim log: Set log = New Logger
Dim protParameterObj: Set protParameterObj = New ProtocolInfo
Dim creatorFactory: Set creatorFactory = CreateObject("Scripting.Dictionary")
Set scriptArgs = WScript.Arguments
'If scriptArgs.Count < 4 Then
' Wscript.Quit -1
'End If
If DebugScript = False Then
'Get Principal Name
principalName = GetRegistryValue("HKEY_LOCAL_MACHINE\Software\Dell Computer Corporation\Dell Management Pack Suites\MSHostname")
msIPAddress = GetRegistryValue("HKEY_LOCAL_MACHINE\Software\Dell Computer Corporation\Dell Management Pack Suites\MSIPAddress")
SendMSFQN = "false"
Else
principalName = "DummySystem"
End If
'**************************************************************************************************
'Template method inclusion mechanism
'The following lines will expand the variables holding the VBScript classes and methods
'**************************************************************************************************
$Config/TemplateScriptConfiguration$
'#################################################################################################################################
'**********************************************************************************
' GLOBAL METHODS
'**********************************************************************************
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 GetRegistryValue (strRegistryKey )
Dim WSHShell, value
On Error Resume Next
Set WSHShell = CreateObject("WScript.Shell")
value = WSHShell.RegRead( strRegistryKey )
If(strcomp(value,"") = 0) Then
value = GetMSName()
end if
set WSHShell = nothing
GetRegistryValue = value
End Function
'#################################################################################################################################
'**********************************************************************************
' DSMT ENGINE CLASSES
'**********************************************************************************
'*****************************************************************
'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 = "Discovery_DellServer_" & hyphenIP & ".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
'**************************************************************************************************
'DiscoveryPreChecker class
'Provides functions for checking the prerequisite in order to proceed with doing discovery
'**************************************************************************************************
Class DiscoveryPreChecker
Private m_Protocol
Private m_ProtParameterObj
Private m_protocolHelperObject
Private m_ProfileClassList
Private m_ProfileClassDict
'Please DO NOT change this string. This is the feature name used to retrieve licenses.
m_FeatureName = "Server Out-of-Band Monitoring"
m_deviceServiceTag = ""
Public Function getServerType()
getServerType = m_ServerType
End Function
Public Function getServerGeneration()
getServerGeneration = m_ServerGeneration
End Function
Public Function getGeneration()
getGeneration = m_Generation
End Function
'Public Function getModel()
' getModel = m_Model
'End Function
Public Function isServerManaged()
isServerManaged = m_isServerManaged
End Function
Public Function setProtocol(ByRef protocol)
m_Protocol = protocol
End Function
Public Function setProtocolParameterObject(ByRef ProtParameterObj)
Set m_ProtParameterObj = ProtParameterObj
End Function
Public Function setComponentInventoryProfileHandle(ByRef componentInventoryProfileHandleObj)
Set m_componentInventoryProfileHandle = componentInventoryProfileHandleObj
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 setProductName(productName)
m_ProductName = productName
End Function
Public Function setProductVersion(productVersion)
m_ProductVersion = productVersion
End Function
Public Function setFeatureName(featureName)
m_FeatureName = featureName
End Function
Public Function isDoDiscoveryFlagSet()
If doDiscoveryFlag = "false" Then
' We need to do discovery only through Agent-based means, so make Agent-free discovery false
log.MOMDebugLog 1, "Not performing the discovery, since the preferred monitoring is not set as Agent-free."
isDoDiscoveryFlagSet = False
Exit Function
Else
' We need to do discovery only through Agent-free means, so make Agent-free discovery true
isDoDiscoveryFlagSet = True
End If
End Function
Public Function isiDRACNicEnableFlagSet()
If iDRACNicEnableFlag = "false" Then
isiDRACNicEnableFlagSet = False
Exit Function
Else
isiDRACNicEnableFlagSet = True
End If
End Function
Public Function IsHostNicPresent()
Dim profileClass, modelType, returnVal,deviceFQDD, profileInstance, profileInstanceList
returnVal = "False"
If m_componentInventoryProfileHandle Is Nothing Then
log.MOMDebugLog 1, "Got componentInventory object as NULL during HostNIC"
else
'check for DeviceFQDD is valid
For Each profileClass in m_ProfileClassList
Set profileInstanceList = m_componentInventoryProfileHandle.Item(profileClass)
For Each profileInstance In profileInstanceList
modelType = profileInstance.getProfileAttributeValue("deviceFQDD")
If NOT deviceFQDD = "null" Then
returnVal = "True"
Exit For
End If
Next
Next
End If
IsHostNicPresent = returnVal
End Function
Public Function isPCIeSSDExtenderPresent()
Dim returnVal, profileInstance, profileClass, profileInstanceList
returnVal = "False"
If m_componentInventoryProfileHandle Is Nothing Then
log.MOMDebugLog 1, "Got componentInventory object as NULL during isPCIeSSDExtenderPresent"
Else
For Each profileClass in m_ProfileClassList
Set profileInstanceList = m_componentInventoryProfileHandle.Item(profileClass)
For each profileInstance in profileInstanceList
returnVal = "True"
Next
Next
End If
isPCIeSSDExtenderPresent = returnVal
End Function
Public Function isPCIeSSDBackPlanePresent()
Dim returnVal, profileInstance, profileClass, profileInstanceList
returnVal = "False"
If m_componentInventoryProfileHandle Is Nothing Then
log.MOMDebugLog 1, "Got componentInventory object as NULL during isPCIeSSDExtenderPresent"
Else
For Each profileClass in m_ProfileClassList
Set profileInstanceList = m_componentInventoryProfileHandle.Item(profileClass)
For each profileInstance in profileInstanceList
returnVal = "True"
Next
Next
End If
isPCIeSSDBackPlanePresent = returnVal
End Function
Public Function isPCIeSSDPhysicalDiskPresent()
Dim returnVal, profileInstance, profileClass, profileInstanceList
returnVal = "False"
If m_componentInventoryProfileHandle Is Nothing Then
log.MOMDebugLog 1, "Got componentInventory object as NULL during isPCIeSSDExtenderPresent"
Else
For Each profileClass in m_ProfileClassList
Set profileInstanceList = m_componentInventoryProfileHandle.Item(profileClass)
For each profileInstance in profileInstanceList
returnVal = "True"
Next
Next
End If
isPCIeSSDPhysicalDiskPresent = returnVal
End Function
Public Function doServerClassification()
Dim attributeName, attributeValue, profileClass, modelType, systemType, systemGen, generation
Dim profileInstance, profileInstanceList, serviceTag, chassisServiceTag
If m_componentInventoryProfileHandle Is Nothing Then
log.MOMDebugLog 1, "Unable to load OOBHelper dll, hence not discovering the server"
log.MOMDebugLog 1, "Got componentInventory object as NULL during classification"
m_ServerGeneration = ""
m_isServerManaged = ""
Exit Function
End If
For Each profileClass in m_ProfileClassList
Set profileInstanceList = m_componentInventoryProfileHandle.Item(profileClass)
For Each profileInstance In profileInstanceList
attributeName = "Manufacturer"
attributeValue = profileInstance.getProfileAttributeValue(attributeName)
log.MOMDebugLog 1, "Manufacture Attribute Value is : " & attributeValue
log.MOMDebugLog 1, "Service Tag is : " & serviceTag
log.MOMDebugLog 1, "Chassis Service Tag is : : " & chassisServiceTag
'Possible values for Manufacturer are as follows
'a) for Dell Branded Servers Or Dell Branded OEM Servers(As per Existing code) -- Starts With "Dell Inc." OR "Dell" OR "Dell "
'b) for OEM Ready Servers ------------------- Space Character i.e " "
If instr(Lcase(attributeValue), "dell ") = 1 OR Lcase(attributeValue) = "dell" OR Trim(attributeValue) = "" Then
systemGen = Split(profileInstance.getProfileAttributeValue("SystemGeneration"))
m_Generation =(Split(systemGen(0),"G"))(0)
log.MOMDebugLog 1, "System Generation: " & m_Generation
if(m_Generation > 11) then
m_ServerGeneration = m_Generation+"th Generation"
m_isServerManaged = "True"
Else
m_ServerGeneration = "NA"
m_isServerManaged = "False"
End If
'systemType = profileInstance.getProfileAttributeValue("ChassisName")
modelType = profileInstance.getProfileAttributeValue("Model")
'm_Model = modelType
log.MOMDebugLog 1, "Chassis Model Type: " & modelType
log.MOMDebugLog 1, "Generation Type : " & systemGen(1)
If (InStr(modelType,"Precision Rack") <> 0) Then
m_ServerType = "Dell Rack WorkStation"
ElseIf systemGen(1) = "Monolithic" Then
m_ServerType = "Monolithic Server"
ElseIf (InStr(modelType,"PowerEdge FC") <> 0) Then
m_ServerType = "Sled Server"
ElseIf (InStr(modelType,"PowerEdge FM") <> 0) Then
m_ServerType = "Sled FM Server"
ElseIf systemGen(1) = "Modular" Then
m_ServerType = "Modular Server"
ElseIf systemGen(1) = "DCS" Then
m_ServerType = "Monolithic Server"
ElseIf (InStr(modelType,"PowerVault NX") <> 0) Then
m_ServerType = "PowerVault NX"
ElseIf serviceTag <> chassisServiceTag Then
m_ServerType = "Modular Server"
Else
m_ServerType = "Monolithic Server"
End If
log.MOMDebugLog 1, "Server Type : " & m_ServerType
Else
m_ServerGeneration = ""
m_isServerManaged = ""
End If
Next
Next
End Function
Public Function fetchSystemInfoFromDevice()
Set protFactoryObj = New ProtocolFactory
Set m_protocolHelperObject = protFactoryObj.getProtocolHelperObject(m_Protocol, m_ProtParameterObj)
m_ProfileClassList = m_ProfileClassDict.Keys
m_protocolHelperObject.ProfileNameArrayObj = m_ProfileClassList
Set sysInfoObject = m_protocolHelperObject.GetProfileDictionary()
log.MOMDebugLog 1, "Received the Profile Dictionary from DellDeviceHelper."
Set fetchSystemInfoFromDevice = sysInfoObject
End Function
Public Function destroyCOMObjects()
protFactoryObj.destroyCOMObjects()
Set protFactoryObj = Nothing
m_protocolHelperObject.ClearProfileDictionary()
Set m_protocolHelperObject = Nothing
Set sysInfoObject = Nothing
m_ProfileClassDict.RemoveAll
Set m_ProfileClassDict = Nothing
m_momAPIHelper.destroyCOMObjects()
Set m_momAPIHelper = Nothing
Set m_componentInventoryProfileHandle = 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 setSkipRevocationCheck(ByRef SkipRevoCheck)
m_SkipRevocation = cbool(SkipRevoCheck)
End Function
Public Function getSkipRevocationCheck()
getSkipRevocationCheck = cbool(m_SkipRevocation)
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.SkipRevocationCheck = getSkipRevocationCheck()
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.setSkipRevocationCheck( protocolParamterObj.getProtocolParameterValue("SkipRevocationCheck") )
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 Agent-free 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 modifyExistingAttributeValue(ByRef name, value)
Dim existingValue
If (m_AttributeValueDict.Exists(name)) Then
existingValue = m_AttributeValueDict.Item(name)
m_AttributeValueDict.Remove(name) 'Removing the existing key value pair
m_AttributeValueDict.Add name, value
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 Sub Class_Initialize
' Statements go here.
Set oAPI = CreateMOMScriptAPI
End Sub
Function CreateMOMScriptAPI
If DebugScript = False Then
Set CreateMOMScriptAPI = CreateObject("MOM.ScriptAPI")
Else
log.DebugOut "Creating MOM Script API"
Set CreateMOMScriptAPI = New RegExp
End If
End Function
Function CreateDiscoveryData(ByRef SourceId, ByRef ManagedEntityId)
If DebugScript = False Then
Set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
set CreateDiscoveryData = oDiscoveryData
Else
Set CreateDiscoveryData = New RegExp
End If
Dim logMessage
logMessage = "INFO: New Discovery Data"
log.MOMDebugLog 1, logMessage
End Function
Function SubmitDiscoveryData()
If DebugScript = False Then
Call oAPI.Return(oDiscoveryData)
End If
Dim logMessage
logMessage = "INFO: Returning Discovery Data"
log.MOMDebugLog 1, logMessage
End Function
Sub oInstAddProperty(ByRef oInst, prop, val)
If DebugScript = False Then
Call oInst.AddProperty(prop, val)
End If
Dim logMessage
logMessage = "INFO: Set " & prop & " = " & val
log.MOMDebugLog 1, logMessage
End Sub
Function CreateClassInstance(classid)
If DebugScript = False Then
set CreateClassInstance = oDiscoveryData.CreateClassInstance(classid)
Else
Set CreateClassInstance = New RegExp
End If
Dim logMessage
logMessage = "INFO: New Class Instance" & classid
log.MOMDebugLog 1, logMessage
End Function
Function CreateRelationshipInstance(classid, ByRef oInst1, ByRef oInst2)
If DebugScript = False Then
Dim oRelationshipInst
set oRelationshipInst = oDiscoveryData.CreateRelationshipInstance(classid)
oRelationshipInst.Source = oInst1
oRelationshipInst.Target = oInst2
set CreateRelationshipInstance = oRelationshipInst
Else
Set CreateRelationshipInstance = New RegExp
End If
Dim logMessage
logMessage = "INFO: New Relationship Instance" & classid
log.MOMDebugLog 1, logMessage
End Function
Sub AddInstanceToDiscoveryData(ByRef oInst)
If DebugScript = False Then
Call oDiscoveryData.AddInstance(oInst)
End If
Dim logMessage
logMessage = "INFO: AddInstance to Discovery Data"
log.MOMDebugLog 1, logMessage
End Sub
Function GetDiscoveryData()
set GetDiscoveryData = oDiscoveryData
End Function
Sub SubmitDiscoveryData1(oDiscoData)
If DebugScript = False Then
Call oAPI.Return(oDiscoData)
Else
log.DebugOut "Returning Discovery Data"
End If
End Sub
Function LogSCOMEvent(eventMessage, alertNum, alertLevel)
If DebugScript = False Then
Call oAPI.LogScriptEvent("ServerDiscoveryDSMT.vbs", alertNum, alertLevel, eventMessage)
End If
Dim logMessage
logMessage = "Generated EVENT: " & eventMessage
log.MOMDebugLog 1, logMessage
End Function
Public Function destroyCOMObjects()
set oDiscoveryData = Nothing
set oAPI = 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
'#################################################################################################################################
'**************************************************************************************************
'Template method inclusion mechanism
'The following lines will expand the variables holding the VBScript classes and methods
'**************************************************************************************************
$Config/ProfileDictionaryScript$
$Config/ComponentInstanceFactoryScript$
$Config/PrePopulationScript$
$Config/ServerDiscoveryScript$
'#################################################################################################################################
'#################################################################################################################################
'**************************************************************************************************
'Resource Clean up statements goes here
'**************************************************************************************************
creatorFactory.RemoveAll
set creatorFactory = Nothing
Call log.CloseLog()
'################################################################################################################################# </Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DP"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>