Lenovo.BladeCenter Proxy Computer Discovery Provider

IBM.BladeCenter.ProxyComputer.Discovery.Provider (DataSourceModuleType)

Lenovo.BladeCenter Proxy Computer discovery provider

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

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

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Lenovo.BladeCenter Proxy Computer Discovery Provider Interval Seconds
SyncTimestring$Config/SyncTime$Lenovo.BladeCenter Proxy Computer Discovery Provider Sync Time
TimeoutSecondsstring$Config/TimeoutSeconds$Lenovo.BladeCenter Proxy Computer Discovery Provider Timeout Seconds

Source Code:

<DataSourceModuleType ID="IBM.BladeCenter.ProxyComputer.Discovery.Provider" Accessibility="Internal">
<Configuration>
<xsd:element name="IntervalSeconds" type="xsd:integer"/>
<xsd:element name="SyncTime" type="xsd:string"/>
<xsd:element name="ComputerID" type="xsd:string"/>
<xsd:element name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" ParameterType="int" Selector="$Config/IntervalSeconds$"/>
<OverrideableParameter ID="SyncTime" ParameterType="string" Selector="$Config/SyncTime$"/>
<OverrideableParameter ID="TimeoutSeconds" ParameterType="string" Selector="$Config/TimeoutSeconds$"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime>$Config/SyncTime$</SyncTime>
<ScriptName>IBMBladeCenterProxyComputerDiscovery.vbs</ScriptName>
<Arguments>"$MPElement$" "$Target/Id$" "$Config/ComputerID$"</Arguments>
<ScriptBody><Script>

Option Explicit

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

Dim sourceID, managedEntityID, computerID

sourceID = oArgs(0)
managedEntityID = oArgs(1)
computerID = oArgs(2)

Dim Regdebug, oAPI, oDiscoveryData, oReg

'Debug Log Definition
Const HKEY_LOCAL_MACHINE = &amp;H80000002
Const DEBUG_INFO_KEY = "SOFTWARE\Lenovo\Lenovo SCOM MP\Debug"
Const DEBUG_LEVEL_NAME = "Level"
Const ERROR_LEVEL = 1
Const WARNING_LEVEL = 2
Const WARNING_LEVEL_DEV = 3
Const INFO_LEVEL = 4
Const INFO_LEVEL_FUNCTION = 5
Const INFO_LEVEL_DETAIL = 6

Const RMS_KEY_IBM = "SOFTWARE\IBM\Systems Management Integrations\IBM HW Mgmt Pack for OpsMgr"
Const RMS_KEY_Lenovo = "SOFTWARE\Lenovo\Systems Management Integrations\Lenovo HW Mgmt Pack for OpsMgr"
Const RMS_Name = "RMSName"
Const RMS_MPVER = "Version"

SetLocale("en-us")

Call IBMBladeCenterProxyComputerDiscovery()

Sub IBMBladeCenterProxyComputerDiscovery()

Dim RC_Code
Regdebug = -1
Set oAPI = SCOMCreateObject("MOM.ScriptAPI")
Set oReg = GetObject("winmgmts://localhost/root/default:StdRegProv")
If (not(oReg is nothing)) Then
RC_Code = oReg.GetStringValue(HKEY_LOCAL_MACHINE, DEBUG_INFO_KEY, DEBUG_LEVEL_NAME, Regdebug)
If ( RC_Code&lt;&gt;0) Then
Regdebug = -1
End If
End If

Call LogDebugString("Entering IBMBladeCenterProxyComputerDiscovery", INFO_LEVEL_FUNCTION)

Set oDiscoveryData = oAPI.CreateDiscoveryData(0, sourceID, managedEntityID)

If (CreateIBMBladeCenterProxyComputerInstance() &gt; 0) Then
Call LogDebugString("Created IBM.BladeCenter.ProxyComputer instance", INFO_LEVEL_DETAIL)
End If

Call oAPI.Return(oDiscoveryData)

End Sub

Function CreateIBMBladeCenterProxyComputerInstance()

Call LogDebugString("Entering CreateIBMBladeCenterProxyComputerInstance", INFO_LEVEL_FUNCTION)
Dim oIBMBladeCenterProxyComputerInstance, RC_Code, RMS, MPVER

RC_Code = oReg.GetStringValue(HKEY_LOCAL_MACHINE, RMS_KEY_Lenovo, RMS_Name, RMS)
if IsNull(RMS) Or IsEmpty(RMS) then
RC_Code = oReg.GetStringValue(HKEY_LOCAL_MACHINE, RMS_KEY_IBM, RMS_Name, RMS)
End if

If IsNull(RMS) Then
Call LogDebugString("It is not a BladeCenter proxy computer", INFO_LEVEL)
CreateIBMBladeCenterProxyComputerInstance = -1
Else
Set oIBMBladeCenterProxyComputerInstance = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.BladeCenter.ProxyComputer']$")
Call oIBMBladeCenterProxyComputerInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", computerID)
Call oIBMBladeCenterProxyComputerInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", computerID)
Call oIBMBladeCenterProxyComputerInstance.AddProperty("$MPElement[Name='IBM.BladeCenter.ProxyComputer']/RMSName$", RMS)
RC_Code = oReg.GetStringValue(HKEY_LOCAL_MACHINE, RMS_KEY_Lenovo, RMS_MPVER, MPVER)
if IsNull(MPVER) Or IsEmpty(MPVER) then
RC_Code = oReg.GetStringValue(HKEY_LOCAL_MACHINE, RMS_KEY_IBM, RMS_MPVER, MPVER)
End if

If IsNull(MPVER) Then
Call LogDebugString("Cannot get a BladeCenter proxy computer mp version by registry", INFO_LEVEL)
Else
Call oIBMBladeCenterProxyComputerInstance.AddProperty("$MPElement[Name='IBM.BladeCenter.ProxyComputer']/MgmtPackVersion$", MPVER)
End If
Call oDiscoveryData.AddInstance(oIBMBladeCenterProxyComputerInstance)
CreateIBMBladeCenterProxyComputerInstance = 1
End if

End Function


Function SCOMCreateObject(ByVal sProgramId)

Dim oError
Set oError = New Error

On Error Resume Next
Set SCOMCreateObject = CreateObject(sProgramId)
oError.Save
On Error Goto 0

If (oError.Number &lt;&gt; 0) Then
Call LogDebugString("Error to create object", ERROR_LEVEL)
WScript.Quit
End If

End Function

Sub LogDebugString(debugString, debugLevel)

If (Int(Regdebug) &gt;= Int(debugLevel)) Then
Call oAPI.LogScriptEvent("IBMBladeCenterProxyComputerDiscovery.vbs", 200, DebugLevelToLogLevel(debugLevel), debugString)
End If

End Sub

Function DebugLevelToLogLevel(debugLevel)
DebugLevelToLogLevel = 4
If debugLevel &lt;= 1 then
DebugLevelToLogLevel = 1
ElseIF debugLevel &lt;= 3 then
DebugLevelToLogLevel = 2
Else
DebugLevelToLogLevel = 4
End If
End Function


Class Error
Private lNumber
Private sSource
Private sDescription
Private sHelpContext
Private sHelpFile
Public Sub Save()
lNumber = Err.number
sSource = Err.Source
sDescription = Err.Description
sHelpContext = Err.HelpContext
sHelpFile = Err.helpfile
End Sub
Public Sub Raise()
Err.Raise lNumber, sSource, sDescription, sHelpFile, sHelpContext
End Sub
Public Sub Clear()
lNumber = 0
sSource = ""
sDescription = ""
sHelpContext = ""
sHelpFile = ""
End Sub
Public Default Property Get Number()
Number = lNumber
End Property
Public Property Get Source()
Source = sSource
End Property
Public Property Get Description()
Description = sDescription
End Property
Public Property Get HelpContext()
HelpContext = sHelpContext
End Property
Public Property Get HelpFile()
HelpFile = sHelpFile
End Property
End Class
</Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>