Do not add empty paths to output file
This commit fixes a bug in the script where an undefined (blank)
path would get added to the output inventory file in case the
path for a given FRU is not found in both the MRW and the
default path map.
Having an empty path would result in a bad inventory environment
file that would cause the openpower vpd parser service that relies
on this file to fail at runtime.
Tested:
I ran the script manually against the witherspoon MRW and the
openpower layout YAML and verified that the generated inventory
file was good.
Change-Id: I6443208bd3e9e7705da40c30799f007a386b3612
Signed-off-by: Santosh Puranik <santosh.puranik@in.ibm.com>
diff --git a/gen_openpower_fru.pl b/gen_openpower_fru.pl
index 066c949..3eefc3e 100755
--- a/gen_openpower_fru.pl
+++ b/gen_openpower_fru.pl
@@ -64,9 +64,12 @@
for my $type (keys %targetHash)
{
- # One or more targets wasn't present in the inventory
- push @targetTypes, $type;
- push @paths, $defaultPaths{$type};
+ if(defined $defaultPaths{$type})
+ {
+ # 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' $!";