Dell License Configuration Discovery DSMT

Dell.LicenseServerConfiguration.Discovery.DSMT (DataSourceModuleType)

This discovery module configures the license web server url

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource System.Discovery.Scheduler Default
P1 ProbeAction Microsoft.Windows.ScriptDiscoveryProbe Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
LogLevelint$Config/LogLevel$Log LevelDell License Configuration Discovery log level
Intervalstring$Config/Interval$Interval SecondsDell License Configuration Discovery interval seconds
LicenseWebServerURLstring$Config/LicenseWebServerURL$License Web Server URLLicense Web Server URL
TimeOutSecondsstring$Config/TimeOutSeconds$License Server Request timeoutLicense Server Request timeout

Source Code:

<DataSourceModuleType ID="Dell.LicenseServerConfiguration.Discovery.DSMT" Accessibility="Internal" Batching="false">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>System!System.Discovery.MapperSchema</SchemaType>
<SchemaType>System!System.ExpressionEvaluatorSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element minOccurs="1" name="LogLevel" type="xsd:integer"/>
<xsd:element minOccurs="1" name="Interval" type="xsd:integer"/>
<xsd:element minOccurs="1" maxOccurs="1" name="ManagementServerPrincipalName" type="xsd:string"/>
<xsd:element minOccurs="1" maxOccurs="1" name="LicenseWebServerURL" type="xsd:string"/>
<xsd:element minOccurs="1" maxOccurs="1" name="TimeOutSeconds" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="LogLevel" Selector="$Config/LogLevel$" ParameterType="int"/>
<OverrideableParameter ID="Interval" Selector="$Config/Interval$" ParameterType="string"/>
<OverrideableParameter ID="LicenseWebServerURL" Selector="$Config/LicenseWebServerURL$" ParameterType="string"/>
<OverrideableParameter ID="TimeOutSeconds" Selector="$Config/TimeOutSeconds$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.Discovery.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval Unit="Seconds">$Config/Interval$</Interval>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction ID="P1" TypeID="Windows!Microsoft.Windows.ScriptDiscoveryProbe">
<ScriptName>LicenseConfiguration_Discovery.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Config/ManagementServerPrincipalName$ $Config/LicenseWebServerURL$ $Config/TimeOutSeconds$ $Config/LogLevel$</Arguments>
<ScriptBody><Script>
'**********************************************************************************
' Script Name - LicenseConfiguration_Discovery
' Author: Sriram Venkatesh
'
' Description:
' * Creates LicenseConfiguration_Discovery object
' * Invokes Dell Device Helper to configure the License Web Server URL
'
' (c) Copyright &#xA9; 2009&#x2013; 2017 Dell Inc, or its subsidiaries. All Rights Reserved
'**********************************************************************************

Option Explicit
'On Error Resume Next
SetLocale("en-us")
Const DebugScript = False
Dim oArgs
Set oArgs = WScript.Arguments

Dim SourceId, ManagedEntityId
Dim oAPI, oDiscoveryData, oInstance

Dim sPrincipalName, licenseWebServerURL, timeOutSeconds, oReg
Dim logLevel
Dim log: Set log = New Logger

SourceId = oArgs(0)
ManagedEntityId = oArgs(1)
sPrincipalName = oArgs(2)
licenseWebServerURL = oArgs(3)
timeOutSeconds = oArgs(4)
logLevel = oArgs(5)

Call log.CreateLog("")
log.MOMDebugLog 1, "------------------License Configuration Discovery-------------------"

log.MOMDebugLog 1, "licenseWebServerURL is: " &amp; 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 &lt;&gt; "" 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 &lt;&gt; "" Then
' Persisting the license url onto the registry
log.MOMDebugLog 1, "Persisting the license url onto the registry" &amp; 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 &lt;&gt; "" And licenseWebServerURL &lt;&gt; "http://licensewebserver.company.com:8543/" Then
Dim cachefilepath
If serverSuitePath &lt;&gt; "" Then
cachefilepath = serverSuitePath &amp; "Library/"
log.MOMDebugLog 1, "Calling InitializeLicenseClient() for cache file path: " &amp; cachefilepath
dellDeviceHelperObject.InitializeLicenseClient cachefilepath

log.MOMDebugLog 1, "Calling ConfigureLicenseWebServer() for url: " &amp; licenseWebServerURL &amp; " and timeout: " &amp; timeOutSeconds
dellDeviceHelperObject.ConfigureLicenseWebServer licenseWebServerURL, timeOutSeconds
End If
Else
log.MOMDebugLog 1, "Not Calling ConfigureLicenseWebServer() since url is the default url..." &amp; licenseWebServerURL &amp; " and timeout: " &amp; 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 &lt;&gt; 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,".") &gt; 0 ) Then
hyphenIP = Replace(hyphenIP,".","_")
End If
If ( InStr(hyphenIP,":") &gt; 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 &amp; "\" &amp; oobLogsFolder) Then
FileSystemObject.CreateFolder(tFolder &amp; "\" &amp; oobLogsFolder)
End If
strOutFile = tFolder &amp; "\" &amp; oobLogsFolder &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 logLevel &lt;&gt; 0 Then
If (debugLevel &gt; 0) and (debugLevel &lt;= logLevel) Then
objLogTextFile.WriteLine(Now() &amp; " ---- " &amp; Message)
Err.Clear
End If
End If
End Sub

Function CloseLog()
If logLevel &lt;&gt; 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>