blob: 79125fe5013fb04befbb14f9cda233af43eeae62 [file] [log] [blame]
Anupama B R445819f2025-09-18 11:00:25 -05001#include "prime_inventory.hpp"
2
3#include "event_logger.hpp"
4#include "exceptions.hpp"
Rekha Aparnac6159a22025-10-09 12:20:20 +05305#include "utility/common_utility.hpp"
Anupama B R445819f2025-09-18 11:00:25 -05006#include "utility/dbus_utility.hpp"
7#include "utility/json_utility.hpp"
8#include "utility/vpd_specific_utility.hpp"
9
10#include <string>
11
12PrimeInventory::PrimeInventory()
13{
14 try
15 {
16 uint16_t l_errCode = 0;
17 m_sysCfgJsonObj =
18 vpd::jsonUtility::getParsedJson(INVENTORY_JSON_SYM_LINK, l_errCode);
19
20 if (l_errCode)
21 {
22 throw std::runtime_error(
23 "JSON parsing failed for file [ " +
Rekha Aparnac6159a22025-10-09 12:20:20 +053024 std::string(INVENTORY_JSON_SYM_LINK) +
25 " ], error : " + vpd::commonUtility::getErrCodeMsg(l_errCode));
Anupama B R445819f2025-09-18 11:00:25 -050026 }
27
28 // check for mandatory fields at this point itself.
29 if (!m_sysCfgJsonObj.contains("frus"))
30 {
31 throw std::runtime_error(
32 "Mandatory tag(s) missing from JSON file [" +
33 std::string(INVENTORY_JSON_SYM_LINK) + "]");
34 }
35 }
36 catch (const std::exception& l_ex)
37 {
38 vpd::EventLogger::createSyncPel(
39 vpd::types::ErrorType::JsonFailure,
40 vpd::types::SeverityType::Critical, __FILE__, __FUNCTION__, 0,
41 "Prime inventory failed, reason: " + std::string(l_ex.what()),
42 std::nullopt, std::nullopt, std::nullopt, std::nullopt);
43
44 throw;
45 }
46}
47
48bool PrimeInventory::isPrimingRequired() const noexcept
49{
50 // ToDo: Check if priming is required.
51 return true;
52}
53
54void PrimeInventory::primeSystemBlueprint() const noexcept
55{
56 try
57 {
58 /*ToDo:
59 * Check if priming is required.
60 * Traverse the system config JSON &
61 prime all the FRU paths which qualifies for priming.
62 */
63 }
64 catch (const std::exception& l_ex)
65 {
66 // ToDo: log an error
67 }
68}
69
70bool PrimeInventory::primeInventory(
71 [[maybe_unused]] const std::string& i_vpdFilePath) const noexcept
72{
73 // ToDo: Travers system config JSON & prime inventory objects found under
74 // the EEPROM.
75 return true;
76}
77
78void PrimeInventory::populateInterfaces(
79 [[maybe_unused]] const nlohmann::json& i_interfaceJson,
80 [[maybe_unused]] vpd::types::InterfaceMap& io_interfaceMap,
81 [[maybe_unused]] const vpd::types::VPDMapVariant& i_parsedVpdMap)
82 const noexcept
83{
84 // ToDo: Populate interfaces needs to be published on Dbus.
85}
86
87void PrimeInventory::processFunctionalProperty(
88 [[maybe_unused]] const std::string& i_inventoryObjPath,
89 [[maybe_unused]] vpd::types::InterfaceMap& io_interfaces) const noexcept
90{
91 // ToDo: Populate interface to publish Functional property on Dbus.
92}
93
94void PrimeInventory::processEnabledProperty(
95 [[maybe_unused]] const std::string& i_inventoryObjPath,
96 [[maybe_unused]] vpd::types::InterfaceMap& io_interfaces) const noexcept
97{
98 // ToDo: Populate interface to publish Enabled property on Dbus.
99}