Lenovo Flex System Chassis Refresh Module Base

IBM.FlexSystem.Refresh.ModuleBase (WriteActionModuleType)

Lenovo Flex System Chassis Refresh Module base method

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.FlexSystem.Refresh.ModuleBase" 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"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" maxOccurs="1" name="NoOfRetries" type="xsd:unsignedInt" default="1"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" maxOccurs="1" name="Timeout" type="xsd:unsignedInt" default="1500"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" maxOccurs="1" name="Port" type="xsd:unsignedInt" default="161"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" maxOccurs="1" name="Version" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" maxOccurs="1" name="SNMPv3UserName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" maxOccurs="1" name="SNMPv3EngineID" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" maxOccurs="1" name="SNMPv3AuthProtocol" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" maxOccurs="1" name="SNMPv3AuthPassword" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" maxOccurs="1" name="SNMPv3PrivProtocol" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" maxOccurs="1" name="SNMPv3PrivPassword" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" maxOccurs="1" name="SNMPv3ContextName" type="xsd:string"/>
</Configuration>
<ModuleImplementation>
<Composite>
<MemberModules>
<WriteAction ID="WA" TypeID="Windows!Microsoft.Windows.ScriptWriteAction">
<ScriptName>IBMFlexChassisRefreshModule.vbs</ScriptName>
<Arguments>"$Config/ModuleType$" "$Config/IPAddress$" "$Config/BayNumber$" "$Config/CommunityString$" "$Config/Port$" "$Config/SNMPv3UserName$" "$Config/SNMPv3AuthProtocol$" "$Config/SNMPv3AuthPassword$" "$Config/SNMPv3PrivProtocol$" "$Config/SNMPv3PrivPassword$" "$Config/SNMPv3ContextName$" "$Config/Version$" "$Config/Timeout$" "$Config/NoOfRetries$" </Arguments>
<!-- <Arguments>"$MPElement[Name='IBM.FlexSystem.FSM']/FSMIPaddress$" "$Config/ModuleType$" "$Config/IPAddress$" "$Config/BayNumber$" "$Config/CommunityString$" "$Config/Port$" "$Config/SNMPv3UserName$" "$Config/SNMPv3AuthProtocol$" "$Config/SNMPv3AuthPassword$" "$Config/SNMPv3PrivProtocol$" "$Config/SNMPv3PrivPassword$" "$Config/SNMPv3ContextName$" "$Config/Version$" "$Config/Timeout$" "$Config/NoOfRetries$" </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 FSM_TYPE="FSM"
Const COOLING_TYPE = "COOLING"
Const IO_TYPE = "IO"
Const MEDIA_TYPE = "MEDIA"
Const MM_TYPE = "MM"
Const POWER_TYPE = "POWER"
Const STORAGE_TYPE = "STORAGE"
Const FANMUX_TYPE="FANMUX"
Const REARLED_TYPE="REARLED"
'-----------------------------------------------------------------------------
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 = GetModuleBayNumber(modBay)
EncodeCmtyStr = WScript.Arguments.Item(3)
CommunityString = EncodeCmtyStr
'CommunityString = Chr2Unicode(fDecode(EncodeCmtyStr))
'Add license control
Dim oArgs
Set oArgs = WScript.Arguments
Dim port,user,auPro,auProPW,priPro,priProPW,context,version,timeout,retry
On Error Resume Next
port = oArgs(4)
user = oArgs(5)
auPro= oArgs(6)
auProPW= oArgs(7)
priPro= oArgs(8)
priProPW= oArgs(9)
context = oArgs(10)
version = oArgs(11)
timeout = oArgs(12)
retry = oArgs(13)
On Error GoTo 0

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 &amp; vbCrlf + _
"CommunityString = "+ EncodeCmtyStr, INFO_LEVEL_DETAIL)

Set SCOMServer = WScript.CreateObject("IBM.SystemsManagement.SCOMHelper.SCOMServer")
Dim licenseLevel, licenseToken
call SCOMServer.GetLicenseLevel(licenseToken, licenseLevel)

If SCOMServer.VersionCompare(licenseLevel,"4.0") &lt; 0 Then
WScript.Echo "This premium feature is only supported on servers with IBM Hardware management license 4.0 or higher. It is not supported on current server"
WScript.Echo "Refer to the IBM Hardware Management Pack User's Guide for more information on managed system requirements. "
WScript.Quit 1
End If

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("IBM.SystemsManagement.CMMClassLibrary.FlexChassis")

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

Dim init
init = -1
init = bladeChassis.InitializeSocketConnection(IPAddress, CommunityString, port,version)

Call bladeChassis.SetSnmpV3User(user,auPro,auProPW,priPro,priProPW,context,version,timeout,retry)

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 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

case FANMUX_TYPE
Call LogDebugString("Refresh a FanMux Module in bay " &amp; 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 " &amp; 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

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

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 " &amp; "...", 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)

' 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.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 " &amp; blade.Bay &amp; "...", INFO_LEVEL_DETAIL)

bladeID = SCOMServer.AddBladeToCMMCenter(ipaddress,_
blade.Name,_
blade.Description,_
blade.PartNumber,_
blade.FRUNumber,_
blade.FRUSerialNumber,_
modBay,_
blade.ChassisUUID,_
blade.UUID,_
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()
'-----------------------------------------------------------------------------


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

SwithID = SCOMServer.AddIOToCMMCenter(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.AddIOToCMMCenter(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.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 = " &amp; name, INFO_LEVEL_DETAIL)

PowerID = SCOMServer.AddPowerToCMMCenter(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()
'-----------------------------------------------------------------------------


Function RefreshFanMux(bayNumber, FanMux)

Dim NA
NA = "Not Available"
Call LogDebugString("Refreshing new FanMux Module in slot " &amp; bayNumber &amp; "...", INFO_LEVEL_DETAIL)
Dim name
name = "FanMux" &amp; bayNumber

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

FanMuxID = SCOMServer.AddFanMuxToCMMCenter(ipaddress,_
NA,_
NA,_
NA,_
NA,_
NA,_
modBay,_
NA,_
NA,_
NA,_
NA,_
ModuleBay(FanMux.Bay,"FanMux"),EncodeCmtyStr)
Call LogDebugString("Error - FanMux module is null", WARNING_LEVEL_DEV)
Else
Call LogDebugString("FanMux Module name = " &amp; name, INFO_LEVEL_DETAIL)

FanMuxID = SCOMServer.AddFanMuxToCMMCenter(ipaddress,_
FanMux.Name,_
FanMux.Description,_
FanMux.PartNumber,_
FanMux.FRUNumber,_
FanMux.FRUSerialNumber,_
modBay,_
FanMux.ChassisUUID,_
FanMux.UUID,_
FanMux.Firmware,_
FanMux.ModuleID, _
ModuleBay(FanMux.Bay,"FanMux"),EncodeCmtyStr)

End If

End Function



Function RefreshRearLED(bayNumber, RearLED)
Dim RearLEDID
Dim NA
NA = "Not Available"
Call LogDebugString("Refreshing new RearLED Module in slot " &amp; bayNumber &amp; "...", INFO_LEVEL_DETAIL)
Dim name
name = "RearLED" &amp; bayNumber

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

RearLEDID = SCOMServer.AddRearLEDToCMMCenter(ipaddress,_
NA,_
NA,_
NA,_
NA,_
NA,_
modBay,_
NA,_
NA,_
NA,_
NA,_
ModuleBay(RearLED.Bay,"RearLED"),EncodeCmtyStr)
Call LogDebugString("Error - RearLED module is null", WARNING_LEVEL_DEV)
Else
Call LogDebugString("RearLED Module name = " &amp; name, INFO_LEVEL_DETAIL)

RearLEDID = SCOMServer.AddRearLEDToCMMCenter(ipaddress,_
RearLED.Name,_
RearLED.Description,_
RearLED.PartNumber,_
RearLED.FRUNumber,_
RearLED.FRUSerialNumber,_
modBay,_
RearLED.ChassisUUID,_
RearLED.UUID,_
RearLED.Firmware,_
RearLED.ModuleID, _
ModuleBay(RearLED.Bay,"RearLED"),EncodeCmtyStr)

End If

End Function

'-----------------------------------------------------------------------------
' 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 " &amp; bayNumber &amp; "...", 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 " &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.AddMMToCMMCenter(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_DEV)
Else
Call LogDebugString("Media Module name= " &amp; name, INFO_LEVEL_DETAIL)

MMID = SCOMServer.AddMMToCMMCenter(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.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 = " &amp; 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 " &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.AddStorageToCMMCenter(ipaddress,_
NA,_
NA,_
NA,_
NA,_
NA,_
modBay,_
NA,_
NA,_
NA,_
ModuleBay(storage.Bay,"Storage"),EncodeCmtyStr)
Call LogDebugString("Error - storage module is null", WARNING_LEVEL_DEV)
Else
Call LogDebugString("Storage Module name = " &amp; name, INFO_LEVEL_DETAIL)

StorageID = SCOMServer.AddStorageToCMMCenter(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.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 " &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.AddPseudoToCMMCenter(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 "FSM"
ModuleBay="FSM_"
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("IBMFlexChassisRefreshModule.vbs", 233, 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>600</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="WA"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.CommandOutput</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>