18457f821SDeepak Kodihalli ## This file is a template. The comment below is emitted 28457f821SDeepak Kodihalli ## into the rendered file; feel free to edit this file. 38457f821SDeepak Kodihalli // WARNING: Generated header. Do not edit! 48457f821SDeepak Kodihalli 58457f821SDeepak Kodihalli 68457f821SDeepak Kodihalli #pragma once 78457f821SDeepak Kodihalli 88457f821SDeepak Kodihalli #include <map> 98457f821SDeepak Kodihalli #include <iostream> 108457f821SDeepak Kodihalli #include "defines.hpp" 118457f821SDeepak Kodihalli #include "store.hpp" 1276794495SDeepak Kodihalli #include "types.hpp" 1376794495SDeepak Kodihalli #include "utils.hpp" 14128512b2SDeepak Kodihalli #include "extra-properties-gen.hpp" 158457f821SDeepak Kodihalli 168457f821SDeepak Kodihalli namespace openpower 178457f821SDeepak Kodihalli { 188457f821SDeepak Kodihalli namespace vpd 198457f821SDeepak Kodihalli { 208457f821SDeepak Kodihalli namespace inventory 218457f821SDeepak Kodihalli { 228457f821SDeepak Kodihalli 238457f821SDeepak Kodihalli /** @brief API to write parsed VPD to inventory, 24b29fb688SGunnar Mills * for a specific FRU 258457f821SDeepak Kodihalli * 268457f821SDeepak Kodihalli * @param [in] vpdStore - Store object containing 278457f821SDeepak Kodihalli * parsed VPD 288457f821SDeepak Kodihalli * @param [in] path - FRU object path 298457f821SDeepak Kodihalli */ 308457f821SDeepak Kodihalli template<Fru F> 31*640004f1SAlexander Filippov void writeFru(const Store& /*vpdStore*/, const std::string& /*path*/) { 32675ee7e4SArtem Senichev throw std::runtime_error("Not implemented"); 33675ee7e4SArtem Senichev } 348457f821SDeepak Kodihalli 353d7b4fe1SSantosh Puranik % for key in fruDict.keys(): 368457f821SDeepak Kodihalli <% 378457f821SDeepak Kodihalli fru = fruDict[key] 388457f821SDeepak Kodihalli %>\ 398457f821SDeepak Kodihalli // Specialization of ${key} 408457f821SDeepak Kodihalli template<> 418457f821SDeepak Kodihalli void writeFru<Fru::${key}>(const Store& vpdStore, 428457f821SDeepak Kodihalli const std::string& path) 438457f821SDeepak Kodihalli { 444cf89a10SDeepak Kodihalli ObjectMap objects; 454cf89a10SDeepak Kodihalli InterfaceMap interfaces; 460cc20121SDeepak Kodihalli auto iter = extra::objects.find(path); 478457f821SDeepak Kodihalli 488457f821SDeepak Kodihalli // Inventory manager needs object path, list of interface names to be 498457f821SDeepak Kodihalli // implemented, and property:value pairs contained in said interfaces 508457f821SDeepak Kodihalli 513d7b4fe1SSantosh Puranik % for interface, properties in fru.items(): 528457f821SDeepak Kodihalli <% 534cf89a10SDeepak Kodihalli names = interface.split(".") 544cf89a10SDeepak Kodihalli intfName = names[0] + names[-1] 558457f821SDeepak Kodihalli %>\ 564cf89a10SDeepak Kodihalli PropertyMap ${intfName}Props; 57c74ca6c9SMarri Devender Rao % if properties: 583d7b4fe1SSantosh Puranik % for name, value in properties.items(): 594cf89a10SDeepak Kodihalli % if fru and interface and name and value: 608457f821SDeepak Kodihalli <% 61db12d763SDeepak Kodihalli record, keyword = name.split(",") 628457f821SDeepak Kodihalli %>\ 63db12d763SDeepak Kodihalli if (vpdStore.exists<Record::${record}, record::Keyword::${keyword}>()) 64db12d763SDeepak Kodihalli { 65db12d763SDeepak Kodihalli ${intfName}Props["${value}"] = 668457f821SDeepak Kodihalli vpdStore.get<Record::${record}, record::Keyword::${keyword}>(); 67db12d763SDeepak Kodihalli } 688457f821SDeepak Kodihalli % endif 698457f821SDeepak Kodihalli % endfor 70c74ca6c9SMarri Devender Rao % endif 710cc20121SDeepak Kodihalli // Check and update extra properties 720cc20121SDeepak Kodihalli if(extra::objects.end() != iter) 730cc20121SDeepak Kodihalli { 740cc20121SDeepak Kodihalli auto propIter = (iter->second).find("${interface}"); 750cc20121SDeepak Kodihalli if((iter->second).end() != propIter) 760cc20121SDeepak Kodihalli { 770cc20121SDeepak Kodihalli for(const auto& map : propIter->second) 780cc20121SDeepak Kodihalli { 790cc20121SDeepak Kodihalli ${intfName}Props[map.first] = map.second; 800cc20121SDeepak Kodihalli } 810cc20121SDeepak Kodihalli } 820cc20121SDeepak Kodihalli } 834cf89a10SDeepak Kodihalli interfaces.emplace("${interface}", 844cf89a10SDeepak Kodihalli std::move(${intfName}Props)); 858457f821SDeepak Kodihalli % endfor 868457f821SDeepak Kodihalli 874cf89a10SDeepak Kodihalli sdbusplus::message::object_path object(path); 88128512b2SDeepak Kodihalli // Check and update extra properties 890cc20121SDeepak Kodihalli if(extra::objects.end() != iter) 90128512b2SDeepak Kodihalli { 910cc20121SDeepak Kodihalli for(const auto& entry : iter->second) 920cc20121SDeepak Kodihalli { 930cc20121SDeepak Kodihalli if(interfaces.end() == interfaces.find(entry.first)) 94128512b2SDeepak Kodihalli { 95128512b2SDeepak Kodihalli interfaces.emplace(entry.first, entry.second); 96128512b2SDeepak Kodihalli } 97128512b2SDeepak Kodihalli } 980cc20121SDeepak Kodihalli } 994cf89a10SDeepak Kodihalli objects.emplace(std::move(object), std::move(interfaces)); 1004cf89a10SDeepak Kodihalli 1014cf89a10SDeepak Kodihalli callPIM(std::move(objects)); 1028457f821SDeepak Kodihalli } 1038457f821SDeepak Kodihalli 1048457f821SDeepak Kodihalli % endfor 1058457f821SDeepak Kodihalli } // namespace inventory 1068457f821SDeepak Kodihalli } // namespace vpd 1078457f821SDeepak Kodihalli } // namespace openpower 108