PEL: Set critical association to object paths

Create critical association to inventory d-bus objects.
This is being done for the items in callouts that need
their service indicators turned on in its code, and
that the other association endpoint is the chasis so
it can be used for health rollup.

The associations property on the
xyz.openbmc_project.Association.Definitions interface
will have following entry added to called out object path:
["health_rollup", "critical",
"/xyz/openbmc_project/inventory/system/chassis"]

Signed-off-by: Sumit Kumar <sumit_kumar@in.ibm.com>
Change-Id: I50dfe4807ac9c19f54c49dfa2b9ec7119aaffb96
diff --git a/extensions/openpower-pels/service_indicators.cpp b/extensions/openpower-pels/service_indicators.cpp
index 1c9eff0..fca9f27 100644
--- a/extensions/openpower-pels/service_indicators.cpp
+++ b/extensions/openpower-pels/service_indicators.cpp
@@ -80,6 +80,7 @@
             if (!paths.empty())
             {
                 setNotFunctional(paths);
+                createCriticalAssociation(paths);
                 sai = false;
             }
         }
@@ -242,4 +243,24 @@
     }
 }
 
+void LightPath::createCriticalAssociation(
+    const std::vector<std::string>& inventoryPaths) const
+{
+    for (const auto& path : inventoryPaths)
+    {
+        try
+        {
+            _dataIface.setCriticalAssociation(path);
+        }
+        catch (const std::exception& e)
+        {
+            log<level::INFO>(
+                fmt::format(
+                    "Could not set critical association on object path {} ({})",
+                    path, e.what())
+                    .c_str());
+        }
+    }
+}
+
 } // namespace openpower::pels::service_indicators