1 #include "prime_inventory.hpp" 2 3 #include "event_logger.hpp" 4 #include "exceptions.hpp" 5 #include "utility/common_utility.hpp" 6 #include "utility/dbus_utility.hpp" 7 #include "utility/json_utility.hpp" 8 #include "utility/vpd_specific_utility.hpp" 9 10 #include <string> 11 12 PrimeInventory::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 [ " + 24 std::string(INVENTORY_JSON_SYM_LINK) + 25 " ], error : " + vpd::commonUtility::getErrCodeMsg(l_errCode)); 26 } 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 48 bool PrimeInventory::isPrimingRequired() const noexcept 49 { 50 // ToDo: Check if priming is required. 51 return true; 52 } 53 54 void 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 70 bool 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 78 void 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 87 void 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 94 void 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 } 100