IPMI Parser Script Updates

This commit adds a new option to the IPMI MRW
parsing scripts (--skip-broken-mrw).

When specified, the option will cause the scripts
to ignore broken MRW targets such as IPMI sensor
targets without a valid SENSOR_ID attribute
or a FRU without a valid FRU_ID.

This allows us to pull in an in-progress MRW without
it breaking our builds.

Tested:
I tested the scripts against an incomplete MRW and made
sure that the scripts ignored broken targets and generated
output config files for whatever targets were valid.

Signed-off-by: Santosh Puranik <santosh.puranik@in.ibm.com>
Change-Id: Ibf2ca3769e6030d62e73fb362d73a775433273bc
diff --git a/gen_fru_properties.pl b/gen_fru_properties.pl
index 43cc753..c371658 100755
--- a/gen_fru_properties.pl
+++ b/gen_fru_properties.pl
@@ -13,12 +13,14 @@
 my $mrwFile = "";
 my $outFile = "";
 my $configFile = "";
+my $skipBrokenMrw = 0;
 
 
 GetOptions(
 "m=s" => \$mrwFile,
 "c=s" => \$configFile,
 "o=s" => \$outFile,
+"skip-broken-mrw" => \$skipBrokenMrw
 )
 or printUsage();
 
@@ -79,6 +81,10 @@
     my ($yamlDict) = @_;
     for my $type (keys %targetHash)
     {
+        if($skipBrokenMrw and !exists $defaultPaths{$type})
+        {
+            next;
+        }
         print $fh $defaultPaths{$type}.":";
         print $fh "\n";
         while (my ($interface,$propertyMap) = each %{$yamlDict->{$type}})
@@ -140,6 +146,9 @@
 sub printUsage
 {
     print "
-    $0 -m [MRW file] -c [Config yaml] -o [Output filename]\n";
+    $0 -m [MRW file] -c [Config yaml] -o [Output filename] [OPTIONS]
+Options:
+    --skip-broken-mrw = Skip broken MRW targets
+    \n";
     exit(1);
 }
diff --git a/gen_ipmi_fru.pl b/gen_ipmi_fru.pl
index dab5e41..1f13584 100644
--- a/gen_ipmi_fru.pl
+++ b/gen_ipmi_fru.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/perl
 use strict;
 use warnings;
 
@@ -12,12 +12,14 @@
 my $debug           = 0;
 my $outputFile     = "";
 my $metaDataFile   = "";
+my $skipBrokenMrw  = 0;
 
 # Command line argument parsing
 GetOptions(
 "i=s" => \$serverwizFile,    # string
 "m=s" => \$metaDataFile,     # string
 "o=s" => \$outputFile,       # string
+"skip-broken-mrw" => \$skipBrokenMrw,
 "d"   => \$debug,
 )
 or printUsage();
@@ -67,6 +69,10 @@
     #1) If not fru
     #2) if the fru type is not there in the config file.
     #3) if the fru type is in associated types.
+    #4) if FRU_ID is not defined for the target and we are asked to ignore such
+    #   targets.
+
+    next if ($skipBrokenMrw and ($fruID eq ""));
 
     next if (not $isFru or not exists $types{$fruType} or exists $allAssoTypesHash{$fruType});
 
@@ -173,6 +179,7 @@
     $0 -i [MRW filename] -m [MetaData filename] -o [Output filename] [OPTIONS]
 Options:
     -d = debug mode
+    --skip-broken-mrw = Skip broken MRW targets
         \n";
     exit(1);
 }
diff --git a/gen_ipmi_sel.pl b/gen_ipmi_sel.pl
index 30efb0d..bb70a7f 100755
--- a/gen_ipmi_sel.pl
+++ b/gen_ipmi_sel.pl
@@ -13,12 +13,14 @@
 my $debug          = 0;
 my $outputFile     = "";
 my $metaDataFile   = "";
+my $skipBrokenMrw  = 0;
 
 # Command line argument parsing
 GetOptions(
 "i=s" => \$serverwizFile,    # string
 "m=s" => \$metaDataFile,     # string
 "o=s" => \$outputFile,       # string
+"skip-broken-mrw" => \$skipBrokenMrw,
 "d"   => \$debug,
 )
 or printUsage();
@@ -74,6 +76,7 @@
         #Instance path then die
 
         if ($sensorID eq '' or $eventReadingType eq '' or $path eq '') {
+            next if $skipBrokenMrw;
             close $fh;
             die("sensor without info for target=$target");
         }
@@ -118,6 +121,7 @@
     $0 -i [MRW filename] -m [SensorMetaData filename] -o [Output filename] [OPTIONS]
 Options:
     -d = debug mode
+    --skip-broken-mrw = Skip broken MRW targets
         \n";
     exit(1);
 }
diff --git a/gen_ipmi_sensor.pl b/gen_ipmi_sensor.pl
index 5ac15b2..490cade 100755
--- a/gen_ipmi_sensor.pl
+++ b/gen_ipmi_sensor.pl
@@ -12,12 +12,14 @@
 my $debug           = 0;
 my $outputFile     = "";
 my $metaDataFile   = "";
+my $skipBrokenMrw = 0;
 
 # Command line argument parsing
 GetOptions(
 "i=s" => \$serverwizFile,    # string
 "m=s" => \$metaDataFile,     # string
 "o=s" => \$outputFile,       # string
+"skip-broken-mrw" => \$skipBrokenMrw,
 "d"   => \$debug,
 )
 or printUsage();
@@ -88,6 +90,7 @@
         #Instance path then die
 
         if ($sensorID eq '' or $sensorReadingType eq '' or $path eq '') {
+            next if $skipBrokenMrw;
             close $fh;
             die("sensor without info for target=$target");
         }
@@ -295,6 +298,7 @@
     print "
     $0 -i [MRW filename] -m [SensorMetaData filename] -o [Output filename] [OPTIONS]
 Options:
+    --skip-broken-mrw = Skip broken MRW targets
     -d = debug mode
         \n";
     exit(1);