PEL: Update getInventoryFromLocCode

Add an argument to this function that says if the location code passed
in is already expanded (has the fcs and mts placeholders filled in with
VPD data).

This will be used in an upcoming commit that pulls location codes out of
PEL callouts.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Icefa9475962bdf161ddb8b51ce3dab805bcd396b
diff --git a/extensions/openpower-pels/data_interface.cpp b/extensions/openpower-pels/data_interface.cpp
index 1477806..c57593d 100644
--- a/extensions/openpower-pels/data_interface.cpp
+++ b/extensions/openpower-pels/data_interface.cpp
@@ -370,15 +370,25 @@
     return expandedLocationCode;
 }
 
-std::string DataInterface::getInventoryFromLocCode(
-    const std::string& unexpandedLocationCode, uint16_t node) const
+std::string
+    DataInterface::getInventoryFromLocCode(const std::string& locationCode,
+                                           uint16_t node, bool expanded) const
 {
-    auto method = _bus.new_method_call(
-        service_name::vpdManager, object_path::vpdManager,
-        interface::vpdManager, "GetFRUsByUnexpandedLocationCode");
+    std::string methodName = expanded ? "GetFRUsByExpandedLocationCode"
+                                      : "GetFRUsByUnexpandedLocationCode";
 
-    method.append(addLocationCodePrefix(unexpandedLocationCode),
-                  static_cast<uint16_t>(0));
+    auto method =
+        _bus.new_method_call(service_name::vpdManager, object_path::vpdManager,
+                             interface::vpdManager, methodName.c_str());
+
+    if (expanded)
+    {
+        method.append(locationCode);
+    }
+    else
+    {
+        method.append(addLocationCodePrefix(locationCode), node);
+    }
 
     auto reply = _bus.call(method);
 
diff --git a/extensions/openpower-pels/data_interface.hpp b/extensions/openpower-pels/data_interface.hpp
index 944de05..2a80dba 100644
--- a/extensions/openpower-pels/data_interface.hpp
+++ b/extensions/openpower-pels/data_interface.hpp
@@ -263,16 +263,23 @@
      * @brief Returns the inventory path for the FRU that the location
      *        code represents.
      *
-     * @param[in] locationCode - Location code value starting with Ufcs-, and
-     *                           if that isn't present it will be added first.
+     * @param[in] locationCode - If an expanded location code, then the
+     *                           full location code.
+     *                           If not expanded, a location code value
+     *                           starting with Ufcs-, and if that isn't
+     *                           present it will be added first.
      *
-     * @param[in] node - The node number the location is on.
+     * @param[in] node - The node number the location is on.  Ignored if the
+     *                   expanded location code is passed in.
+     *
+     * @param[in] expanded - If the location code already has the relevent
+     *                       VPD fields embedded in it.
      *
      * @return std::string - The inventory D-Bus object
      */
-    virtual std::string
-        getInventoryFromLocCode(const std::string& unexpandedLocationCode,
-                                uint16_t node) const = 0;
+    virtual std::string getInventoryFromLocCode(const std::string& LocationCode,
+                                                uint16_t node,
+                                                bool expanded) const = 0;
 
   protected:
     /**
@@ -483,15 +490,23 @@
      * @brief Returns the inventory path for the FRU that the location
      *        code represents.
      *
-     * @param[in] locationCode - Location code value starting with Ufcs-, and
-     *                           if that isn't present it will be added first.
+     * @param[in] locationCode - If an expanded location code, then the
+     *                           full location code.
+     *                           If not expanded, a location code value
+     *                           starting with Ufcs-, and if that isn't
+     *                           present it will be added first.
      *
-     * @param[in] node - The node number the location is on.
+     * @param[in] node - The node number the location is on.  Ignored if the
+     *                   expanded location code is passed in.
+     *
+     * @param[in] expanded - If the location code already has the relevent
+     *                       VPD fields embedded in it.
      *
      * @return std::string - The inventory D-Bus object
      */
-    std::string getInventoryFromLocCode(const std::string& expandedLocationCode,
-                                        uint16_t node) const override;
+    std::string getInventoryFromLocCode(const std::string& locationCode,
+                                        uint16_t node,
+                                        bool expanded) const override;
 
   private:
     /**
diff --git a/extensions/openpower-pels/src.cpp b/extensions/openpower-pels/src.cpp
index b96cb8f..b3a7693 100644
--- a/extensions/openpower-pels/src.cpp
+++ b/extensions/openpower-pels/src.cpp
@@ -671,7 +671,7 @@
         {
             // Get the inventory item from the unexpanded location code
             inventoryPath =
-                dataIface.getInventoryFromLocCode(regCallout.locCode, 0);
+                dataIface.getInventoryFromLocCode(regCallout.locCode, 0, false);
         }
         catch (const std::exception& e)
         {
@@ -781,8 +781,8 @@
 
         try
         {
-            auto inventoryPath =
-                dataIface.getInventoryFromLocCode(callout.locationCode, 0);
+            auto inventoryPath = dataIface.getInventoryFromLocCode(
+                callout.locationCode, 0, false);
 
             addInventoryCallout(inventoryPath, priority, std::nullopt,
                                 dataIface);