diff options
author | Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com> | 2017-03-30 00:10:47 +0530 |
---|---|---|
committer | Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com> | 2017-03-30 16:24:48 +0530 |
commit | d00394377105a72a7ca0ba5feabd52d029c71b17 (patch) | |
tree | 8ab692082024af60f1b9f6fa0fcf21b54ad275a8 | |
parent | 9142da4b410e6c34aca3ef8a8e84b13d39a9c00d (diff) | |
download | phosphor-mrw-tools-d00394377105a72a7ca0ba5feabd52d029c71b17.tar.gz phosphor-mrw-tools-d00394377105a72a7ca0ba5feabd52d029c71b17.zip |
LEDS: Create default groups by hand if not defined in MRW
Certain LED groups must be present in all systems and they are
* BmcBooted
* PowerOn
If MRW does not define these, then these are to be defined in the script
and its fine to have no LEDs mapping to the group.
Change-Id: Ic99a019794145c6c2da5b0139198df9435024b93
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
-rwxr-xr-x | gen_led_groups.pl | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/gen_led_groups.pl b/gen_led_groups.pl index 5530578..2c5ca33 100755 --- a/gen_led_groups.pl +++ b/gen_led_groups.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; use warnings; @@ -6,6 +6,7 @@ use mrw::Targets; # Set of APIs allowing access to parsed ServerWiz2 XML output use mrw::Inventory; # To get list of Inventory targets use Getopt::Long; # For parsing command line arguments use Data::Dumper qw(Dumper); # Dumping blob +use List::Util qw(first); # Globals my $force = 0; @@ -39,6 +40,10 @@ my %invHash; # front-fault-led and rear-fault-led my @encFaults; +# These groups are a must in all the systems. +# Its fine if they don't map to any physical LED +my @defaultGroup = ("BmcBooted", "PowerOn"); + # API used to access parsed XML data my $targetObj = Targets->new; if($verbose == 1) @@ -218,6 +223,15 @@ sub generateYamlFile { if($group ne $groupCopy) { + # If one of these is a default group, then delete it from the array + # that is being maintained to create one by hand if all default ones + # are not defined + my $index = first {$defaultGroup[$_] eq $group} 0..$#defaultGroup; + if (defined $index) + { + splice @defaultGroup, $index, 1; + } + $groupCopy = ''; $ledCopy = ''; } @@ -244,6 +258,11 @@ sub generateYamlFile } } } + # If we need to hand create some of the groups, do so now. + foreach my $name (@defaultGroup) + { + print $fh "$name:\n"; + } close $fh; } |