Prime system blueprint from wait-vpd-parsers

This commit updates wait-vpd-parsers to prime system blueprint.
As part of PST VPD collection flow, priming inventory objects needs to
be triggered as a part of systemd target, instead of being triggered by
vpd-manager.
This commit only implements only stub APIs under PrimeInventory class.

Change-Id: I144b13192e9ce39461c331c51ed7d4d9e952809c
Signed-off-by: Anupama B R <anupama.b.r1@ibm.com>
diff --git a/wait-vpd-parser/src/prime_inventory.cpp b/wait-vpd-parser/src/prime_inventory.cpp
new file mode 100644
index 0000000..84688d0
--- /dev/null
+++ b/wait-vpd-parser/src/prime_inventory.cpp
@@ -0,0 +1,98 @@
+#include "prime_inventory.hpp"
+
+#include "event_logger.hpp"
+#include "exceptions.hpp"
+#include "utility/dbus_utility.hpp"
+#include "utility/json_utility.hpp"
+#include "utility/vpd_specific_utility.hpp"
+
+#include <string>
+
+PrimeInventory::PrimeInventory()
+{
+    try
+    {
+        uint16_t l_errCode = 0;
+        m_sysCfgJsonObj =
+            vpd::jsonUtility::getParsedJson(INVENTORY_JSON_SYM_LINK, l_errCode);
+
+        if (l_errCode)
+        {
+            throw std::runtime_error(
+                "JSON parsing failed for file [ " +
+                std::string(INVENTORY_JSON_SYM_LINK) + " ], error : " +
+                vpd::vpdSpecificUtility::getErrCodeMsg(l_errCode));
+        }
+
+        // check for mandatory fields at this point itself.
+        if (!m_sysCfgJsonObj.contains("frus"))
+        {
+            throw std::runtime_error(
+                "Mandatory tag(s) missing from JSON file [" +
+                std::string(INVENTORY_JSON_SYM_LINK) + "]");
+        }
+    }
+    catch (const std::exception& l_ex)
+    {
+        vpd::EventLogger::createSyncPel(
+            vpd::types::ErrorType::JsonFailure,
+            vpd::types::SeverityType::Critical, __FILE__, __FUNCTION__, 0,
+            "Prime inventory failed, reason: " + std::string(l_ex.what()),
+            std::nullopt, std::nullopt, std::nullopt, std::nullopt);
+
+        throw;
+    }
+}
+
+bool PrimeInventory::isPrimingRequired() const noexcept
+{
+    // ToDo: Check if priming is required.
+    return true;
+}
+
+void PrimeInventory::primeSystemBlueprint() const noexcept
+{
+    try
+    {
+        /*ToDo:
+      * Check if priming is required.
+      * Traverse the system config JSON &
+      prime all the FRU paths which qualifies for priming.
+      */
+    }
+    catch (const std::exception& l_ex)
+    {
+        // ToDo: log an error
+    }
+}
+
+bool PrimeInventory::primeInventory(
+    [[maybe_unused]] const std::string& i_vpdFilePath) const noexcept
+{
+    // ToDo: Travers system config JSON & prime inventory objects found under
+    // the EEPROM.
+    return true;
+}
+
+void PrimeInventory::populateInterfaces(
+    [[maybe_unused]] const nlohmann::json& i_interfaceJson,
+    [[maybe_unused]] vpd::types::InterfaceMap& io_interfaceMap,
+    [[maybe_unused]] const vpd::types::VPDMapVariant& i_parsedVpdMap)
+    const noexcept
+{
+    // ToDo: Populate interfaces needs to be published on Dbus.
+}
+
+void PrimeInventory::processFunctionalProperty(
+    [[maybe_unused]] const std::string& i_inventoryObjPath,
+    [[maybe_unused]] vpd::types::InterfaceMap& io_interfaces) const noexcept
+{
+    // ToDo: Populate interface to publish Functional property on Dbus.
+}
+
+void PrimeInventory::processEnabledProperty(
+    [[maybe_unused]] const std::string& i_inventoryObjPath,
+    [[maybe_unused]] vpd::types::InterfaceMap& io_interfaces) const noexcept
+{
+    // ToDo: Populate interface to publish Enabled property on Dbus.
+}
diff --git a/wait-vpd-parser/src/wait_vpd_parser.cpp b/wait-vpd-parser/src/wait_vpd_parser.cpp
index 44f1da3..352f5cd 100644
--- a/wait-vpd-parser/src/wait_vpd_parser.cpp
+++ b/wait-vpd-parser/src/wait_vpd_parser.cpp
@@ -2,6 +2,7 @@
 
 #include "constants.hpp"
 #include "logger.hpp"
+#include "prime_inventory.hpp"
 #include "utility/dbus_utility.hpp"
 
 #include <CLI/CLI.hpp>
@@ -104,20 +105,34 @@
 
 int main(int argc, char** argv)
 {
-    CLI::App l_app{"Wait VPD parser app"};
+    try
+    {
+        CLI::App l_app{"Wait VPD parser app"};
 
-    // default retry limit and sleep duration values
-    unsigned l_retryLimit{100};
-    unsigned l_sleepDurationInSeconds{2};
+        // default retry limit and sleep duration values
+        unsigned l_retryLimit{100};
+        unsigned l_sleepDurationInSeconds{2};
 
-    l_app.add_option("--retryLimit, -r", l_retryLimit, "Retry limit");
-    l_app.add_option("--sleepDurationInSeconds, -s", l_sleepDurationInSeconds,
-                     "Sleep duration in seconds between each retry");
+        l_app.add_option("--retryLimit, -r", l_retryLimit, "Retry limit");
+        l_app.add_option("--sleepDurationInSeconds, -s",
+                         l_sleepDurationInSeconds,
+                         "Sleep duration in seconds between each retry");
 
-    CLI11_PARSE(l_app, argc, argv);
+        CLI11_PARSE(l_app, argc, argv);
 
-    return collectAllFruVpd()
-               ? checkVpdCollectionStatus(l_retryLimit,
-                                          l_sleepDurationInSeconds)
-               : vpd::constants::VALUE_1;
+        PrimeInventory l_primeObj;
+        l_primeObj.primeSystemBlueprint();
+
+        return collectAllFruVpd()
+                   ? checkVpdCollectionStatus(l_retryLimit,
+                                              l_sleepDurationInSeconds)
+                   : vpd::constants::VALUE_1;
+    }
+    catch (const std::exception& l_ex)
+    {
+        const auto l_logger = vpd::Logger::getLoggerInstance();
+        l_logger->logMessage("Exiting from wait-vpd-parser, reason: " +
+                             std::string(l_ex.what()));
+        return vpd::constants::VALUE_1;
+    }
 }