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