blob: 7bbd0798d906446e8245fb64c5813771f5a6f03a [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,
24 * for a specifc FRU
25 *
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;
Deepak Kodihalli8457f822016-11-29 06:05:39 -060055 % for name, value in properties.iteritems():
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060056 % if fru and interface and name and value:
Deepak Kodihalli8457f822016-11-29 06:05:39 -060057<%
58 record, keyword = value.split(",")
59%>\
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060060 ${intfName}Props["${name}"] =
Deepak Kodihalli8457f822016-11-29 06:05:39 -060061 vpdStore.get<Record::${record}, record::Keyword::${keyword}>();
62 % endif
63 % endfor
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060064 // Check and update extra properties
65 if(extra::objects.end() != iter)
66 {
67 auto propIter = (iter->second).find("${interface}");
68 if((iter->second).end() != propIter)
69 {
70 for(const auto& map : propIter->second)
71 {
72 ${intfName}Props[map.first] = map.second;
73 }
74 }
75 }
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060076 interfaces.emplace("${interface}",
77 std::move(${intfName}Props));
Deepak Kodihalli8457f822016-11-29 06:05:39 -060078 % endfor
79
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060080 sdbusplus::message::object_path object(path);
Deepak Kodihalli128512b2017-02-17 03:12:08 -060081 // Check and update extra properties
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060082 if(extra::objects.end() != iter)
Deepak Kodihalli128512b2017-02-17 03:12:08 -060083 {
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060084 for(const auto& entry : iter->second)
Deepak Kodihalli128512b2017-02-17 03:12:08 -060085 {
Deepak Kodihalli0cc20122017-02-21 03:35:20 -060086 if(interfaces.end() == interfaces.find(entry.first))
87 {
88 interfaces.emplace(entry.first, entry.second);
89 }
Deepak Kodihalli128512b2017-02-17 03:12:08 -060090 }
91 }
Deepak Kodihalli4cf89a12017-02-06 05:06:48 -060092 objects.emplace(std::move(object), std::move(interfaces));
93
94 callPIM(std::move(objects));
Deepak Kodihalli8457f822016-11-29 06:05:39 -060095}
96
97% endfor
98} // namespace inventory
99} // namespace vpd
100} // namespace openpower