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