blob: 786edbd44735400da1afa5aae92344c1f038ed16 [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"
13#include "utils.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{
22
Deepak Kodihalli8457f822016-11-29 06:05:39 -060023/** @brief API to write parsed VPD to inventory,
Gunnar Millsb29fb682017-10-25 16:23:31 -050024 * for a specific FRU
Deepak Kodihalli8457f822016-11-29 06:05:39 -060025 *
26 * @param [in] vpdStore - Store object containing
27 * parsed VPD
28 * @param [in] path - FRU object path
29 */
30template<Fru F>
31void writeFru(const Store& vpdStore, const std::string& path);
32
33% for key in fruDict.iterkeys():
34<%
35 fru = fruDict[key]
36%>\
37// Specialization of ${key}
38template<>
39void writeFru<Fru::${key}>(const Store& vpdStore,
40 const std::string& path)
41{
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060042 ObjectMap objects;
43 InterfaceMap interfaces;
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060044 auto iter = extra::objects.find(path);
Deepak Kodihalli8457f822016-11-29 06:05:39 -060045
46 // Inventory manager needs object path, list of interface names to be
47 // implemented, and property:value pairs contained in said interfaces
48
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060049 % for interface, properties in fru.iteritems():
Deepak Kodihalli8457f822016-11-29 06:05:39 -060050<%
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060051 names = interface.split(".")
52 intfName = names[0] + names[-1]
Deepak Kodihalli8457f822016-11-29 06:05:39 -060053%>\
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060054 PropertyMap ${intfName}Props;
Marri Devender Raoc74ca6c2017-08-20 01:22:34 -050055 % if properties:
56 % for name, value in properties.iteritems():
57 % if fru and interface and name and value:
Deepak Kodihalli8457f822016-11-29 06:05:39 -060058<%
Deepak Kodihallidb12d762017-09-11 23:04:33 -050059 record, keyword = name.split(",")
Deepak Kodihalli8457f822016-11-29 06:05:39 -060060%>\
Deepak Kodihallidb12d762017-09-11 23:04:33 -050061 if (vpdStore.exists<Record::${record}, record::Keyword::${keyword}>())
62 {
63 ${intfName}Props["${value}"] =
64 vpdStore.get<Record::${record}, record::Keyword::${keyword}>();
65 }
Marri Devender Raoc74ca6c2017-08-20 01:22:34 -050066 % endif
67 % endfor
68 % endif
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060069 // Check and update extra properties
70 if(extra::objects.end() != iter)
71 {
72 auto propIter = (iter->second).find("${interface}");
73 if((iter->second).end() != propIter)
74 {
75 for(const auto& map : propIter->second)
76 {
77 ${intfName}Props[map.first] = map.second;
78 }
79 }
80 }
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060081 interfaces.emplace("${interface}",
82 std::move(${intfName}Props));
Deepak Kodihalli8457f822016-11-29 06:05:39 -060083 % endfor
84
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060085 sdbusplus::message::object_path object(path);
Deepak Kodihalli128512b2017-02-17 03:12:08 -060086 // Check and update extra properties
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060087 if(extra::objects.end() != iter)
Deepak Kodihalli128512b2017-02-17 03:12:08 -060088 {
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060089 for(const auto& entry : iter->second)
Deepak Kodihalli128512b2017-02-17 03:12:08 -060090 {
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060091 if(interfaces.end() == interfaces.find(entry.first))
92 {
93 interfaces.emplace(entry.first, entry.second);
94 }
Deepak Kodihalli128512b2017-02-17 03:12:08 -060095 }
96 }
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060097 objects.emplace(std::move(object), std::move(interfaces));
98
99 callPIM(std::move(objects));
Deepak Kodihalli8457f822016-11-29 06:05:39 -0600100}
101
102% endfor
103} // namespace inventory
104} // namespace vpd
105} // namespace openpower