PEL: LightPath: Assert LED groups

Fill in the functions to get the LED group D-Bus paths corresponding to
the called out location codes, and then set the Asserted property on
that path to turn on the LEDs.

If there are any problems looking up any of the LED groups, then do not
turn on any LEDs at all, even if others were OK.  In this case, the
system attention indicator will be turned on instead.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I7e3ee6259d972dd2c6939c5a1004c6d25c40e38a
diff --git a/extensions/openpower-pels/service_indicators.cpp b/extensions/openpower-pels/service_indicators.cpp
index 074251c..3f934c7 100644
--- a/extensions/openpower-pels/service_indicators.cpp
+++ b/extensions/openpower-pels/service_indicators.cpp
@@ -15,6 +15,8 @@
  */
 #include "service_indicators.hpp"
 
+#include <fmt/format.h>
+
 #include <bitset>
 #include <phosphor-logging/log.hpp>
 
@@ -182,13 +184,62 @@
 std::vector<std::string> LightPath::getLEDGroupPaths(
     const std::vector<std::string>& locationCodes) const
 {
-    // TODO
-    return {};
+    std::vector<std::string> ledGroups;
+    std::string inventoryPath;
+
+    for (const auto& locCode : locationCodes)
+    {
+        try
+        {
+            inventoryPath =
+                _dataIface.getInventoryFromLocCode(locCode, 0, true);
+        }
+        catch (const std::exception& e)
+        {
+            log<level::ERR>(fmt::format("Could not get inventory path for "
+                                        "location code {} ({}).",
+                                        locCode, e.what())
+                                .c_str());
+
+            // Unless we can get the LEDs for all FRUs, we can't turn
+            // on any of them, so clear the list and quit.
+            ledGroups.clear();
+            break;
+        }
+
+        try
+        {
+            ledGroups.push_back(_dataIface.getFaultLEDGroup(inventoryPath));
+        }
+        catch (const std::exception& e)
+        {
+            log<level::ERR>(fmt::format("Could not get LED group path for "
+                                        "inventory path {} ({}).",
+                                        inventoryPath, e.what())
+                                .c_str());
+            ledGroups.clear();
+            break;
+        }
+    }
+
+    return ledGroups;
 }
 
 void LightPath::assertLEDs(const std::vector<std::string>& ledGroups) const
 {
-    // TODO
+    for (const auto& ledGroup : ledGroups)
+    {
+        try
+        {
+            _dataIface.assertLEDGroup(ledGroup, true);
+        }
+        catch (const std::exception& e)
+        {
+            log<level::ERR>(fmt::format("Failed to assert LED group {} ({})",
+                                        ledGroup, e.what())
+                                .c_str());
+        }
+    }
 }
 
 } // namespace openpower::pels::service_indicators