FRU.DiscoveryRule (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DsFRUPs DataSource Microsoft.Windows.TimedPowerShell.DiscoveryProvider Default

Overrideable Parameters:

IDParameterTypeSelector
IntervalSecondsint$Config/IntervalSeconds$

Source Code:

<DataSourceModuleType ID="FRU.DiscoveryRule" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="computerName" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DsFRUPs" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>DiscoverFRU.PS1</ScriptName>
<ScriptBody><Script>

# **********************************************************************************
# Script Name : DiscoverFRU
# Authored by : MphasiS Corporation
# Description : Discovers Lenovo Servers FRU Properties thru Out-Of Band
#
# Copyright (c) 2013 Lenovo Group. All rights reserved.
# Redistribution and use in source and binary forms, with or without modification,
# is not permitted without specific prior written permission from Lenovo.
# **********************************************************************************
param($sourceId,$managedEntityId,$computerName)

#--------------Inventory Logging--------------#
Function LogEntry($LogContent)
{
Try
{
$LoggingFlag_Reg = (New-Object -ComObject WScript.Shell).RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\LenovoPartnerPack\SCOMServer\Log")
if( $LoggingFlag_Reg -eq 1)
{
$SetLogging = $true
}
else
{
$SetLogging = $false
}
}
Catch
{
$SetLogging = $true
}

if ($SetLogging -eq $true)
{
$LogPath = ${Env:LENOVOPARTNERPACK_HOME} + "\Log"

if(![IO.Directory]::Exists($LogPath))
{
New-Item -ItemType directory -Path $LogPath
}

##$LogFileName = "ThinkServerPartnerPack_Inventory_"+ (Get-Date -Format "dd-MMM-yyyy")+".log"
$LogFileName = "ThinkServerPartnerPack_Inventory.log"
$LogFile = $LogPath + "\" + $LogFileName

$LogTime = Get-Date -Format "dd-MMM-yyyy HH:mm:ss"
$LogEntryContent = $LogTime + " : " + $LogContent

$LogEntryContent | Out-File $LogFile -Append -Force
}
}
#--------------Inventory Logging--------------#


$api = new-object -comObject 'MOM.ScriptAPI'
$discoveryFRU = $api.CreateDiscoveryData(0, $SourceId, $ManagedEntityId)

$SCOMServer_Reg = (New-Object -ComObject WScript.Shell).RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Machine Settings\DefaultSDKServiceMachine")

$LocalHostName = [System.Net.Dns]::GetHostByName('localhost').HostName

IF ($SCOMServer_Reg -eq $LocalHostName)
{
#Import-Module OperationsManager
$ServersList = Get-SCOMClass -Name 'Lenovo.TMM.Server.MP.Host.Class' | Get-SCOMClassInstance | Select *.HostName, *.BMCIP

foreach($Server in $ServersList)
{
$ServerName = $Server.'[Lenovo.TMM.Server.MP.Host.Class].HostName'.Value
$BMCIPAddress = $Server.'[Lenovo.TMM.Server.MP.Host.Class].BMCIP'.Value

$BMCData = Get-SCOMClass -Name 'Lenovo.TMM.Server.MP.LenovoBMC.Class' | Get-SCOMClassInstance | where {$_.DisplayName -eq $ServerName } | Select *.UserName, *.Password
$BMCUserName = $BMCData.'[Lenovo.TMM.Server.MP.LenovoBMC.Class].UserName'.Value
$BMCPassword = $BMCData.'[Lenovo.TMM.Server.MP.LenovoBMC.Class].Password'.Value

#Enc - Code#
$dllPath = ${Env:LENOVOPARTNERPACK_HOME} + "\bin\LenovoCryptoLib.dll"
[Reflection.Assembly]::LoadFile($dllPath)
$EncInstance = New-Object LenovoCryptoLib.LenovoAsymmetricEncryption
$EncInstance.CheckKeyAndSet();
$BMCUserName = $EncInstance.DecryptText($BMCUserName, $EncInstance.PrivateKey, 1024);
$BMCPassword = $EncInstance.DecryptText($BMCPassword, $EncInstance.PrivateKey, 1024);
#Enc - Code#
$JavaFilePath = ${Env:LENOVOPARTNERPACK_HOME}+ '\Lib\jre8\bin\java.exe'

if (($BMCUserName -ne $null) -and ($BMCPassword -ne $null))
{
$FRUJarFilePath = "${Env:LENOVOPARTNERPACK_HOME}"+ "\Lib\VeraxIPMIWrapper.jar"
Try
{
$FRUsList = &amp; $JavaFilePath -jar $FRUJarFilePath FRU $BMCIPAddress $BMCUserName $BMCPassword | ConvertFrom-Json
}
Catch
{
LogEntry("Error while fetching FRU details using Out of band for "+ $computerName)
}

$boardInfoList = $FRUsList.result.boardInfoList | Select-Object -Property mfgdate, boardManufacturer, boardProductName, boardSerialNumber, boardPartNumber, fruFileId, customBoardInfo

$chassisInfoList = $FRUsList.result.chassisInfoList | Select-Object -Property chassisType, chassisPartNumber, chassisSerialNumber, customChassisInfo

$productInfoList = $FRUsList.result.productInfoList | Select-Object -Property manufacturerName, productName, productModelNumber, productVersion, productSerialNumber

if ( [string]::IsNullOrEmpty($boardInfoList.boardManufacturer))
{
$FRUDataValid = "false";
}
else
{
$FRUDataValid = "true";
}

if ( $FRUDataValid -eq "true")
{
$BoardManufacturer = $boardInfoList.boardManufacturer

$Description = "FRU Information"

$instance = $discoveryFRU.CreateClassInstance("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']$")
$instance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", $Description)
$instance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $ServerName)

if ([string]::IsNullOrEmpty($boardInfoList.mfgdate))
{
$BoardManufacturingDate = "Not Available"
}
else
{
$BoardManufacturingDate = $boardInfoList.mfgdate
}

if ( [string]::IsNullOrEmpty($boardInfoList.boardProductName))
{
$BoardProductName = "Not Available"
}
else
{
$BoardProductName = $boardInfoList.boardProductName
}

if ( [string]::IsNullOrEmpty($boardInfoList.boardSerialNumber))
{
$BoardSerialNumber = "Not Available"
}
else
{
$BoardSerialNumber = $boardInfoList.boardSerialNumber
}

if ( [string]::IsNullOrEmpty($boardInfoList.boardPartNumber))
{
$BoardPartNumber = "Not Available"
}
else
{
$BoardPartNumber = $boardInfoList.boardPartNumber
}

if ( [string]::IsNullOrEmpty($chassisInfoList.chassisType))
{
$ChassisType = "Not Available"
}
else
{
$ChassisType = $chassisInfoList.chassisType
}

if ( [string]::IsNullOrEmpty($chassisInfoList.chassisPartNumber))
{
$ChassisPartNumber = "Not Available"
}
else
{
$ChassisPartNumber = $chassisInfoList.chassisPartNumber
}

if ( [string]::IsNullOrEmpty($chassisInfoList.chassisSerialNumber))
{
$ChassisSerialNumber = "Not Available"
}
else
{
$ChassisSerialNumber = $chassisInfoList.chassisSerialNumber
}

if ( [string]::IsNullOrEmpty($chassisInfoList.customChassisInfo))
{
$CustomChassisInfo = "Not Available"
}
else
{
$CustomChassisInfo = $chassisInfoList.customChassisInfo
}

if ( [string]::IsNullOrEmpty($productInfoList.manufacturerName))
{
$ProductManufacturerName = "Not Available"
}
else
{
$ProductManufacturerName = $productInfoList.manufacturerName
}

if ( [string]::IsNullOrEmpty($productInfoList.productName))
{
$ProductName = "Not Available"
}
else
{
$ProductName = $productInfoList.productName
}

if ( [string]::IsNullOrEmpty($productInfoList.productModelNumber))
{
$ProductModelNumber = "Not Available"
}
else
{
$ProductModelNumber = $productInfoList.productModelNumber
}

if ( [string]::IsNullOrEmpty($productInfoList.productVersion))
{
$ProductVersion = "Not Available"
}
else
{
$ProductVersion = $productInfoList.productVersion
}

if ( [string]::IsNullOrEmpty($productInfoList.productSerialNumber))
{
$ProductSerialNumber = "Not Available"
}
else
{
$ProductSerialNumber = $productInfoList.productSerialNumber
}

#BaseBoard
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/BoardManufacturingDate$", $BoardManufacturingDate)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/BoardManufacturer$", $BoardManufacturer)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/BoardProductName$", $BoardProductName)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/BoardSerialNumber$", $BoardSerialNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/BoardPartNumber$", $BoardPartNumber )

#Chasis
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/ChassisType$", $ChassisType )
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/ChassisPartNumber$", $ChassisPartNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/ChassisSerialNumber$", $ChassisSerialNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/CustomChassisInfo$", $CustomChassisInfo)

#Product Info List
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/ProductManufacturerName$", $ProductManufacturerName)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/ProductName$", $ProductName)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/ProductModelNumber$", $ProductModelNumber)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/ProductVersion$", $ProductVersion)
$instance.AddProperty("$MPElement[Name='Lenovo.TMM.Server.MP.Inventory.FRU.Class']/ProductSerialNumber$", $ProductSerialNumber)
$discoveryFRU.AddInstance($instance)

}
}
}
}
$discoveryFRU

</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>sourceID</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>managedEntityID</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>computerName</Name>
<Value>$Config/computerName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>3600</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DsFRUPs"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>