log.MOMDebugLog 1, "licenseWebServerURL is: " & licenseWebServerURL
' Configure the License Web Server URL
Dim dellDeviceHelperObject
Dim serverSuitePath
serverSuitePath = GetRegistryValue ("HKEY_LOCAL_MACHINE\Software\Dell\Dell Server Management Pack Suites\Path")
If serverSuitePath <> "" Then
log.MOMDebugLog 1, "Server Suite presence detected...Loading DellDeviceHelper..."
set dellDeviceHelperObject=CreateObject("OOBHelper.LicenseConfiguration")
If dellDeviceHelperObject Is Nothing Then
log.MOMDebugLog 1, "Unable to load DellDeviceHelper dll, hence not proceeding to configure the License server url"
log.MOMDebugLog 1, "Got dellDeviceHelperObject as NULL during CreateObject(OOBHelper.LicenseConfiguration)"
Else
If licenseWebServerURL <> "" Then
' Persisting the license url onto the registry
log.MOMDebugLog 1, "Persisting the license url onto the registry" & licenseWebServerURL
Set oReg = CreateObject("WScript.Shell")
Call oReg.RegWrite("HKEY_LOCAL_MACHINE\Software\Dell\Dell Server Management Pack Suites\LicenseWebServerURL", licenseWebServerURL)
End If
' Configure the license web server url only if the url is not the default url
If licenseWebServerURL <> "" And licenseWebServerURL <> "http://licensewebserver.company.com:8543/" Then
Dim cachefilepath
If serverSuitePath <> "" Then
cachefilepath = serverSuitePath & "Library/"
log.MOMDebugLog 1, "Calling InitializeLicenseClient() for cache file path: " & cachefilepath
dellDeviceHelperObject.InitializeLicenseClient cachefilepath
log.MOMDebugLog 1, "Calling ConfigureLicenseWebServer() for url: " & licenseWebServerURL & " and timeout: " & timeOutSeconds
dellDeviceHelperObject.ConfigureLicenseWebServer licenseWebServerURL, timeOutSeconds
End If
Else
log.MOMDebugLog 1, "Not Calling ConfigureLicenseWebServer() since url is the default url..." & licenseWebServerURL & " and timeout: " & timeOutSeconds
End If
End If
Else
log.MOMDebugLog 1, "Server Suite is not present or registry is corrupt...Not loading DellDeviceHelper..."
End If
' Submit empty discovery data
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oDiscoveryData = oAPI.CreateDiscoveryData(0,SourceId,ManagedEntityId)
Set oInstance = oDiscoveryData.CreateClassInstance("$MPElement[Name='Dell.LicenseConfigurationDiscovery.Sink']$")
call oInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Dell License Configuration Discovery Sink")
call oInstance.AddProperty("$MPElement[Name='Dell.LicenseConfigurationDiscovery.Sink']/InstanceID$", sPrincipalName)
call oInstance.AddProperty("$MPElement[Name='Dell.LicenseConfigurationDiscovery.Sink']/LicenseWebServerURL$", licenseWebServerURL)
call oInstance.AddProperty("$MPElement[Name='Dell.LicenseConfigurationDiscovery.Sink']/TimeOutSeconds$", timeOutSeconds)
oDiscoveryData.AddInstance oInstance
log.MOMDebugLog 1, "Submitting discovery data - license configuration discovery sink object...."
Call oAPI.Return(oDiscoveryData)
Set oDiscoveryData = Nothing
Set oAPI = Nothing
Set oReg = Nothing
Set dellDeviceHelperObject = Nothing
log.MOMDebugLog 1, "------------------End of License Configuration Discovery-------------------"
log.CloseLog
'#################################################################################################################################
'**********************************************************************************
' GLOBAL METHODS
'**********************************************************************************
Function GetRegistryValue (strRegistryKey )
Dim WSHShell, value
On Error Resume Next
Set WSHShell = CreateObject("WScript.Shell")
value = WSHShell.RegRead( strRegistryKey )
set WSHShell = nothing
GetRegistryValue = value
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 = "Discovery_LicenseConfiguration.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 </Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="P1">
<Node ID="DS"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>