blob: 6e04649f0b030526551c9f493660d7aee8f25128 [file] [log] [blame]
Deepak Kodihalli8457f822016-11-29 06:05:39 -06001## This file is a template. The comment below is emitted
2## into the rendered file; feel free to edit this file.
3// WARNING: Generated header. Do not edit!
4
5
6#pragma once
7
8#include <map>
9#include <iostream>
10#include "defines.hpp"
11#include "store.hpp"
Deepak Kodihalli76794492017-02-16 23:48:18 -060012#include "types.hpp"
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -050013#include "common_utility.hpp"
Deepak Kodihalli128512b2017-02-17 03:12:08 -060014#include "extra-properties-gen.hpp"
Deepak Kodihalli8457f822016-11-29 06:05:39 -060015
16namespace openpower
17{
18namespace vpd
19{
20namespace inventory
21{
Sunny Srivastava6c71c9d2021-04-15 04:43:54 -050022using namespace openpower::vpd::common::utility;
Deepak Kodihalli8457f822016-11-29 06:05:39 -060023
Deepak Kodihalli8457f822016-11-29 06:05:39 -060024/** @brief API to write parsed VPD to inventory,
Gunnar Millsb29fb682017-10-25 16:23:31 -050025 * for a specific FRU
Deepak Kodihalli8457f822016-11-29 06:05:39 -060026 *
27 * @param [in] vpdStore - Store object containing
28 * parsed VPD
29 * @param [in] path - FRU object path
30 */
31template<Fru F>
Alexander Filippov640004f2021-01-29 17:32:11 +030032void writeFru(const Store& /*vpdStore*/, const std::string& /*path*/) {
Artem Senichev675ee7e2020-02-19 18:19:51 +030033 throw std::runtime_error("Not implemented");
34}
Deepak Kodihalli8457f822016-11-29 06:05:39 -060035
Santosh Puranik3d7b4fe2020-04-02 23:27:22 +053036% for key in fruDict.keys():
Deepak Kodihalli8457f822016-11-29 06:05:39 -060037<%
38 fru = fruDict[key]
39%>\
40// Specialization of ${key}
41template<>
42void writeFru<Fru::${key}>(const Store& vpdStore,
43 const std::string& path)
44{
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060045 ObjectMap objects;
46 InterfaceMap interfaces;
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060047 auto iter = extra::objects.find(path);
Deepak Kodihalli8457f822016-11-29 06:05:39 -060048
49 // Inventory manager needs object path, list of interface names to be
50 // implemented, and property:value pairs contained in said interfaces
51
Santosh Puranik3d7b4fe2020-04-02 23:27:22 +053052 % for interface, properties in fru.items():
Deepak Kodihalli8457f822016-11-29 06:05:39 -060053<%
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060054 names = interface.split(".")
55 intfName = names[0] + names[-1]
Deepak Kodihalli8457f822016-11-29 06:05:39 -060056%>\
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060057 PropertyMap ${intfName}Props;
Marri Devender Raoc74ca6c2017-08-20 01:22:34 -050058 % if properties:
Santosh Puranik3d7b4fe2020-04-02 23:27:22 +053059 % for name, value in properties.items():
Marri Devender Raoc74ca6c2017-08-20 01:22:34 -050060 % if fru and interface and name and value:
Deepak Kodihalli8457f822016-11-29 06:05:39 -060061<%
Deepak Kodihallidb12d762017-09-11 23:04:33 -050062 record, keyword = name.split(",")
Deepak Kodihalli8457f822016-11-29 06:05:39 -060063%>\
Deepak Kodihallidb12d762017-09-11 23:04:33 -050064 if (vpdStore.exists<Record::${record}, record::Keyword::${keyword}>())
65 {
66 ${intfName}Props["${value}"] =
67 vpdStore.get<Record::${record}, record::Keyword::${keyword}>();
68 }
Marri Devender Raoc74ca6c2017-08-20 01:22:34 -050069 % endif
70 % endfor
71 % endif
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060072 // Check and update extra properties
73 if(extra::objects.end() != iter)
74 {
75 auto propIter = (iter->second).find("${interface}");
76 if((iter->second).end() != propIter)
77 {
78 for(const auto& map : propIter->second)
79 {
80 ${intfName}Props[map.first] = map.second;
81 }
82 }
83 }
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060084 interfaces.emplace("${interface}",
85 std::move(${intfName}Props));
Deepak Kodihalli8457f822016-11-29 06:05:39 -060086 % endfor
87
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060088 sdbusplus::message::object_path object(path);
Deepak Kodihalli128512b2017-02-17 03:12:08 -060089 // Check and update extra properties
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060090 if(extra::objects.end() != iter)
Deepak Kodihalli128512b2017-02-17 03:12:08 -060091 {
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060092 for(const auto& entry : iter->second)
Deepak Kodihalli128512b2017-02-17 03:12:08 -060093 {
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060094 if(interfaces.end() == interfaces.find(entry.first))
95 {
96 interfaces.emplace(entry.first, entry.second);
97 }
Deepak Kodihalli128512b2017-02-17 03:12:08 -060098 }
99 }
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -0600100 objects.emplace(std::move(object), std::move(interfaces));
101
102 callPIM(std::move(objects));
Deepak Kodihalli8457f822016-11-29 06:05:39 -0600103}
104
105% endfor
106} // namespace inventory
107} // namespace vpd
108} // namespace openpower