summaryrefslogtreecommitdiffstats
path: root/gen_ipmi_fru.pl
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@in.ibm.com>2017-01-17 00:44:17 +0530
committerDeepak Kodihalli <dkodihal@in.ibm.com>2017-01-26 03:28:34 -0600
commit26cc055b4de7118234decf8931a53661aee7500c (patch)
treeabc8e13d5e4ac622f6608cc01192313b5c734554 /gen_ipmi_fru.pl
parenta149ba100e90416ba41e9d9205c6f23d27c4249a (diff)
downloadphosphor-mrw-tools-26cc055b4de7118234decf8931a53661aee7500c.tar.gz
phosphor-mrw-tools-26cc055b4de7118234decf8931a53661aee7500c.zip
gen_ipmi_fru.pl : retrieve children of FRUs
For IPMI FRUs, figure out if they have children (non-FRU) that are of interest, and if yes, generate metadata for those children. Change-Id: Iecc54dd39633f869b2210de83df9cb3292ab483a Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'gen_ipmi_fru.pl')
-rwxr-xr-xgen_ipmi_fru.pl64
1 files changed, 62 insertions, 2 deletions
diff --git a/gen_ipmi_fru.pl b/gen_ipmi_fru.pl
index 760082f..aab9bdb 100755
--- a/gen_ipmi_fru.pl
+++ b/gen_ipmi_fru.pl
@@ -45,12 +45,12 @@ my %types;
my @inventory = Inventory::getInventory($targetObj);
for my $item (@inventory) {
my $isFru = 0, my $fruID = 0, my $fruType = "";
- #Fetch the FRU ID.
+ #Fetch the FRUID.
if (!$targetObj->isBadAttribute($item->{TARGET}, "FRU_ID")) {
$fruID = $targetObj->getAttribute($item->{TARGET}, "FRU_ID");
$isFru = 1;
}
- # Fetch the FRU Type.
+ #Fetch the FRU Type.
if (!$targetObj->isBadAttribute($item->{TARGET}, "TYPE")) {
$fruType = $targetObj->getAttribute($item->{TARGET}, "TYPE");
}
@@ -65,11 +65,71 @@ for my $item (@inventory) {
writeToFile($fruType,$item->{OBMC_NAME},$fruTypeConfig,$fh);
+ # Fetch all the children for this inventory target,It might happen the child is fru or non fru
+ # Following condition to be true for fetching the associated non fru devices.
+ # -it should be non fru.
+ # -type of the fru is in the interested types.
+ # - the parent of the child should be same as inventory target.
+
+ foreach my $child ($targetObj->getAllTargetChildren($item->{TARGET})) {
+ $fruType = $targetObj->getAttribute($child, "TYPE");
+
+ if (!$targetObj->isBadAttribute($child, "FRU_ID")) {
+ #i.e this child is a fru,we are interrested in non fru devices
+ next;
+ }
+
+ #Fetch the Fru Type
+ if (!$targetObj->isBadAttribute($child, "TYPE")) {
+ $fruType = $targetObj->getAttribute($child, "TYPE");
+ }
+
+ # check whether this fru type is in interested fru types.
+ if (not exists $types{$fruType}) {
+ next;
+ }
+
+ # find the parent fru of this child.
+ my $parent = $targetObj->getTargetParent($child);
+ while ($parent ne ($item->{TARGET})) {
+ $parent = $targetObj->getTargetParent($parent);
+ if (!$targetObj->isBadAttribute($parent, "FRU_ID")) {
+ last;
+ }
+
+ }
+ #if parent of the child is not equal to the item->target
+ #i.e some other fru is parent of this child.
+ if ( $parent ne ($item->{TARGET}) ){
+ next;
+ }
+
+ printDebug(" ".$child);
+ printDebug(" Type:".$fruType );
+ my $childObmcName = getObmcName(\@inventory, $child);
+ writeToFile($fruType, $childObmcName, $fruTypeConfig, $fh);
+ }
}
close $fh;
#------------------------------------END OF MAIN-----------------------
+# Map an MRW name to corresponding OBMC name
+sub getObmcName
+{
+ my $inventory = $_[0]; # Inventory items
+ my $target = $_[1]; # MRW Target name
+ for my $item (@inventory)
+ {
+ if($item->{TARGET} eq $target)
+ {
+ return $item->{OBMC_NAME};
+ }
+ }
+ return undef;
+}
+
+
#Get the metdata for the incoming frutype from the loaded config file.
#Write the FRU data into the output file
OpenPOWER on IntegriCloud