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<>0) Then
Regdebug = -1
End If
End If
Set oDiscoveryData = oAPI.CreateDiscoveryData(0, sourceID, managedEntityID)
If (CreateIBMBladeCenterProxyComputerInstance() > 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 <> 0) Then
Call LogDebugString("Error to create object", ERROR_LEVEL)
WScript.Quit
End If
End Function
Sub LogDebugString(debugString, debugLevel)
If (Int(Regdebug) >= Int(debugLevel)) Then
Call oAPI.LogScriptEvent("IBMBladeCenterProxyComputerDiscovery.vbs", 200, DebugLevelToLogLevel(debugLevel), debugString)
End If
End Sub
Function DebugLevelToLogLevel(debugLevel)
DebugLevelToLogLevel = 4
If debugLevel <= 1 then
DebugLevelToLogLevel = 1
ElseIF debugLevel <= 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>