summaryrefslogtreecommitdiffstats
path: root/gen_ipmi_fru.pl
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@in.ibm.com>2017-01-17 00:09:04 +0530
committerDeepak Kodihalli <dkodihal@in.ibm.com>2017-01-23 02:30:54 -0600
commitfa70dc9dcf463c6f29dd8fc5bc85dc4280e38593 (patch)
tree6a0ec3aa6e530f034a111c033ade35864e6c26d0 /gen_ipmi_fru.pl
parent854e26a36cde5f4131f2c673b716509cbdd4f298 (diff)
downloadphosphor-mrw-tools-fa70dc9dcf463c6f29dd8fc5bc85dc4280e38593.tar.gz
phosphor-mrw-tools-fa70dc9dcf463c6f29dd8fc5bc85dc4280e38593.zip
gen_ipmi_fru.pl : Fetch FRU information from MRW
This commit serves as a building block since the script can now just print certain attributes (see output example below) for FRU elements defined in the MRW. Typically, FRUs of interest to IPMI will have a non-zero FRU id defined. Output example: FRUID => 1, FRUType => SYS, ObjectPath => /system FRUID => 2, FRUType => NODE, ObjectPath => /system/chassis Change-Id: I3f27f905b2a366277e8a6120142c3fb136a44ad5 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'gen_ipmi_fru.pl')
-rwxr-xr-xgen_ipmi_fru.pl71
1 files changed, 71 insertions, 0 deletions
diff --git a/gen_ipmi_fru.pl b/gen_ipmi_fru.pl
new file mode 100755
index 0000000..34b19ee
--- /dev/null
+++ b/gen_ipmi_fru.pl
@@ -0,0 +1,71 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+
+use mrw::Targets;
+use mrw::Inventory;
+use Getopt::Long; # For parsing command line arguments
+use YAML::XS 'LoadFile'; # For loading and reading of YAML file
+
+# Globals
+my $serverwizFile = "";
+my $debug = 0;
+
+# Command line argument parsing
+GetOptions(
+"i=s" => \$serverwizFile, # string
+"d" => \$debug,
+)
+or printUsage();
+
+if (($serverwizFile eq ""))
+{
+ printUsage();
+}
+
+my $targetObj = Targets->new;
+$targetObj->loadXML($serverwizFile);
+
+#open the mrw xml Fetch the FRU id,type,object path from the mrw.
+
+my @inventory = Inventory::getInventory($targetObj);
+for my $item (@inventory) {
+ my $isFru = 0, my $fruID = 0, my $fruType = "";
+ my $isChildFru = 0;
+
+ #Fetch the fruid.
+ if (!$targetObj->isBadAttribute($item->{TARGET}, "FRU_ID")) {
+ $fruID = $targetObj->getAttribute($item->{TARGET}, "FRU_ID");
+ $isFru = 1;
+ }
+
+ #Fech 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');
+
+ printDebug ("FRUID => $fruID, FRUType => $fruType, ObjectPath => $item->{OBMC_NAME}");
+
+}
+#------------------------------------END OF MAIN-----------------------
+
+# Usage
+sub printUsage
+{
+ print "
+ $0 -i [MRW filename] [OPTIONS]
+Options:
+ -d = debug mode
+ \n";
+ exit(1);
+}
+
+# Helper function to put debug statements.
+sub printDebug
+{
+ my $str = shift;
+ print "DEBUG: ", $str, "\n" if $debug;
+}
OpenPOWER on IntegriCloud