SetLocale("en-us")
Dim SourceID, ManagedEntityId, TargetComputer
'SourceId = "$MPElement$" ' The GUID of the Discovery that launched the script.
'ManagedEntityId = "$Target/Id$" ' The GUID of the computer class targeted by the script.
'TargetComputer = oArgs(2) ' The FQDN of the computer targeted by the script.
Dim oArgs, EncodeCmtyStr
Set oArgs = WScript.Arguments
WScript.Echo oArgs.Count
if oArgs.Count < 4 Then
'Wscript.Quit -1
End If
Set oAPI = CreateObject("MOM.ScriptAPI")
ipaddress = oArgs(0)
SourceId = oArgs(1)
ManagedEntityId = oArgs(2)
EncodeCmtyStr = oArgs(3)
WScript.Echo(ipaddress)
WScript.Echo(SourceId)
WScript.Echo(ManagedEntityId)
'*************************************
'The aArgs(3) "$Config/CommunityString$" is not encoded string. such as "public"
'*******************************************
'EncodeCmtyStr="public"
CommunityString = oArgs(3) 'Chr2Unicode(fDecode(EncodeCmtyStr))
EncodeCmtyStr=CommunityString
WScript.Echo(CommunityString)
Dim chassisUUID
Set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
Set SCOMServer = WScript.CreateObject("IBM.SystemsManagement.SCOMHelper.SCOMServer")
Call GetDebugLevel()
Call oAPI.LogScriptEvent("IBMBladeCenterModuleDiscovery.vbs", 1000, 4, "Module Discovery begin on BladeCenter: " + ipaddress)
'Call oAPI.LogScriptEvent("IBMBladeCenterModuleDiscovery.vbs", 1000, 4, "EncodeCommunityString: " + oArgs(3)) ' it is "public"!!!!!!!!!
'-----------------------------------------------------------------------------
' End of Main
'-----------------------------------------------------------------------------
Sub ComponentDiscovery()
WScript.Echo("------------------------------------------------------")
Call WScript.Echo(" Lenovo BladeCenter Components Discovery")
WScript.Echo("------------------------------------------------------")
bccInstalled = IsInstallBCCProject()
If (Isnull(ipaddress)) then
Call LogDebugString("Error: Bad or missing ipaddress!", ERROR_LEVEL)
Else
Set bladeChassis = WScript.CreateObject("IBM.SystemsManagement.MMClassLibrary.BladeChassis")
Call WScript.Echo("Inventory For chassis " & " at " & ipaddress)
Call LogDebugString("Inventory For chassis " & " at " & ipaddress, INFO_LEVEL_FUNCTION)
Dim i
i = 0
Dim bladeModuleCount
bladeModuleCount = 0
Dim ioModuleCount
ioModuleCount = 0
Dim mmModuleCount
mmModuleCount = 0
Dim poweModuleCount
poweModuleCount = 0
Dim blowerModuleCount
blowerModuleCount = 0
Dim mediaModuleCount
mediaModuleCount = 0
Dim storageModuleCount
storageModuleCount = 0
Dim diskDriveModuleCount
diskDriveModuleCount = 0
Dim bladeModuleIndex
bladeModuleIndex = 0
Dim ioModuleIndex
ioModuleIndex = 0
Dim mmModuleIndex
mmModuleIndex = 0
Dim powerModuleIndex
powerModuleIndex = 0
Dim blowerModuleIndex
blowerModuleIndex = 0
Dim mediaModuleIndex
mediaModuleIndex = 0
Dim storageModuleIndex
storageModuleIndex = 0
Dim init
init = -1
init = bladeChassis.InitializeSocketConnection(ipaddress, CommunityString,0,"V1")
Call LogDebugString("init = " & init, INFO_LEVEL_DETAIL)
If (init = 0) then
'Call LogDebugString("Try logging in using Default", WARNING_LEVEL)
Dim loggedin
loggedin = 0
'loggedin = bladeChassis.LoginDefault()
If (loggedin <> 0) then
Call LogDebugString("Warning - Could not log in to management module using defaults, trying Userid/Password table", WARNING_LEVEL)
'loggedin = bladeChassis.LoginByTable()
End If
'Call LogDebugString("Loggedin = " & loggedin, INFO_LEVEL)
If (loggedin = 0) then
Dim retval
retval = bladeChassis.GetTopology() '->lin no get storage
If (retval = 0) Then
' Blade Modules
bladeModuleCount = bladeChassis.GetBladeModuleCount()
Dim bladesInstalled
bladesInstalled = bladeChassis.GetBladeModulesInstalled()
WScript.Echo("===========================================")
Call WScript.Echo(" MaxbladeModuleCount = " & bladeModuleCount)
WScript.Echo("===========================================")
Call LogDebugString("MaxbladeModuleCount = " & bladeModuleCount, INFO_LEVEL_DETAIL)
Dim btwoSlot
btwoSlot = False
For each item in bladesInstalled
bayNumber = bayNumber + 1
If btwoSlot = True Then
btwoSlot = False
'just jump this bay, do not create Pseudo
Else
If (item = true) then
Call CreateBlade( bayNumber,bladeChassis.GetBladeModule(bayNumber) )
if (bladeChassis.GetBladeModule(bayNumber).SlotWidth > 1) then
btwoSlot = true
else
btwoSlot = false
end if
Else
Call CreatePseudo(bayNumber,"Blade",chassisUUID ,0)
btwoSlot = False
End If
If bayNumber >= bladeModuleCount then
Exit For
End If
Call LogDebugString("ioModuleCount = " & ioModuleCount, INFO_LEVEL_DETAIL)
WScript.Echo("===========================================")
Call WScript.Echo(" MaxioModuleCount = " & ioModuleCount)
WScript.Echo("===========================================")
bayNumber = 0
For each item in ioModulesInstalled
bayNumber = bayNumber+1
If (item = true) then
Call CreateSwitch(bayNumber,bladeChassis.GetIOModule(bayNumber))
else
Call CreatePseudo(bayNumber,"IO",chassisUUID,0)
End If
if bayNumber >= ioModuleCount then
Exit For
end if
Next
' Management Modules 'linlin how about backup MM ?
mmModuleCount = bladeChassis.GetManagementModuleCount()
Dim mmModulesInstalled
mmModulesInstalled = bladeChassis.GetManagementModulesInstalled()
Call LogDebugString("mmModuleCount = " & mmModuleCount, INFO_LEVEL)
bayNumber = 0
Call LogDebugString("MaxmmModuleCount = " & mmModuleCount, INFO_LEVEL_DETAIL)
WScript.Echo("===========================================")
Call WScript.Echo(" MaxmmModuleCount = " & mmModuleCount)
WScript.Echo("===========================================")
For each item in mmModulesInstalled
bayNumber = bayNumber+1
If (item = true) then
Call CreateManagement( bayNumber,bladeChassis.GetManagementModule(bayNumber) )
else
Call CreatePseudo(bayNumber,"MM",chassisUUID,0)
End If
if bayNumber >= mmModuleCount then
Exit For
end if
Next
' Power Modules
powerModuleCount = bladeChassis.GetPowerModuleCount()
Dim powerModulesInstalled
powerModulesInstalled = bladeChassis.GetPowerModulesInstalled()
Dim powerInstalledString
powerInstalledString = InstalledString(powerModuleCount, powerModulesInstalled)
Call LogDebugString("powerModuleCount = " & powerModuleCount, INFO_LEVEL_DETAIL)
WScript.Echo("===========================================")
Call WScript.Echo(" MaxpowerModuleCount = " & powerModuleCount)
WScript.Echo("===========================================")
bayNumber = 0
For each item in powerModulesInstalled
bayNumber = bayNumber+1
If (item = true) then
Call CreatePower( bayNumber, bladeChassis.GetPowerModule(bayNumber))
else
Call CreatePseudo(bayNumber,"Power",chassisUUID,0)
End If
if bayNumber >= powerModuleCount then
Exit For
end if
Next
' Blower Modules
blowerModuleCount = bladeChassis.GetBlowerModuleCount()
Dim blowerModulesInstalled
blowerModulesInstalled = bladeChassis.GetBlowerModulesInstalled()
Dim blowerInstalledString
blowerInstalledString = InstalledString(blowerModuleCount, blowerModulesInstalled)
Call LogDebugString("Blower module count = " & blowerModuleCount, INFO_LEVEL_DETAIL)
WScript.Echo("===========================================")
Call WScript.Echo(" MaxblowerModuleCount = " & blowerModuleCount)
WScript.Echo("===========================================")
bayNumber = 0
For each item in blowerModulesInstalled
bayNumber = bayNumber+1
If (item = true) then
Call CreateBlower(bayNumber,bladeChassis.GetBlowerModule(bayNumber))
else
Call CreatePseudo(bayNumber,"Blower",chassisUUID,0)
End If
if bayNumber >= blowerModuleCount then
Exit For
end if
Next
'Media Modules
mediaModuleCount = bladeChassis.GetMediaModuleCount()
Dim mediaModulesInstalled
mediaModulesInstalled = bladeChassis.GetMediaModulesInstalled()
Dim mediaInstalledString
mediaInstalledString = InstalledString(mediaModuleCount, mediaModulesInstalled)
Call LogDebugString("Media module count = " & mediaModuleCount, INFO_LEVEL_DETAIL)
WScript.Echo("===========================================")
Call WScript.Echo(" MaxMediaModuleCount = " & mediaModuleCount)
WScript.Echo("===========================================")
bayNumber = 0
For each item in mediaModulesInstalled
bayNumber = bayNumber+1
If (item = true) then
Call CreateMedia(bayNumber,bladeChassis.GetMediaModule(bayNumber))
else
Call CreatePseudo(bayNumber,"Media",chassisUUID,0)
End If
if bayNumber >= mediaModuleCount then
Exit For
end if
Next
'GetStorageModule
storageModuleCount = bladeChassis.GetStorageModuleCount()
Dim storageModulesInstalled
storageModulesInstalled = bladeChassis.GetStorageModulesInstalled()
Dim storageInstalledString
storageInstalledString = InstalledString(storageModuleCount, storageModulesInstalled)
Call LogDebugString("Storage module count = " & storageModuleCount, INFO_LEVEL_DETAIL)
WScript.Echo("===========================================")
Call WScript.Echo(" MaxStorageModuleCount = " & storageModuleCount)
WScript.Echo("===========================================")
bayNumber = 0
For each item in storageModulesInstalled
bayNumber = bayNumber+1
If (item = true) then
Call CreateStorage(bayNumber,bladeChassis.GetStorageModule(bayNumber))
else
Call CreatePseudo(bayNumber,"Storage",chassisUUID,0)
End If
if bayNumber >= storageModuleCount then
Exit For
end if
Next
'lin component key uuid-> slot number, mm do not care pseudo
'lin call somefuc to get chassisproperties.
'Call SCOMServer.UpdateBladeCenterProperties(ipaddress, bladeModuleCount, ioModuleCount, mmModuleCount, powerModuleCount, blowerModuleCount, powerInstalledString, blowerInstalledString)
Else
Call LogDebugString("Error - GetTopology failed - retval = " & retval, ERROR_LEVEL)
End If
Else
Call LogDebugString("Error - Could not log in to management module", ERROR_LEVEL)
End If
Call bladeChassis.CloseSocketConnection()
End If
End Function
'-----------------------------------------------------------------------------
' End of FindBlades()
'-----------------------------------------------------------------------------
'**
'* Calls CreateVPDData to get the data about the Blade.
'* Creates an instance of this JScript's Blade class with the data.
'**
'-----------------------------------------------------------------------------
' start of CreateChassis()
'-----------------------------------------------------------------------------
Function CreateChassis(chassisModule)
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.BladeCenter.Chassis']$")
Dim NA
NA = "Not available"
Call LogDebugString("Entering CreateChassis" , INFO_LEVEL_FUNCTION)
If (Isnull(chassisModule) or chassisModule is nothing) then
Call LogDebugString("Error - Could not get information for chassisModule" , WARNING_LEVEL)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.Chassis']/ChassisUUID$", NA)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.Chassis']/MachineModelNumber$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.Chassis']/SerialNumber$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.Base']/Description$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.Base']/PartNumber$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.Base']/FRUNumber$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.Base']/FRUSerialNumber$", NA)
Call LogDebugString("Chassis data created", INFO_LEVEL_DETAIL)
End If
Call oDiscoveryData.AddInstance(oInst)
End Function
'-----------------------------------------------------------------------------
' start of CreateBlade()
'-----------------------------------------------------------------------------
Function CreateBlade(bayNumber, blade)
Call LogDebugString("Entering CreateBlade", INFO_LEVEL_FUNCTION)
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.BladeCenter.BladeModule']$")
Dim NA
NA = "Not available"
Dim result
result = -1
If (Isnull(blade) or blade is nothing) then
Call LogDebugString("Error - Could not get information For blade in slot " & bayNumber, WARNING_LEVEL)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.Module']/BayNumber$", "Blade Bay " & blade.Bay & "," & CStr( bayNumber + 1))
'create part two instance
Dim oInst2
Set oInst2 = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.BladeCenter.BladeModule']$")
Call LogDebugString("Error - Could not get information For blade in slot " & bayNumber, WARNING_LEVEL_DEV)
Call oInst2.AddProperty("$MPElement[Name='IBM.BladeCenter.BladeModule']/MachineSerialNumber$", "")
Call oInst2.AddProperty("$MPElement[Name='IBM.BladeCenter.BladeModule']/ModelNumber$", "")
Call oInst2.AddProperty("$MPElement[Name='IBM.BladeCenter.BladeModule']/BladeExpansionCardList$", "")
Call oInst2.AddProperty("$MPElement[Name='IBM.BladeCenter.BladeModule']/Firmware$", "")
Call oInst2.AddProperty("$MPElement[Name='IBM.BladeCenter.BladeModule']/PowerOnState$", "")
Call oInst2.AddProperty("$MPElement[Name='IBM.BladeCenter.Module']/ModuleBay$", ModuleBay(bayNumber,"Blade"))
Call oInst2.AddProperty("$MPElement[Name='IBM.BladeCenter.Module']/BayNumber$", "Blade Bay " + CStr(bayNumber))
Call oInst2.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Blade Bay " + CStr(bayNumber+1) & " - <Part of Blade Bay "& CStr( bayNumber) & "," & CStr( bayNumber + 1) & ">")
WScript.Echo ("blade.ChassisUUID__" + blade.ChassisUUID + "__")
WScript.Echo ("blade.UUID__" + blade.UUID + "__")
Dim IBBladeHostName
if( Len(blade.UUID) <> 39) then
'If the length of UUID is not a valid number. The IB object can not be discovered.
Call LogDebugString("Incorrect Blade UUID:" + blade.UUID , WARNING_LEVEL_DEV)
else
'Austin disabled for MP2.3 #504006
'result = SCOMServer.UpdateIBBladeSystem(ipaddress,blade.UUID )
'IBBladeHostName = SCOMServer.GetRelatedIBBladeName (blade.UUID)
'If IsEmpty(IBBladeHostName) then
result = 1
'else
'Move to Relation .mp
'Call CreateHealthReflectionObject(blade.Description + "-" + ipaddress, IBBladeHostName)
result = 0
'end if
end if
WScript.Echo("BladeFRUSerialNumber " + blade.FRUSerialNumber)
'Call LogDebugString("CreateBlade at Bay :" + blade.Bay + " blade.Description: " + blade.Description, ERROR_LEVEL)
Call LogDebugString("Blade data created", INFO_LEVEL_DETAIL)
End If
Call oDiscoveryData.AddInstance(oInst)
End Function
'-----------------------------------------------------------------------------
' End of CreateBlade()
'-----------------------------------------------------------------------------
'**
'* Uses the vpdDataIF to get the data about the Switch Module.
'* Creates an instance of this JScript's Switch class.
'**
'-----------------------------------------------------------------------------
' start of CreateSwitch()
'-----------------------------------------------------------------------------
Function CreateSwitch(bayNumber, ioModule)
Call LogDebugString("Entering CreateSwitch", INFO_LEVEL_FUNCTION)
Dim NA
NA = "Not available"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.BladeCenter.IOModule']$")
Call LogDebugString("Creating new IO Module in slot " & slot & "...", INFO_LEVEL)
If (Isnull(ioModule) or ioModule is nothing) then
Call LogDebugString("Error - Could not get information For IO Module in slot " & bayNumber, WARNING_LEVEL_DEV)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.IOModule']/Firmware$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.IOModule']/PowerOnState$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.IOModule']/ConfigMethod$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.IOModule']/ConfigIPAddress$", NA)
End If
Call oDiscoveryData.AddInstance(oInst)
End Function
'-----------------------------------------------------------------------------
' End of CreateSwitch()
'-----------------------------------------------------------------------------
'**
'* Uses the vpdDataIF to get data about the Power Module.
'* Creates an instance of this JScript's Power class.
'**
'-----------------------------------------------------------------------------
' Start of CreatePower()
'-----------------------------------------------------------------------------
Function CreatePower(bayNumber, power)
Dim NA
NA = "Not available"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.BladeCenter.PowerModule']$")
Call LogDebugString("Creating new Power Module in slot " & bayNumber & "...", INFO_LEVEL_FUNCTION)
Dim name
name = "Power" & bayNumber
If (Isnull(power) or power is nothing) then
Call LogDebugString("Error - power module is null", ERROR_LEVEL)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.PowerModule']/Firmware$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.PowerModule']/PowerModuleID$", NA)
End Function
'-----------------------------------------------------------------------------
' End of CreatePower()
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
' Start of CreateBlower()
'-----------------------------------------------------------------------------
Function CreateBlower(bayNumber,blower)
Dim NA
NA = "Not available"
Call LogDebugString("Entering CreateBlower", INFO_LEVEL_FUNCTION)
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.BladeCenter.CoolingModule']$")
If (Isnull(blower) or blower is nothing) then
Call LogDebugString("Error - Blower module is null", WARNING_LEVEL_DEV)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.CoolingModule']/Firmware$", NA)
Call oInst.AddProperty("$MPElement[Name='NetworkLibrary!System.NetworkManagement.Node']/DeviceKey$", ipaddress)
Else
Call LogDebugString("Creating new Blower Module in bay " & bayNumber & "...", INFO_LEVEL_DETAIL)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", blower.Name)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.CoolingModule']/Firmware$", blower.Firmware)
end if
Call oDiscoveryData.AddInstance(oInst)
End Function
'-----------------------------------------------------------------------------
' End of CreateBlower()
'-----------------------------------------------------------------------------
'**
'* Uses the vpdDataIF to get the data about the Management Module.
'* Creates an instance of this JScript's Management class.
'**
'-----------------------------------------------------------------------------
' Start of CreateManagement()
'-----------------------------------------------------------------------------
Function CreateManagement(bayNumber, mmMod)
Dim NA
NA = "Not available"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.BladeCenter.ManagementModule']$")
Call LogDebugString("Creating new Management Module in bay " & bayNumber & "...", INFO_LEVEL_DETAIL)
Dim mgmt
mgmt = null
Call LogDebugString("mmMod getting... ", INFO_LEVEL_DETAIL)
Dim name
name = "Management" & bayNumber
If (Isnull(mmMod) or mmMod is nothing) then
Call LogDebugString("Error - management module is null", WARNING_LEVEL_DEV)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.ManagementModule']/Firmware$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.ManagementModule']/ExternalIPAddress$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.ManagementModule']/ExternalIPConfigMethod$", NA)
Call LogDebugString("Management Module created", INFO_LEVEL_DETAIL)
end If
If (bayNumber = 1) then
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.ManagementModule']/EventInsert$", "2629633")
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.ManagementModule']/EventRemove$", "2637825")
else
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.ManagementModule']/EventInsert$", "2629634")
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.ManagementModule']/EventRemove$", "2637826")
End If
Call oDiscoveryData.AddInstance(oInst)
End Function
'-----------------------------------------------------------------------------
' End of CreateManagement()
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
' Start of CreateMedia()
'-----------------------------------------------------------------------------
Function CreateMedia(bayNumber,media)
Dim NA
NA = "Not available"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.BladeCenter.MediaModule']$")
Call LogDebugString("Creating new Media Module in slot " & bayNumber & "...", INFO_LEVEL_DETAIL)
Dim name
name = "Media" & bayNumber
If (Isnull(media) or media is nothing) then
Call LogDebugString("Error - media module is null", WARNING_LEVEL_DEV)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.MediaModule']/EventInsert$", "111157249")
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.MediaModule']/EventRemove$", "111271937")
else
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.MediaModule']/EventInsert$", "111157250")
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.MediaModule']/EventRemove$", "111271938")
End If
Call oDiscoveryData.AddInstance(oInst)
End Function
'-----------------------------------------------------------------------------
' End of CreateMedia()
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
' Start of CreateStorage()
'-----------------------------------------------------------------------------
Function CreateStorage(bayNumber,storage)
Dim NA
NA = "Not available"
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.BladeCenter.StorageModule']$")
Call LogDebugString("Creating new Storage Module in slot " & bayNumber & "...", INFO_LEVEL_DETAIL)
Dim Name
name = "Storage" & bayNumber
If (Isnull(storage) or storage is nothing) then
Call LogDebugString("Error - storage module is null", WARNING_LEVEL_DEV)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", NA)
Call oInst.AddProperty("$MPElement[Name='IBM.BladeCenter.StorageModule']/Firmware$", NA)
'diskDrives = storage.StorageDiskList
Dim slotNumber, diskCount
diskCount = storage.StorageDiskCount
WSCript.echo diskCount
If diskCount > 0 Then
For slotNumber = 1 to diskCount
Dim diskDrive
Set diskDrive = storage.GetStorageDisk(slotNumber)
If diskDrive is nothing then
Call CreatePseudo(bayNumber,"DiskDrive",storage.ChassisUUID,slotNumber)
else
Call CreateStorageDisk(slotNumber,diskDrive)
End if
Next
End if
End If
End Function
'-----------------------------------------------------------------------------
' End of CreateStorage()
'-----------------------------------------------------------------------------
Function CreateStorageDisk(slotNumber,diskDrive)
Dim oDiskInst
If Not IsNull(diskDrive) Then
Call LogDebugString("Creating new Storage Disk Drive Module in slot " & slotNumber & "...", INFO_LEVEL_DETAIL)
Set oDiskInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='IBM.BladeCenter.StorageDiskDriveModule']$")
End Function
'-----------------------------------------------------------------------------
' End of CreatePseudo()
'-----------------------------------------------------------------------------
Function ModuleBay(bayNumber,typee)
ModuleBay = "Not available"
If( bayNumber >=100 ) Then
Call LogDebugString("Error Bay Number for " + typee + " Module", WARNING_LEVEL)
Exit Function
End If
Select Case typee
case "Blade"
ModuleBay = "Blade_"
case "IO"
ModuleBay = "IOMod_"
case "MM"
ModuleBay = "MM_"
case "Power"
ModuleBay = "Power_"
case "Blower"
ModuleBay = "Cool_"
case "Media"
ModuleBay = "Media_"
case "Storage"
ModuleBay = "Stor_"
'case "DiskDrive"
End Select
If ModuleBay = "Not available" Then
Exit Function
End If
If(bayNumber <10) Then
ModuleBay = ModuleBay +"0" + CStr(bayNumber)
Else
ModuleBay = ModuleBay + CStr(bayNumber)
End If
End Function
'**
'* Creates a string to represent the installed state. For example:
'* there are 4 power modules maximum - two installed. One installed
'* in slot 0, one in slot 2. This routine should return:
'* "true, false, true, false". *
'**
'-----------------------------------------------------------------------------
' Start of InstalledString()
'-----------------------------------------------------------------------------
Function InstalledString(count, installed)
Call LogDebugString("Creating installed string", INFO_LEVEL_FUNCTION)
Dim installString
installString = ""
Dim i
i = 0
For each item in installed
If (item = true) then
installString = installString & "true"
Else
installString = installString & "false"
End If
If (i < count-1) then
installString = installString & ","
End If
i = i + 1
Next
InstalledString = installString
End Function
'-----------------------------------------------------------------------------
'End of Main()
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
'start of IsInstallBCCProject()
'This Function judges whether the target machine installed or not
'IBM Assemblies For Systems Management Support.
'-----------------------------------------------------------------------------
Function IsInstallBCCProject()
Dim IsInstalled
IsInstalled = true
Dim obj
Set obj = WScript.CreateObject("WScript.Shell")
Dim regpath
regpath = "HKEY_LOCAL_MACHINE\SOFTWARE\Lenovo\Systems Management Integrations\Lenovo HW Mgmt Pack for OpsMgr\Path"
Dim InstallPath
InstallPath = obj.RegRead(regpath)
If isNull(InstallPath) then
regpath = "HKEY_LOCAL_MACHINE\SOFTWARE\IBM\Systems Management Integrations\IBM HW Mgmt Pack for OpsMgr\Path"
InstallPath = obj.RegRead(regpath)
End If
If not isNull(InstallPath) then
IsInstalled = true
Else
WScript.Echo("!!!!!!!!!!Error: BCC Not Installed!!!!!!!!!!!!")
End If
IsInstallBCCProject = IsInstalled
'WScript.Echo(IsInstalled)
End Function
'-------------------------------------------------------------------------------
'end of IsInstallBCCProject()
'-------------------------------------------------------------------------------
Sub GetDebugLevel()
' Const HKEY_LOCAL_MACHINE = &H80000002
' Const DEBUG_INFO_KEY = "SOFTWARE\Lenovo\Lenovo SCOM MP\Debug"
' Const DEBUG_LEVEL_NAME = "Level"
Dim oReg,RC_Code
' 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
End Sub
'-------------------------------------------------------------------------------
'start of LogDebugString()
'-------------------------------------------------------------------------------
Sub LogDebugString(debugString, debugLevel)
If (Int(Regdebug) >= Int(debugLevel)) Then
Call oAPI.LogScriptEvent("IBMBladeCenterModuleDiscovery.vbs", 201, 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
'-------------------------------------------------------------------------------
'start of SCOMCreateObject()
'-------------------------------------------------------------------------------
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
'-------------------------------------------------------------------------------
'end of SCOMCreateObject()
'-------------------------------------------------------------------------------
Function Chr2Unicode(byval str)
Dim st, t, i
For i = 1 To Len(str) Step 2
t = Mid(str, i, 1)
st = st + t
Next
Chr2Unicode = st
End Function
Function fDecode(sStringToDecode)
'This function will decode a Base64 encoded string and returns the decoded string.
Const CharList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim iDataLength, sOutputString, iGroupInitialCharacter
sStringToDecode = Replace(Replace(Replace(sStringToDecode, vbCrLf, ""), vbTab, ""), " ", "")
iDataLength = Len(sStringToDecode)
If iDataLength Mod 4 <> 0 Then
fDecode = "Bad string passed to fDecode() function."
Exit Function
End If
For iGroupInitialCharacter = 1 To iDataLength Step 4
Dim iDataByteCount, iCharacterCounter, sCharacter, iData, iGroup, sPreliminaryOutString
iDataByteCount = 3
iGroup = 0
For iCharacterCounter = 0 To 3
sCharacter = Mid(sStringToDecode, iGroupInitialCharacter + iCharacterCounter, 1)
If sCharacter = "=" Then
iDataByteCount = iDataByteCount - 1
iData = 0
Else
iData = InStr(1, CharList, sCharacter, 0) - 1
If iData = -1 Then
fDecode = "Bad string passed to fDecode() function."
Exit Function
End If
End If
iGroup = 64 * iGroup + iData
Next
iGroup = Hex(iGroup)
iGroup = String(6 - Len(iGroup), "0") & iGroup
sPreliminaryOutString = Chr(CByte("&H" & Mid(iGroup, 1, 2))) & Chr(CByte("&H" & Mid(iGroup, 3, 2))) & Chr(CByte("&H" & Mid(iGroup, 5, 2)))
sOutputString = sOutputString & Left(sPreliminaryOutString, iDataByteCount)
Next
fDecode = sOutputString
End Function
Function ConvertUUID(uuid)
Dim temp, UUID2
temp = UCase(uuid)
For i = 1 To 8
UUID2 = UUID2 + Mid(temp,1+(i-1)*4 ,4) + " "
ConvertUUID = Trim(UUID2)
Next
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>