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>
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::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 @@
# 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 @@
{
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 @@
}
}
}
+ # If we need to hand create some of the groups, do so now.
+ foreach my $name (@defaultGroup)
+ {
+ print $fh "$name:\n";
+ }
close $fh;
}