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,
24*b29fb688SGunnar 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>
318457f821SDeepak Kodihalli void writeFru(const Store& vpdStore, const std::string& path);
328457f821SDeepak Kodihalli 
338457f821SDeepak Kodihalli % for key in fruDict.iterkeys():
348457f821SDeepak Kodihalli <%
358457f821SDeepak Kodihalli     fru = fruDict[key]
368457f821SDeepak Kodihalli %>\
378457f821SDeepak Kodihalli // Specialization of ${key}
388457f821SDeepak Kodihalli template<>
398457f821SDeepak Kodihalli void writeFru<Fru::${key}>(const Store& vpdStore,
408457f821SDeepak Kodihalli                            const std::string& path)
418457f821SDeepak Kodihalli {
424cf89a10SDeepak Kodihalli     ObjectMap objects;
434cf89a10SDeepak Kodihalli     InterfaceMap interfaces;
440cc20121SDeepak Kodihalli     auto iter = extra::objects.find(path);
458457f821SDeepak Kodihalli 
468457f821SDeepak Kodihalli     // Inventory manager needs object path, list of interface names to be
478457f821SDeepak Kodihalli     // implemented, and property:value pairs contained in said interfaces
488457f821SDeepak Kodihalli 
494cf89a10SDeepak Kodihalli     % for interface, properties in fru.iteritems():
508457f821SDeepak Kodihalli <%
514cf89a10SDeepak Kodihalli         names = interface.split(".")
524cf89a10SDeepak Kodihalli         intfName = names[0] + names[-1]
538457f821SDeepak Kodihalli %>\
544cf89a10SDeepak Kodihalli     PropertyMap ${intfName}Props;
55c74ca6c9SMarri Devender Rao         % if properties:
568457f821SDeepak Kodihalli             % for name, value in properties.iteritems():
574cf89a10SDeepak Kodihalli                 % if fru and interface and name and value:
588457f821SDeepak Kodihalli <%
59db12d763SDeepak Kodihalli                 record, keyword = name.split(",")
608457f821SDeepak Kodihalli %>\
61db12d763SDeepak Kodihalli     if (vpdStore.exists<Record::${record}, record::Keyword::${keyword}>())
62db12d763SDeepak Kodihalli     {
63db12d763SDeepak Kodihalli         ${intfName}Props["${value}"] =
648457f821SDeepak Kodihalli             vpdStore.get<Record::${record}, record::Keyword::${keyword}>();
65db12d763SDeepak Kodihalli     }
668457f821SDeepak Kodihalli                 % endif
678457f821SDeepak Kodihalli             % endfor
68c74ca6c9SMarri Devender Rao         % endif
690cc20121SDeepak Kodihalli     // Check and update extra properties
700cc20121SDeepak Kodihalli     if(extra::objects.end() != iter)
710cc20121SDeepak Kodihalli     {
720cc20121SDeepak Kodihalli         auto propIter = (iter->second).find("${interface}");
730cc20121SDeepak Kodihalli         if((iter->second).end() != propIter)
740cc20121SDeepak Kodihalli         {
750cc20121SDeepak Kodihalli             for(const auto& map : propIter->second)
760cc20121SDeepak Kodihalli             {
770cc20121SDeepak Kodihalli                 ${intfName}Props[map.first] = map.second;
780cc20121SDeepak Kodihalli             }
790cc20121SDeepak Kodihalli         }
800cc20121SDeepak Kodihalli     }
814cf89a10SDeepak Kodihalli     interfaces.emplace("${interface}",
824cf89a10SDeepak Kodihalli                        std::move(${intfName}Props));
838457f821SDeepak Kodihalli     % endfor
848457f821SDeepak Kodihalli 
854cf89a10SDeepak Kodihalli     sdbusplus::message::object_path object(path);
86128512b2SDeepak Kodihalli     // Check and update extra properties
870cc20121SDeepak Kodihalli     if(extra::objects.end() != iter)
88128512b2SDeepak Kodihalli     {
890cc20121SDeepak Kodihalli         for(const auto& entry : iter->second)
900cc20121SDeepak Kodihalli         {
910cc20121SDeepak Kodihalli             if(interfaces.end() == interfaces.find(entry.first))
92128512b2SDeepak Kodihalli             {
93128512b2SDeepak Kodihalli                 interfaces.emplace(entry.first, entry.second);
94128512b2SDeepak Kodihalli             }
95128512b2SDeepak Kodihalli         }
960cc20121SDeepak Kodihalli     }
974cf89a10SDeepak Kodihalli     objects.emplace(std::move(object), std::move(interfaces));
984cf89a10SDeepak Kodihalli 
994cf89a10SDeepak Kodihalli     callPIM(std::move(objects));
1008457f821SDeepak Kodihalli }
1018457f821SDeepak Kodihalli 
1028457f821SDeepak Kodihalli % endfor
1038457f821SDeepak Kodihalli } // namespace inventory
1048457f821SDeepak Kodihalli } // namespace vpd
1058457f821SDeepak Kodihalli } // namespace openpower
106