Add LED grouping support

This enables creating custom groups and participating LEDs so that it can later
be generated from MRW. For each of the group, a dbus object is created which
will announce LED actions.

Fixes openbmc/openbmc#550

Change-Id: I7a56d08755288dcfce45ee4c6d6b6c5e5aa454f7
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/parse_led.py b/parse_led.py
new file mode 100755
index 0000000..96bcd5e
--- /dev/null
+++ b/parse_led.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+import yaml
+
+if __name__ == '__main__':
+    with open('led.yaml', 'r') as f:
+        ifile = yaml.safe_load(f)
+
+    with open('led-gen.hpp', 'w') as ofile:
+        ofile.write('/* !!! WARNING: This is a GENERATED Code..')
+        ofile.write('Please do NOT Edit !!! */\n\n')
+
+        ofile.write('const std::map<std::string,')
+        ofile.write(' std::set<phosphor::led::Manager::LedAction>>')
+        ofile.write(' phosphor::led::Manager::cv_LedMap = {\n\n')
+        for group in ifile.iterkeys():
+            # Value of this group is a std::set<string, led structure>
+            ledset = ifile[group]
+            ofile.write('   {\"' + group + '\",{\n')
+
+            for led_dict, list_dict in ledset.iteritems():
+                for name, value in list_dict.iteritems():
+                    if group and led_dict and name and value:
+                        ofile.write('        {\"' + led_dict + '\",')
+                        ofile.write(value.upper() + '},\n')
+            ofile.write('   }},\n')
+        ofile.write('};\n')
+