summaryrefslogtreecommitdiffstats
path: root/gen_openpower_fru.pl
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2017-02-07 12:14:55 -0600
committerPatrick Williams <patrick@stwcx.xyz>2017-02-14 16:34:01 +0000
commit6225e93d37644774aaecc30cb0161d0eaf0f570d (patch)
tree1a57b04c2b0d0fa53e7e2c32d642008d4523e3d4 /gen_openpower_fru.pl
parente3e0b720a06ed8fa8bfec834d597d2010412fbe7 (diff)
downloadphosphor-mrw-tools-6225e93d37644774aaecc30cb0161d0eaf0f570d.tar.gz
phosphor-mrw-tools-6225e93d37644774aaecc30cb0161d0eaf0f570d.zip
gen_openpower_fru.pl : Fetch inventory paths
In preparation for the openpower-vpd-parser recipe, this script will, from an input openpower vpd-config YAML file, determine which inventory objects we're interested in, and will fetch from the MRW pathnames these objects should have. The script will output a file in a format that can serve as an environment file for a systemd service, which in turn will launch the openpower-vpd-parser application with this information. Change-Id: I7c4fa70af002f63bd5501093802c1d41bd503e88 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'gen_openpower_fru.pl')
-rwxr-xr-xgen_openpower_fru.pl83
1 files changed, 83 insertions, 0 deletions
diff --git a/gen_openpower_fru.pl b/gen_openpower_fru.pl
new file mode 100755
index 0000000..066c949
--- /dev/null
+++ b/gen_openpower_fru.pl
@@ -0,0 +1,83 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+
+use mrw::Targets;
+use mrw::Inventory;
+use mrw::Util;
+use Getopt::Long;
+use YAML::Tiny qw(LoadFile);
+
+my $mrwFile = "";
+my $outFile = "";
+my $configFile = "";
+
+GetOptions(
+"m=s" => \$mrwFile,
+"c=s" => \$configFile,
+"o=s" => \$outFile,
+)
+or printUsage();
+
+if (($mrwFile eq "") or ($configFile eq "") or ($outFile eq ""))
+{
+ printUsage();
+}
+
+# Load system MRW
+my $targets = Targets->new;
+$targets->loadXML($mrwFile);
+my @inventory = Inventory::getInventory($targets);
+
+# Target Type : Target inventory path
+my %defaultPaths = (
+ "ETHERNET",
+ Util::getObmcName(
+ \@inventory,
+ Util::getBMCTarget($targets))."/ethernet"
+);
+
+# Parse config YAML
+my $targetItems = LoadFile($configFile);
+
+# Targets we're interested in, from the config YAML
+my @targetNames = keys %{$targetItems};
+my %targetHash;
+@targetHash{@targetNames} = ();
+my @targetTypes;
+my @paths;
+
+# Retrieve OBMC path of targets we're interested in
+for my $item (@inventory) {
+ my $targetType = "";
+ my $path = "";
+
+ if (!$targets->isBadAttribute($item->{TARGET}, "TYPE")) {
+ $targetType = $targets->getAttribute($item->{TARGET}, "TYPE");
+ }
+ next if (not exists $targetHash{$targetType});
+
+ push @targetTypes, $targetType;
+ push @paths, $item->{OBMC_NAME};
+ delete($targetHash{$targetType});
+}
+
+for my $type (keys %targetHash)
+{
+ # One or more targets wasn't present in the inventory
+ push @targetTypes, $type;
+ push @paths, $defaultPaths{$type};
+}
+
+open(my $fh, '>', $outFile) or die "Could not open file '$outFile' $!";
+print $fh "FRUS=".join ',',@targetTypes;
+print $fh "\n";
+print $fh "PATHS=".join ',',@paths;
+close $fh;
+
+sub printUsage
+{
+ print "
+ $0 -m [MRW file] -c [Config yaml] -o [Output filename]\n";
+ exit(1);
+}
OpenPOWER on IntegriCloud