Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 1 | ## 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 Kodihalli | 7679449 | 2017-02-16 23:48:18 -0600 | [diff] [blame] | 12 | #include "types.hpp" |
| 13 | #include "utils.hpp" |
Deepak Kodihalli | 128512b | 2017-02-17 03:12:08 -0600 | [diff] [blame] | 14 | #include "extra-properties-gen.hpp" |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 15 | |
| 16 | namespace openpower |
| 17 | { |
| 18 | namespace vpd |
| 19 | { |
| 20 | namespace inventory |
| 21 | { |
| 22 | |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 23 | /** @brief API to write parsed VPD to inventory, |
Gunnar Mills | b29fb68 | 2017-10-25 16:23:31 -0500 | [diff] [blame] | 24 | * for a specific FRU |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 25 | * |
| 26 | * @param [in] vpdStore - Store object containing |
| 27 | * parsed VPD |
| 28 | * @param [in] path - FRU object path |
| 29 | */ |
| 30 | template<Fru F> |
Artem Senichev | 675ee7e | 2020-02-19 18:19:51 +0300 | [diff] [blame] | 31 | void writeFru(const Store& vpdStore, const std::string& path) { |
| 32 | throw std::runtime_error("Not implemented"); |
| 33 | } |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 34 | |
Santosh Puranik | 3d7b4fe | 2020-04-02 23:27:22 +0530 | [diff] [blame^] | 35 | % for key in fruDict.keys(): |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 36 | <% |
| 37 | fru = fruDict[key] |
| 38 | %>\ |
| 39 | // Specialization of ${key} |
| 40 | template<> |
| 41 | void writeFru<Fru::${key}>(const Store& vpdStore, |
| 42 | const std::string& path) |
| 43 | { |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 44 | ObjectMap objects; |
| 45 | InterfaceMap interfaces; |
Deepak Kodihalli | 0cc2012 | 2017-02-21 03:35:20 -0600 | [diff] [blame] | 46 | auto iter = extra::objects.find(path); |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 47 | |
| 48 | // Inventory manager needs object path, list of interface names to be |
| 49 | // implemented, and property:value pairs contained in said interfaces |
| 50 | |
Santosh Puranik | 3d7b4fe | 2020-04-02 23:27:22 +0530 | [diff] [blame^] | 51 | % for interface, properties in fru.items(): |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 52 | <% |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 53 | names = interface.split(".") |
| 54 | intfName = names[0] + names[-1] |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 55 | %>\ |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 56 | PropertyMap ${intfName}Props; |
Marri Devender Rao | c74ca6c | 2017-08-20 01:22:34 -0500 | [diff] [blame] | 57 | % if properties: |
Santosh Puranik | 3d7b4fe | 2020-04-02 23:27:22 +0530 | [diff] [blame^] | 58 | % for name, value in properties.items(): |
Marri Devender Rao | c74ca6c | 2017-08-20 01:22:34 -0500 | [diff] [blame] | 59 | % if fru and interface and name and value: |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 60 | <% |
Deepak Kodihalli | db12d76 | 2017-09-11 23:04:33 -0500 | [diff] [blame] | 61 | record, keyword = name.split(",") |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 62 | %>\ |
Deepak Kodihalli | db12d76 | 2017-09-11 23:04:33 -0500 | [diff] [blame] | 63 | if (vpdStore.exists<Record::${record}, record::Keyword::${keyword}>()) |
| 64 | { |
| 65 | ${intfName}Props["${value}"] = |
| 66 | vpdStore.get<Record::${record}, record::Keyword::${keyword}>(); |
| 67 | } |
Marri Devender Rao | c74ca6c | 2017-08-20 01:22:34 -0500 | [diff] [blame] | 68 | % endif |
| 69 | % endfor |
| 70 | % endif |
Deepak Kodihalli | 0cc2012 | 2017-02-21 03:35:20 -0600 | [diff] [blame] | 71 | // Check and update extra properties |
| 72 | if(extra::objects.end() != iter) |
| 73 | { |
| 74 | auto propIter = (iter->second).find("${interface}"); |
| 75 | if((iter->second).end() != propIter) |
| 76 | { |
| 77 | for(const auto& map : propIter->second) |
| 78 | { |
| 79 | ${intfName}Props[map.first] = map.second; |
| 80 | } |
| 81 | } |
| 82 | } |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 83 | interfaces.emplace("${interface}", |
| 84 | std::move(${intfName}Props)); |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 85 | % endfor |
| 86 | |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 87 | sdbusplus::message::object_path object(path); |
Deepak Kodihalli | 128512b | 2017-02-17 03:12:08 -0600 | [diff] [blame] | 88 | // Check and update extra properties |
Deepak Kodihalli | 0cc2012 | 2017-02-21 03:35:20 -0600 | [diff] [blame] | 89 | if(extra::objects.end() != iter) |
Deepak Kodihalli | 128512b | 2017-02-17 03:12:08 -0600 | [diff] [blame] | 90 | { |
Deepak Kodihalli | 0cc2012 | 2017-02-21 03:35:20 -0600 | [diff] [blame] | 91 | for(const auto& entry : iter->second) |
Deepak Kodihalli | 128512b | 2017-02-17 03:12:08 -0600 | [diff] [blame] | 92 | { |
Deepak Kodihalli | 0cc2012 | 2017-02-21 03:35:20 -0600 | [diff] [blame] | 93 | if(interfaces.end() == interfaces.find(entry.first)) |
| 94 | { |
| 95 | interfaces.emplace(entry.first, entry.second); |
| 96 | } |
Deepak Kodihalli | 128512b | 2017-02-17 03:12:08 -0600 | [diff] [blame] | 97 | } |
| 98 | } |
Deepak Kodihalli | 4cf89a1 | 2017-02-06 05:06:48 -0600 | [diff] [blame] | 99 | objects.emplace(std::move(object), std::move(interfaces)); |
| 100 | |
| 101 | callPIM(std::move(objects)); |
Deepak Kodihalli | 8457f82 | 2016-11-29 06:05:39 -0600 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | % endfor |
| 105 | } // namespace inventory |
| 106 | } // namespace vpd |
| 107 | } // namespace openpower |