summaryrefslogtreecommitdiffstats
path: root/gen_ipmi_fru.pl
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@in.ibm.com>2017-01-17 00:32:32 +0530
committerDeepak Kodihalli <dkodihal@in.ibm.com>2017-01-26 03:28:28 -0600
commita149ba100e90416ba41e9d9205c6f23d27c4249a (patch)
tree31ee4fdff005ba71c9005fbb50933d3430d8614f /gen_ipmi_fru.pl
parentfa70dc9dcf463c6f29dd8fc5bc85dc4280e38593 (diff)
downloadphosphor-mrw-tools-a149ba100e90416ba41e9d9205c6f23d27c4249a.tar.gz
phosphor-mrw-tools-a149ba100e90416ba41e9d9205c6f23d27c4249a.zip
gen_ipmi_fru.pl: construct FRU metadata
For IPMI FRUs, generate a file to depict which dbus properties are implemented for a FRU, and what IPMI FRU properties those dbus properties map to. This commit defines a YAML file which helps figure out the supported dbus inteface/properties for a FRU, and what the corresponding IPMI FRU properties are. Change-Id: I26de1aa26e3a74fd8cc95bb0d479d9b036eb5683 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'gen_ipmi_fru.pl')
-rwxr-xr-xgen_ipmi_fru.pl69
1 files changed, 59 insertions, 10 deletions
diff --git a/gen_ipmi_fru.pl b/gen_ipmi_fru.pl
index 34b19ee..760082f 100755
--- a/gen_ipmi_fru.pl
+++ b/gen_ipmi_fru.pl
@@ -10,15 +10,19 @@ use YAML::XS 'LoadFile'; # For loading and reading of YAML file
# Globals
my $serverwizFile = "";
my $debug = 0;
+my $outputFile = "";
+my $metaDataFile = "";
# Command line argument parsing
GetOptions(
"i=s" => \$serverwizFile, # string
+"m=s" => \$metaDataFile, # string
+"o=s" => \$outputFile, # string
"d" => \$debug,
)
or printUsage();
-if (($serverwizFile eq ""))
+if (($serverwizFile eq "") or ($outputFile eq "") or ($metaDataFile eq ""))
{
printUsage();
}
@@ -26,37 +30,82 @@ if (($serverwizFile eq ""))
my $targetObj = Targets->new;
$targetObj->loadXML($serverwizFile);
-#open the mrw xml Fetch the FRU id,type,object path from the mrw.
+#open the mrw xml and the metaData file for the fru.
+#Fetch the FRU id,type,object path from the mrw.
+#Get the metadata for that fru from the metadata file.
+#Merge the data into the outputfile
+
+open(my $fh, '>', $outputFile) or die "Could not open file '$outputFile' $!";
+my $fruTypeConfig = LoadFile($metaDataFile);
+
+my @interestedTypes = keys %{$fruTypeConfig};
+my %types;
+@types{@interestedTypes} = ();
my @inventory = Inventory::getInventory($targetObj);
for my $item (@inventory) {
my $isFru = 0, my $fruID = 0, my $fruType = "";
- my $isChildFru = 0;
-
- #Fetch the fruid.
+ #Fetch the FRU ID.
if (!$targetObj->isBadAttribute($item->{TARGET}, "FRU_ID")) {
$fruID = $targetObj->getAttribute($item->{TARGET}, "FRU_ID");
$isFru = 1;
}
-
- #Fech the fru type.
+ # Fetch the FRU Type.
if (!$targetObj->isBadAttribute($item->{TARGET}, "TYPE")) {
$fruType = $targetObj->getAttribute($item->{TARGET}, "TYPE");
}
- #skip those entries whose type is NA and is not fru.
- next if ( $fruType eq 'NA' or not($isFru) or $fruType eq 'BMC');
+ #Skip if we're not interested
+ next if (not $isFru or not exists $types{$fruType});
printDebug ("FRUID => $fruID, FRUType => $fruType, ObjectPath => $item->{OBMC_NAME}");
+ print $fh $fruID.":";
+ print $fh "\n";
+
+ writeToFile($fruType,$item->{OBMC_NAME},$fruTypeConfig,$fh);
+
}
+close $fh;
+
#------------------------------------END OF MAIN-----------------------
+#Get the metdata for the incoming frutype from the loaded config file.
+#Write the FRU data into the output file
+
+sub writeToFile
+{
+ my $fruType = $_[0];#fru type
+ my $instancePath = $_[1];#instance Path
+ my $fruTypeConfig = $_[2];#loaded config file (frutypes)
+ my $fh = $_[3];#file Handle
+ #walk over all the fru types and match for the incoming type
+ print $fh " ".$instancePath.":";
+ print $fh "\n";
+ my $interfaces = $fruTypeConfig->{$fruType};
+ #Walk over all the interfaces as it needs to be written
+ while ( my ($interface,$properties) = each %{$interfaces}) {
+ print $fh " ".$interface.":";
+ print $fh "\n";
+ #walk over all the properties as it needs to be written
+ while ( my ($dbusProperty,$metadata) = each %{$properties}) {
+ #will write property named "Property" first then
+ #other properties.
+ print $fh " ".$dbusProperty.":";
+ print $fh "\n";
+ for my $key (sort keys %{$metadata}) {
+ print $fh " $key: "."$metadata->{$key}";
+ print $fh "\n";
+ }
+ }
+ }
+}
+
# Usage
sub printUsage
{
print "
- $0 -i [MRW filename] [OPTIONS]
+ $0 -i [MRW filename] -m [MetaData filename] -o [Output filename] [OPTIONS]
Options:
-d = debug mode
\n";
OpenPOWER on IntegriCloud