Dim moduleCount
Dim moduleInstalled
If (init = 0) then
Dim chassisUUID
Dim module, ret, blademodule
ret = bladeChassis.GetComponentSupportedAndInstalled()
If (ret <> 0) then
Call LogDebugString("Refresh a Blade Module in bay " & bayNumber & " at GetComponentSupportedAndInstalled() error", WARNING_LEVEL_DEV)
Else
chassisUUID = bladeChassis.RefreshChassisInfo().UUID
Select Case ModuleType
'case CHASSIS_TYPE
Call LogDebugString("Refresh a Blade Module in bay " & bayNumber, INFO_LEVEL_DETAIL)
moduleInstalled = bladeChassis.GetBladeModulesInstalled()
if moduleInstalled(CInt(bayNumber)-1) = true then
Call RefreshBlade( bayNumber,bladeChassis.RefreshBladeModuleInfo(CInt(bayNumber)) )
else
if bayNumber> 1 then
if moduleInstalled(CInt(bayNumber)-1-1) = true then ' whether doubleWidth blade
set blademodule = bladeChassis.RefreshBladeModuleInfo(CInt(bayNumber-1))
if blademodule.SlotWidth>1 then' yes doublewidth
Call RefreshPseudo(bayNumber,"Blade",chassisUUID ,0,ModuleBay(bayNumber,"Blade"),modBay,1)
'also create a doublewidth blade for baynumber-1
Call RefreshBlade( CInt(bayNumber-1),blademodule )
else
'do nothing
end if
end if
end if
Call RefreshPseudo(bayNumber,"Blade",chassisUUID ,0,ModuleBay(bayNumber,"Blade"),modBay,0)
end if
case COOLING_TYPE
Call LogDebugString("Refresh a Cooling Module in bay " & bayNumber, INFO_LEVEL_DETAIL)
moduleInstalled = bladeChassis.GetBlowerModulesInstalled()
if moduleInstalled(CInt(bayNumber)-1) = true then
Call RefreshBlower(bayNumber,bladeChassis.RefreshBlowerModuleInfo(CInt(bayNumber)))
else
Call RefreshPseudo(bayNumber,"Blower",chassisUUID,0,ModuleBay(bayNumber,"Blower"),modBay,0)
End if
case IO_TYPE
Call LogDebugString("Refresh a Switch in bay " & bayNumber, INFO_LEVEL)
moduleInstalled = bladeChassis.GetIOModulesInstalled()
if moduleInstalled(CInt(bayNumber)-1) = true then
Set module = bladeChassis.RefreshIOModuleInfo(CInt(bayNumber))
Call RefreshSwitch(bayNumber,module)
else
Call RefreshPseudo(bayNumber,"IO",chassisUUID,0,ModuleBay(bayNumber,"IO"),modBay,0)
end if
case MM_TYPE
Call LogDebugString("Refresh a Management Module in bay " & bayNumber, INFO_LEVEL_DETAIL)
moduleInstalled = bladeChassis.GetManagementModulesInstalled()
if moduleInstalled(CInt(bayNumber)-1) = true then
Call RefreshManagement( bayNumber,bladeChassis.RefreshMMInfo(CInt(bayNumber)))
else
Call RefreshPseudo(bayNumber,"MM",chassisUUID,0,ModuleBay(bayNumber,"MM"),modBay,0)
end if
case POWER_TYPE
Call LogDebugString("Refresh a Power Module in bay " & bayNumber, INFO_LEVEL_DETAIL)
moduleInstalled = bladeChassis.GetPowerModulesInstalled()
if moduleInstalled(CInt(bayNumber)-1) = true then
Call RefreshPower( bayNumber, bladeChassis.RefreshPowerModuleInfo(CInt(bayNumber)))
else
Call RefreshPseudo(bayNumber,"Power",chassisUUID,0,ModuleBay(bayNumber,"Power"),modBay,0)
end if
case STORAGE_TYPE
Call LogDebugString("Refresh a Storage Module in bay " & bayNumber, INFO_LEVEL_DETAIL)
bladeChassis.RefreshStorageModuleInfo(CInt(bayNumber))
moduleInstalled = bladeChassis.GetStorageModulesInstalled()
if moduleInstalled(CInt(bayNumber)-1) = true then
Call RefreshStorage(bayNumber,bladeChassis.RefreshStorageModuleInfo(CInt(bayNumber)))
else
Call RefreshPseudo(bayNumber,"Storage",chassisUUID,0,ModuleBay(bayNumber,"Storage"),modBay,0)
end if
case FANMUX_TYPE
Call LogDebugString("Refresh a FanMux Module in bay " & bayNumber, INFO_LEVEL_DETAIL)
moduleInstalled = bladeChassis.GetFanMuxModulesInstalled()
if moduleInstalled(CInt(bayNumber)-1) = true then
Call RefreshFanMux( bayNumber, bladeChassis.RefreshFanMuxModuleInfo(CInt(bayNumber)))
else
Call RefreshPseudo(bayNumber,"FanMux",chassisUUID,0,ModuleBay(bayNumber,"FanMux"),modBay,0)
end if
case REARLED_TYPE
Call LogDebugString("Refresh a RearLED Module in bay " & bayNumber, INFO_LEVEL_DETAIL)
moduleInstalled = bladeChassis.GetRearLEDModulesInstalled()
if moduleInstalled(CInt(bayNumber)-1) = true then
Call RefreshRearLED( bayNumber, bladeChassis.RefreshRearLEDModuleInfo(CInt(bayNumber)))
else
Call RefreshPseudo(bayNumber,"RearLED",chassisUUID,0,ModuleBay(bayNumber,"RearLED"),modBay,0)
end if
End Select
End if 'ret
Call bladeChassis.CloseSocketConnection()
end if 'init
End If ' ipaddress
'For OM12, could not use commit but should be overwrite() to refresh the discovered data.
'Call SCOMServer.CommitDiscoveryData(0)
Call SCOMServer.OverwriteDiscoveryData(0)
WSCript.Echo("Try to refresh " + ModuleType + CStr(bayNumber) + " on " + IPAddress)
'-----------------------------------------------------------------------------
' start of RefreshChassis()
'-----------------------------------------------------------------------------
Function RefreshChassis(chassisModule)
If (Isnull(chassisModule) or chassisModule is nothing) then
Call LogDebugString("Error - Could not get information For chassisModule" , WARNING_LEVEL)
Else
Call LogDebugString("Refresh chassisModule " & "...", INFO_LEVEL_DETAIL)
Dim chassisID
chassisID = SCOMServer.AddFlexSystemChassisToSCOM(ipaddress,_
chassisModule.Name,_
chassisModule.Description,_
chassisModule.PartNumber,_
chassisModule.FRUNumber,_
chassisModule.FRUSerialNumber,_
chassisModule.UUID,_
chassisModule.MachineTypeModel,_
chassisModule.SerialNumber)
Call LogDebugString("Chassis data Refreshed", INFO_LEVEL_DETAIL)
End If
End Function
Function RefreshBlade(bayNumber, blade)
Dim bladeID
Dim NA
NA = "Not Available"
If (Isnull(blade) or blade is nothing) then
Call LogDebugString("Error - Could not get information For blade in slot " & bayNumber, WARNING_LEVEL)
bladeID = SCOMServer.AddBladeToCMMCenter(ipaddress,_
NA,_
NA,_
NA,_
NA,_
NA,_
modBay,_
NA,_
NA,_
NA,_
NA,_
NA, ModuleBay(blade.Bay,"Blade"),EncodeCmtyStr)
Else
Call LogDebugString("Refreshing new Blade in slot " & blade.Bay & "...", INFO_LEVEL_DETAIL)
Call LogDebugString("Blade data Refreshed", INFO_LEVEL_DETAIL)
End If
End Function
'-----------------------------------------------------------------------------
' End of RefreshBlade()
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
' Start of RefreshFSM() 'deleted
'-----------------------------------------------------------------------------
'**
'* Uses the vpdDataIF to get the data about the Switch Module.
'* Refreshs an instance of this JScript's Switch class.
'**
'-----------------------------------------------------------------------------
' start of RefreshSwitch()
'-----------------------------------------------------------------------------
Function RefreshSwitch(bayNumber, ioModule)
Dim SwithID
Dim NA
NA = "Not Available"
Call LogDebugString("Refreshing new IO Module in slot " & slot & "...", INFO_LEVEL_DETAIL)
If (Isnull(ioModule) or ioModule is nothing) then
Call LogDebugString("IO Module Refreshed", INFO_LEVEL_DETAIL)
End If
End Function
'-----------------------------------------------------------------------------
' End of RefreshSwitch()
'-----------------------------------------------------------------------------
'**
'* Uses the vpdDataIF to get data about the Power Module.
'* Refreshs an instance of this JScript's Power class.
'**
'-----------------------------------------------------------------------------
' Start of RefreshPower()
'-----------------------------------------------------------------------------
Function RefreshPower(bayNumber, power)
Dim PowerID
Dim NA
NA = "Not Available"
Call LogDebugString("Refreshing new Power Module in slot " & bayNumber & "...", INFO_LEVEL_DETAIL)
Dim name
name = "Power" & bayNumber
If (Isnull(power) or power is nothing) then
PowerID = SCOMServer.AddPowerToCMMCenter(ipaddress,_
NA,_
NA,_
NA,_
NA,_
NA,_
modBay,_
NA,_
NA,_
NA,_
NA,_
ModuleBay(power.Bay,"Power"),EncodeCmtyStr)
Call LogDebugString("Error - power module is null", WARNING_LEVEL_DEV)
Else
Call LogDebugString("Power Module name = " & name, INFO_LEVEL_DETAIL)
End Function
'-----------------------------------------------------------------------------
' End of RefreshPower()
'-----------------------------------------------------------------------------
Function RefreshFanMux(bayNumber, FanMux)
Dim NA
NA = "Not Available"
Call LogDebugString("Refreshing new FanMux Module in slot " & bayNumber & "...", INFO_LEVEL_DETAIL)
Dim name
name = "FanMux" & bayNumber
Function RefreshRearLED(bayNumber, RearLED)
Dim RearLEDID
Dim NA
NA = "Not Available"
Call LogDebugString("Refreshing new RearLED Module in slot " & bayNumber & "...", INFO_LEVEL_DETAIL)
Dim name
name = "RearLED" & bayNumber
'-----------------------------------------------------------------------------
' Start of RefreshBlower()
'-----------------------------------------------------------------------------
Function RefreshBlower(bayNumber,blower)
Dim NA
NA = "Not Available"
If (Isnull(blower) or blower is nothing) then
Call SCOMServer.AddBlowerToCMMCenter(ipaddress,_
NA,_
NA,_
NA,_
NA,_
NA,_
modBay,_
NA,_
NA,_
NA,_
ModuleBay(blower.Bay,"Blower"),EncodeCmtyStr)
Call LogDebugString("Error - Blower module is null", WARNING_LEVEL_DEV)
Else
Call LogDebugString("Refreshing new Blower Module in bay " & bayNumber & "...", INFO_LEVEL_DETAIL)
Call SCOMServer.AddBlowerToCMMCenter(ipaddress,_
blower.Name,_
blower.Description,_
blower.PartNumber,_
blower.FRUNumber,_
blower.FRUSerialNumber,_
modBay,_
blower.ChassisUUID,_
blower.UUID,_
blower.Firmware,_
ModuleBay(blower.Bay,"Blower"),EncodeCmtyStr)
end if
End Function
'-----------------------------------------------------------------------------
' End of RefreshBlower()
'-----------------------------------------------------------------------------
'**
'* Uses the vpdDataIF to get the data about the Management Module.
'* Refreshs an instance of this JScript's Management class.
'**
'-----------------------------------------------------------------------------
' Start of RefreshManagement()
'-----------------------------------------------------------------------------
Function RefreshManagement(bayNumber, mmMod)
Call LogDebugString("Refreshing new Management Module in bay " & bayNumber & "...", INFO_LEVEL_DETAIL)
Dim MMID
Dim NA
NA = "Not Available"
Dim mgmt
mgmt = null
Call LogDebugString("mmMod getting... ", INFO_LEVEL_DETAIL)
RefreshManagement = mgmt
End Function
'-----------------------------------------------------------------------------
' End of RefreshManagement()
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
' Start of RefreshMedia()
'-----------------------------------------------------------------------------
Function RefreshMedia(bayNumber,media)
Call LogDebugString("Refreshing new Media Module in slot " & bayNumber & "...", INFO_LEVEL_DETAIL)
Dim name
name = "Media" & bayNumber
Dim MediaID
Dim NA
NA = "Not Available"
If (Isnull(media) or media is nothing) then
MediaID = SCOMServer.AddMediaToCMMCenter(ipaddress,_
NA,_
NA,_
NA,_
NA,_
NA,_
modBay,_
NA,_
NA,_
ModuleBay(media.Bay,"Media"),EncodeCmtyStr)
Call LogDebugString("Error - media module is null", WARNING_LEVEL_DEV)
Else
Call LogDebugString("Media Module name = " & name, INFO_LEVEL_DETAIL)
MediaID = SCOMServer.AddMediaToCMMCenter(ipaddress,_
media.Name,_
media.Description,_
media.PartNumber,_
media.FRUNumber,_
media.FRUSerialNumber,_
modBay,_
media.ChassisUUID,_
media.UUID,_
ModuleBay(media.Bay,"Media"),EncodeCmtyStr)
Call LogDebugString("Media Module refreshed", INFO_LEVEL_DETAIL)
End If
End Function
'-----------------------------------------------------------------------------
' End of RefreshMedia()
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
' Start of RefreshStorage()
'-----------------------------------------------------------------------------
Function RefreshStorage(bayNumber,storage)
Call LogDebugString("Refreshing new Storage Module in slot " & bayNumber & "...", INFO_LEVEL_DETAIL)
Dim StorageID
Dim NA
NA = "Not Available"
Dim name
name = "Storage" & bayNumber
If (Isnull(storage) or storage is nothing) then
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 RefreshPseudo(bayNumber,"DiskDrive",storage.UUID,slotNumber,ModuleBay(storage.Bay,"Storage"),modBay,0)
Else
Call RefreshStorageDisk(slotNumber,diskDrive)
end if
Next
End if
End If
End Function
'-----------------------------------------------------------------------------
' End of RefreshStorage()
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
' Start of CreateDiskDrive()
'-----------------------------------------------------------------------------
Function RefreshStorageDisk(bayNumber,diskDrive)
Call LogDebugString("Refreshing new DiskDrive Module in slot " & bayNumber & "...", INFO_LEVEL_DETAIL)
Dim name
name = "DiskDrive" & bayNumber
If (Isnull(diskDrive) or diskDrive is nothing) then
Call LogDebugString("Error - storage module is null", DETAIL_LEVEL)
Else
Call LogDebugString("DiskDrive Module name = " & name, INFO_LEVEL_DETAIL)
Dim DiskDriveID
DiskDriveID = SCOMServer.AddDiskDriveToCMMStorage(ipaddress,_
diskDrive.Name,_
diskDrive.Slot,_
"Storage Module Bay " + CStr(diskDrive.StorageParentBay),_
diskDrive.ChassisUUID,_
diskDrive.StorageUUID,_
ModuleBay(diskDrive.StorageParentBay,"Storage"))
end if
End Function
'-----------------------------------------------------------------------------
' End of CreateDiskDrive()
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
' Start of RefreshPseudo
'-----------------------------------------------------------------------------
Function RefreshPseudo(bayNumber,typee,storageUUID,slotNumber,moduleBay,BayName, partTwo)
Call LogDebugString("Refreshing Pseudo Module in slot " & bayNumber & "...", INFO_LEVEL_DETAIL)
'public string AddPseudoToCenter(string IPAddress, string BayNumber, string typee, string StorageUUID, string SlotNumber, string moduleBay, string bayName)
Call SCOMServer.AddPseudoToCMMCenter(ipaddress, bayNumber,typee,"","0",moduleBay,BayName,EncodeCmtyStr,partTwo)
End Function
'-----------------------------------------------------------------------------
' End of RefreshPseudo()
'-----------------------------------------------------------------------------
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 "FSM"
ModuleBay="FSM_"
case "Blade"
ModuleBay = "Node_"
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
Function GetModuleBayNumber(tempModBay)
Dim n
n = InStr(1,tempModBay," Bay ",1)
If n > 0 then
GetModuleBayNumber = Right(tempModBay, Len(tempModBay) - n - 4)
n = InStr(1,GetModuleBayNumber,",",1)
if n > 0 then
GetModuleBayNumber = Left(GetModuleBayNumber, Len(GetModuleBayNumber) -n)
end if
Else
GetModuleBayNumber = 0
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_DETAIL)
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()
Dim oReg, RC_Code
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("IBMFlexChassisRefreshModule.vbs", 233, 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
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