Lenovo BladeCenter Refresh Module

IBM.BladeCenter.Refresh.Module (WriteActionModuleType)

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.CommandOutput

Member Modules:

ID Module Type TypeId RunAs 
WA WriteAction Microsoft.Windows.ScriptWriteAction Default

Source Code:

<WriteActionModuleType ID="IBM.BladeCenter.Refresh.Module" Accessibility="Internal">
<Configuration>
<xsd:element name="ModuleType" type="xsd:string"/>
<xsd:element name="IPAddress" type="xsd:string"/>
<xsd:element name="BayNumber" type="xsd:string"/>
<xsd:element name="CommunityString" type="xsd:string"/>
</Configuration>
<ModuleImplementation>
<Composite>
<MemberModules>
<WriteAction ID="WA" TypeID="Windows!Microsoft.Windows.ScriptWriteAction">
<ScriptName>IBMBladeCenterRefreshModule.vbs</ScriptName>
<Arguments>"$Config/ModuleType$" "$Config/IPAddress$" "$Config/BayNumber$" "$Config/CommunityString$"</Arguments>
<ScriptBody><Script>
'----------------------------------------------------------------------------
'The constant should be equal to the input parameter of each refresh task on
'module.
'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 CHASSIS_TYPE = "CHASSIS"
Const BLADE_TYPE = "BLADE"
Const COOLING_TYPE = "COOLING"
Const IO_TYPE = "IO"
Const MEDIA_TYPE = "MEDIA"
Const MM_TYPE = "MM"
Const POWER_TYPE = "POWER"
Const STORAGE_TYPE = "STORAGE"
'-----------------------------------------------------------------------------
Dim SCOMServer, IPAddress, ModuleType, bayNumber,modBay
Dim SourceID, ManagedEntityId
Dim oAPI, oDiscoveryData, oInst, oRelCon, oBCInst,Regdebug, CommunityString, EncodeCmtyStr
Regdebug= "-1"
Dim bladeChassis
SetLocale("en-us")
SCOMServer = null
If (WScript.Arguments.Count &lt; 4) Then
WScript.Quit -1
End If
ModuleType = WScript.Arguments.Item(0)
IPAddress = WScript.Arguments.Item(1)
modBay = WScript.Arguments.Item(2)
'bayNumber = WScript.Arguments.Item(2)
bayNumber = GetModuleBayNumber(modBay)
EncodeCmtyStr = WScript.Arguments.Item(3)
CommunityString = Chr2Unicode(fDecode(EncodeCmtyStr))

Set oAPI = CreateObject("MOM.ScriptAPI")
Call GetDebugLevel()

WScript.Echo("ModuleType = " + ModuleType)
WScript.Echo("IPAddress = "+ IPAddress)
WScript.Echo("bayNumber = " &amp; bayNumber)
WScript.Echo("CommunityString = "+ EncodeCmtyStr)

Call LogDebugString("ModuleType = " + ModuleType + vbCrlf + _
" IPAddress = "+ IPAddress+ vbCrlf + _
"bayNumber = " &amp; bayNumber + vbCrlf + _
"CommunityString = "+ EncodeCmtyStr, INFO_LEVEL_DETAIL)

Set SCOMServer = WScript.CreateObject("IBM.SystemsManagement.SCOMHelper.SCOMServer")

Call SCOMServer.InitSCOMServerConnection()
Call SCOMServer.InitDiscoveryData()
'-------------------------------------

bccInstalled = IsInstallBCCProject()
If (Isnull(IPAddress)) then
Call LogDebugString("Error: Bad or missing ipaddress!", ERROR_LEVEL)
Else

Set bladeChassis = WScript.CreateObject("Lenovo.SystemsManagement.MMClassLibrary.BladeChassis")

Call LogDebugString("Lenovo BladeCenter Component Refleash Starting.", INFO_LEVEL_DETAIL)

Dim init
init = -1
init = bladeChassis.InitializeSocketConnection(IPAddress, CommunityString, 0,"V1")

Dim moduleCount
Dim moduleInstalled
If (init = 0) then

Dim chassisUUID

Dim module, ret, blademodule
ret = bladeChassis.GetComponentSupportedAndInstalled()
If (ret &lt;&gt; 0) then
Call LogDebugString("Refresh a Blade Module in bay " &amp; bayNumber &amp; " at GetComponentSupportedAndInstalled() error", WARNING_LEVEL_DEV)
Else
chassisUUID = bladeChassis.RefreshChassisInfo().UUID
Select Case ModuleType
case CHASSIS_TYPE

Call RefreshChassis(bladeChassis.RefreshChassisInfo())

case BLADE_TYPE

Call LogDebugString("Refresh a Blade Module in bay " &amp; bayNumber, INFO_LEVEL_DETAIL)

moduleInstalled = bladeChassis.GetBladeModulesInstalled()
if moduleInstalled(CInt(bayNumber)-1) = true then
Call RefreshBlade( bayNumber,bladeChassis.RefreshBladeModuleInfo(CInt(bayNumber)) )
else
if bayNumber&gt; 1 then
if moduleInstalled(CInt(bayNumber)-1-1) = true then ' whether doubleWidth blade
set blademodule = bladeChassis.RefreshBladeModuleInfo(CInt(bayNumber-1))
if blademodule.SlotWidth&gt;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 " &amp; 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 " &amp; 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 MEDIA_TYPE

Call LogDebugString("Refresh a Media Module in bay " &amp; bayNumber, INFO_LEVEL)

moduleInstalled = bladeChassis.GetMediaModulesInstalled()
if moduleInstalled(CInt(bayNumber)-1) = true then
Call RefreshMedia(bayNumber,bladeChassis.RefreshMediaModuleInfo(CInt(bayNumber)))
else
Call RefreshPseudo(bayNumber,"Media",chassisUUID,0,ModuleBay(bayNumber,"Media"),modBay,0)
end if
case MM_TYPE

Call LogDebugString("Refresh a Management Module in bay " &amp; 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 " &amp; 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 " &amp; 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
End Select

End if 'ret
Call bladeChassis.CloseSocketConnection()
end if 'init

WScript.Echo("-----------------------------------------")
WScript.Echo(" Finish Components Discovery")
Call LogDebugString("Successful!" + vbcrlf +"Lenovo BladeCenter Component Discovery Running Successfully.", INFO_LEVEL_DETAIL)

End If ' ipaddress

Call SCOMServer.CommitDiscoveryData(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 " &amp; "...", INFO_LEVEL_DETAIL)
Dim chassisID
chassisID = SCOMServer.AddChassisToCenter(ipaddress,_
chassisModule.Name,_
chassisModule.Description,_
chassisModule.PartNumber,_
chassisModule.FRUNumber,_
chassisModule.FRUSerialNumber,_
chassisModule.UUID,_
chassisModule.MachineTypeModel,_
chassisModule.MachineSerialNumber,chassisModule.MachineType &amp; "-" &amp; chassisModule.MachineSerialNumber, chassisModule.ModelNumber)
' Call SCOMServer.UpdateChassisToBladeCenter(ipaddress,_
' chassisModule.Name,_
' chassisModule.Description,_
' chassisModule.PartNumber,_
' chassisModule.FRUNumber,_
' chassisModule.FRUSerialNumber,_
' chassisModule.UUID,_
' chassisModule.MachineType &amp; "-" &amp; chassisModule.MachineSerialNumber,_
' chassisModule.ModelNumber)

' WSCript.echo("SCOMServer.UpdateChassisToBladeCenter chassisModule.UUID:__" +chassisModule.UUID+ "__")

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 " &amp; bayNumber, WARNING_LEVEL)
bladeID = SCOMServer.AddBladeToCenter(ipaddress,_
NA,_
NA,_
NA,_
NA,_
NA,_
modBay,_
NA,_
NA,_
NA,_
NA,_
NA,_
NA,_
NA, ModuleBay(blade.Bay,"Blade"),EncodeCmtyStr)
Else
Call LogDebugString("Refreshing new Blade in slot " &amp; blade.Bay &amp; "...", INFO_LEVEL_DETAIL)

bladeID = SCOMServer.AddBladeToCenter(ipaddress,_
blade.Name,_
blade.Description,_
blade.PartNumber,_
blade.FRUNumber,_
blade.FRUSerialNumber,_
modBay,_
blade.ChassisUUID,_
blade.UUID,_
blade.MachineMTAndSN,_
blade.ModelNumber,_
blade.BladeExpansionCardList,_
blade.Firmwares,_
blade.PowerState, ModuleBay(blade.Bay,"Blade"),EncodeCmtyStr)

Call LogDebugString("Blade data Refreshed", INFO_LEVEL_DETAIL)
End If
End Function

'-----------------------------------------------------------------------------
' End of RefreshBlade()
'-----------------------------------------------------------------------------
'**
'* 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 " &amp; slot &amp; "...", INFO_LEVEL_DETAIL)
If (Isnull(ioModule) or ioModule is nothing) then

SwithID = SCOMServer.AddIOToCenter(ipaddress,_
NA,_
NA,_
NA,_
NA,_
NA,_
modBay,_
NA,_
NA,_
NA,_
NA,_
NA,_
NA,_
ModuleBay(ioModule.Bay,"IO"),EncodeCmtyStr)

Call LogDebugString("Error - Could not get information For IO Module in slot " &amp; bayNumber, WARNING_LEVEL)
Else

SwithID = SCOMServer.AddIOToCenter(ipaddress,_
ioModule.Name,_
ioModule.Description,_
ioModule.PartNumber,_
ioModule.FRUNumber,_
ioModule.FRUSerialNumber,_
modBay,_
ioModule.ChassisUUID,_
ioModule.UUID,_
ioModule.Firmwares,_
ioModule.PowerState,_
ioModule.Configuration,_
ioModule.IPAddress,_
ModuleBay(ioModule.Bay,"IO"),EncodeCmtyStr)



WScript.Echo ("ioModule.UUID__" + ioModule.UUID + "__")
WScript.Echo ("ioModule.ChassisUUID__" + ioModule.ChassisUUID + "__")

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 " &amp; bayNumber &amp; "...", INFO_LEVEL_DETAIL)
Dim name
name = "Power" &amp; bayNumber

If (Isnull(power) or power is nothing) then

PowerID = SCOMServer.AddPowerToCenter(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)
Else
Call LogDebugString("Power Module name = " &amp; name, INFO_LEVEL_DETAIL)

PowerID = SCOMServer.AddPowerToCenter(ipaddress,_
power.Name,_
power.Description,_
power.PartNumber,_
power.FRUNumber,_
power.FRUSerialNumber,_
modBay,_
power.ChassisUUID,_
power.UUID,_
power.Firmware,_
power.ModuleID, _
ModuleBay(power.Bay,"Power"),EncodeCmtyStr)

End If

End Function
'-----------------------------------------------------------------------------
' End of RefreshPower()
'-----------------------------------------------------------------------------

'-----------------------------------------------------------------------------
' Start of RefreshBlower()
'-----------------------------------------------------------------------------
Function RefreshBlower(bayNumber,blower)
Dim NA
NA = "Not available"
If (Isnull(blower) or blower is nothing) then

Call SCOMServer.AddBlowerToCenter(ipaddress,_
NA,_
NA,_
NA,_
NA,_
NA,_
modBay,_
NA,_
NA,_
NA,_
ModuleBay(blower.Bay,"Blower"),EncodeCmtyStr)
Call LogDebugString("Error - Blower module is null", WARNING_LEVEL)
Else
Call LogDebugString("Refreshing new Blower Module in bay " &amp; bayNumber &amp; "...", INFO_LEVEL_DETAIL)
Call SCOMServer.AddBlowerToCenter(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 " &amp; bayNumber &amp; "...", INFO_LEVEL_DETAIL)
Dim MMID
Dim NA
NA = "Not available"
Dim mgmt
mgmt = null
Call LogDebugString("mmMod getting... ", INFO_LEVEL_DETAIL)

Dim name
name = "Management" &amp; bayNumber

If (Isnull(mmMod) or mmMod is nothing) then

MMID = SCOMServer.AddMMToCenter(ipaddress,_
NA,_
NA,_
NA,_
NA,_
NA,_
modBay,_
NA,_
NA,_
NA,_
NA,_
NA,_
ModuleBay(mmMod.Bay,"MM"),EncodeCmtyStr)
Call LogDebugString("Error - management module is null", WARNING_LEVEL)
Else
Call LogDebugString("Media Module name= " &amp; name, INFO_LEVEL_DETAIL)

MMID = SCOMServer.AddMMToCenter(ipaddress,_
mmMod.Name,_
mmMod.Description,_
mmMod.PartNumber,_
mmMod.FRUNumber,_
mmMod.FRUSerialNumber,_
modBay,_
mmMod.ChassisUUID,_
mmMod.UUID,_
mmMod.IPAddress,_
mmMod.Firmware,_
IPConfigMethod,_
ModuleBay(mmMod.Bay,"MM"),EncodeCmtyStr)
Call LogDebugString("Management Module refreshed", INFO_LEVEL_DETAIL)
end If

RefreshManagement = mgmt
End Function
'-----------------------------------------------------------------------------
' End of RefreshManagement()
'-----------------------------------------------------------------------------
'-----------------------------------------------------------------------------
' Start of RefreshMedia()
'-----------------------------------------------------------------------------
Function RefreshMedia(bayNumber,media)
Call LogDebugString("Refreshing new Media Module in slot " &amp; bayNumber &amp; "...", INFO_LEVEL_DETAIL)
Dim name
name = "Media" &amp; bayNumber
Dim MediaID
Dim NA
NA = "Not available"

If (Isnull(media) or media is nothing) then

MediaID = SCOMServer.AddMediaToCenter(ipaddress,_
NA,_
NA,_
NA,_
NA,_
NA,_
modBay,_
NA,_
NA,_
ModuleBay(media.Bay,"Media"),EncodeCmtyStr)
Call LogDebugString("Error - media module is null", WARNING_LEVEL)
Else
Call LogDebugString("Media Module name = " &amp; name, INFO_LEVEL_DETAIL)

MediaID = SCOMServer.AddMediaToCenter(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 " &amp; bayNumber &amp; "...", INFO_LEVEL_DETAIL)
Dim StorageID

Dim NA
NA = "Not available"
Dim name
name = "Storage" &amp; bayNumber
If (Isnull(storage) or storage is nothing) then

StorageID = SCOMServer.AddStorageToCenter(ipaddress,_
NA,_
NA,_
NA,_
NA,_
NA,_
modBay,_
NA,_
NA,_
NA,_
ModuleBay(storage.Bay,"Storage"),EncodeCmtyStr)
Call LogDebugString("Error - storage module is null", WARNING_LEVEL)
Else
Call LogDebugString("Storage Module name = " &amp; name, INFO_LEVEL_DETAIL)

StorageID = SCOMServer.AddStorageToCenter(ipaddress,_
storage.Name,_
storage.Description,_
storage.PartNumber,_
storage.FRUNumber,_
storage.FRUSerialNumber,_
modBay,_
storage.ChassisUUID,_
storage.UUID,_
storage.Firmware,_
ModuleBay(storage.Bay,"Storage"),EncodeCmtyStr)

Dim slotNumber, diskCount
diskCount = storage.StorageDiskCount
WSCript.echo diskCount
If diskCount &gt; 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 " &amp; bayNumber &amp; "...", INFO_LEVEL_DETAIL)
Dim name
name = "DiskDrive" &amp; bayNumber
If (Isnull(diskDrive) or diskDrive is nothing) then
Call LogDebugString("Error - storage module is null", DETAIL_LEVEL)
Else
Call LogDebugString("DiskDrive Module name = " &amp; name, INFO_LEVEL_DETAIL)
Dim DiskDriveID
DiskDriveID = SCOMServer.AddDiskDriveToStorage(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 " &amp; bayNumber &amp; "...", INFO_LEVEL_DETAIL)
'public string AddPseudoToCenter(string IPAddress, string BayNumber, string typee, string StorageUUID, string SlotNumber, string moduleBay, string bayName)
Call SCOMServer.AddPseudoToCenter(ipaddress, bayNumber,typee,"","0",moduleBay,BayName,EncodeCmtyStr,partTwo)

End Function
'-----------------------------------------------------------------------------
' End of RefreshPseudo()
'-----------------------------------------------------------------------------


Function ModuleBay(bayNumber,typee)

ModuleBay = "Not available"
If( bayNumber &gt;=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 &lt;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 &gt; 0 then
GetModuleBayNumber = Right(tempModBay, Len(tempModBay) - n - 4)
n = InStr(1,GetModuleBayNumber,",",1)
if n &gt; 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 &amp; "true"
Else
installString = installString &amp; "false"
End If
If (i &lt; count-1) then
installString = installString &amp; ","
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&lt;&gt;0) Then
Regdebug = -1
End If
End If

End Sub
'-------------------------------------------------------------------------------
'start of LogDebugString()
'-------------------------------------------------------------------------------
Sub LogDebugString(debugString, debugLevel)

If (Int(Regdebug) &gt;= Int(debugLevel)) Then
Call oAPI.LogScriptEvent("IBMBladeCenterRefreshModule.vbs", 202, 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
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 &lt;&gt; 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") &amp; iGroup
sPreliminaryOutString = Chr(CByte("&amp;H" &amp; Mid(iGroup, 1, 2))) &amp; Chr(CByte("&amp;H" &amp; Mid(iGroup, 3, 2))) &amp; Chr(CByte("&amp;H" &amp; Mid(iGroup, 5, 2)))
sOutputString = sOutputString &amp; 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

</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="WA"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.CommandOutput</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>