blob: 7ca72f65d61fa058e17fc82728940e4577cc110a [file] [log] [blame]
SunnySrivastava1984b59fd092020-02-03 09:58:56 -06001#include <algorithm>
2#include <com/ibm/VPD/Manager/server.hpp>
3#include <com/ibm/VPD/error.hpp>
4#include <map>
5#include <sdbusplus/exception.hpp>
6#include <sdbusplus/sdbus.hpp>
SunnySrivastava19849a195542020-09-07 06:04:50 -05007#include <sdbusplus/sdbuspp_support/server.hpp>
SunnySrivastava1984b59fd092020-02-03 09:58:56 -06008#include <sdbusplus/server.hpp>
9#include <string>
10#include <tuple>
SunnySrivastava1984b59fd092020-02-03 09:58:56 -060011#include <xyz/openbmc_project/Common/error.hpp>
12
13namespace sdbusplus
14{
15namespace com
16{
17namespace ibm
18{
19namespace VPD
20{
21namespace server
22{
23
24Manager::Manager(bus::bus& bus, const char* path) :
25 _com_ibm_VPD_Manager_interface(bus, path, interface, _vtable, this),
26 _intf(bus.getInterface())
27{
28}
29
30int Manager::_callback_WriteKeyword(sd_bus_message* msg, void* context,
31 sd_bus_error* error)
32{
SunnySrivastava19849a195542020-09-07 06:04:50 -050033 auto o = static_cast<Manager*>(context);
34
SunnySrivastava1984b59fd092020-02-03 09:58:56 -060035 try
36 {
SunnySrivastava19849a195542020-09-07 06:04:50 -050037 return sdbusplus::sdbuspp::method_callback(
38 msg, o->_intf, error,
39 std::function([=](sdbusplus::message::object_path&& path,
40 std::string&& record, std::string&& keyword,
41 std::vector<uint8_t>&& value) {
42 return o->writeKeyword(path, record, keyword, value);
43 }));
SunnySrivastava1984b59fd092020-02-03 09:58:56 -060044 }
45 catch (sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument& e)
46 {
SunnySrivastava19849a195542020-09-07 06:04:50 -050047 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
SunnySrivastava1984b59fd092020-02-03 09:58:56 -060048 }
49 catch (sdbusplus::com::ibm::VPD::Error::PathNotFound& e)
50 {
SunnySrivastava19849a195542020-09-07 06:04:50 -050051 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
SunnySrivastava1984b59fd092020-02-03 09:58:56 -060052 }
53 catch (sdbusplus::com::ibm::VPD::Error::RecordNotFound& e)
54 {
SunnySrivastava19849a195542020-09-07 06:04:50 -050055 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
SunnySrivastava1984b59fd092020-02-03 09:58:56 -060056 }
57 catch (sdbusplus::com::ibm::VPD::Error::KeywordNotFound& e)
58 {
SunnySrivastava19849a195542020-09-07 06:04:50 -050059 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
SunnySrivastava1984b59fd092020-02-03 09:58:56 -060060 }
61
SunnySrivastava19849a195542020-09-07 06:04:50 -050062 return 0;
SunnySrivastava1984b59fd092020-02-03 09:58:56 -060063}
64
65namespace details
66{
67namespace Manager
68{
69static const auto _param_WriteKeyword = utility::tuple_to_array(
70 message::types::type_id<sdbusplus::message::object_path, std::string,
71 std::string, std::vector<uint8_t>>());
72static const auto _return_WriteKeyword =
73 utility::tuple_to_array(std::make_tuple('\0'));
74} // namespace Manager
75} // namespace details
76
77int Manager::_callback_GetFRUsByUnexpandedLocationCode(sd_bus_message* msg,
78 void* context,
79 sd_bus_error* error)
80{
SunnySrivastava19849a195542020-09-07 06:04:50 -050081 auto o = static_cast<Manager*>(context);
82
SunnySrivastava1984b59fd092020-02-03 09:58:56 -060083 try
84 {
SunnySrivastava19849a195542020-09-07 06:04:50 -050085 return sdbusplus::sdbuspp::method_callback(
86 msg, o->_intf, error,
87 std::function(
88 [=](std::string&& locationCode, uint16_t&& nodeNumber) {
89 return o->getFRUsByUnexpandedLocationCode(locationCode,
90 nodeNumber);
91 }));
SunnySrivastava1984b59fd092020-02-03 09:58:56 -060092 }
93 catch (sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument& e)
94 {
SunnySrivastava19849a195542020-09-07 06:04:50 -050095 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
SunnySrivastava1984b59fd092020-02-03 09:58:56 -060096 }
97 catch (sdbusplus::com::ibm::VPD::Error::LocationNotFound& e)
98 {
SunnySrivastava19849a195542020-09-07 06:04:50 -050099 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600100 }
101 catch (sdbusplus::com::ibm::VPD::Error::NodeNotFound& e)
102 {
SunnySrivastava19849a195542020-09-07 06:04:50 -0500103 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600104 }
105
SunnySrivastava19849a195542020-09-07 06:04:50 -0500106 return 0;
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600107}
108
109namespace details
110{
111namespace Manager
112{
113static const auto _param_GetFRUsByUnexpandedLocationCode =
114 utility::tuple_to_array(message::types::type_id<std::string, uint16_t>());
115static const auto _return_GetFRUsByUnexpandedLocationCode =
116 utility::tuple_to_array(message::types::type_id<
117 std::vector<sdbusplus::message::object_path>>());
118} // namespace Manager
119} // namespace details
120
121int Manager::_callback_GetFRUsByExpandedLocationCode(sd_bus_message* msg,
122 void* context,
123 sd_bus_error* error)
124{
SunnySrivastava19849a195542020-09-07 06:04:50 -0500125 auto o = static_cast<Manager*>(context);
126
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600127 try
128 {
SunnySrivastava19849a195542020-09-07 06:04:50 -0500129 return sdbusplus::sdbuspp::method_callback(
130 msg, o->_intf, error,
131 std::function([=](std::string&& locationCode) {
132 return o->getFRUsByExpandedLocationCode(locationCode);
133 }));
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600134 }
135 catch (sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument& e)
136 {
SunnySrivastava19849a195542020-09-07 06:04:50 -0500137 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600138 }
139 catch (sdbusplus::com::ibm::VPD::Error::LocationNotFound& e)
140 {
SunnySrivastava19849a195542020-09-07 06:04:50 -0500141 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600142 }
143 catch (sdbusplus::com::ibm::VPD::Error::NodeNotFound& e)
144 {
SunnySrivastava19849a195542020-09-07 06:04:50 -0500145 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600146 }
147
SunnySrivastava19849a195542020-09-07 06:04:50 -0500148 return 0;
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600149}
150
151namespace details
152{
153namespace Manager
154{
155static const auto _param_GetFRUsByExpandedLocationCode =
156 utility::tuple_to_array(message::types::type_id<std::string>());
157static const auto _return_GetFRUsByExpandedLocationCode =
158 utility::tuple_to_array(message::types::type_id<
159 std::vector<sdbusplus::message::object_path>>());
160} // namespace Manager
161} // namespace details
162
163int Manager::_callback_GetExpandedLocationCode(sd_bus_message* msg,
164 void* context,
165 sd_bus_error* error)
166{
SunnySrivastava19849a195542020-09-07 06:04:50 -0500167 auto o = static_cast<Manager*>(context);
168
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600169 try
170 {
SunnySrivastava19849a195542020-09-07 06:04:50 -0500171 return sdbusplus::sdbuspp::method_callback(
172 msg, o->_intf, error,
173 std::function(
174 [=](std::string&& locationCode, uint16_t&& nodeNumber) {
175 return o->getExpandedLocationCode(locationCode, nodeNumber);
176 }));
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600177 }
178 catch (sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument& e)
179 {
SunnySrivastava19849a195542020-09-07 06:04:50 -0500180 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600181 }
182 catch (sdbusplus::com::ibm::VPD::Error::LocationNotFound& e)
183 {
SunnySrivastava19849a195542020-09-07 06:04:50 -0500184 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600185 }
186 catch (sdbusplus::com::ibm::VPD::Error::NodeNotFound& e)
187 {
SunnySrivastava19849a195542020-09-07 06:04:50 -0500188 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600189 }
190
SunnySrivastava19849a195542020-09-07 06:04:50 -0500191 return 0;
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600192}
193
194namespace details
195{
196namespace Manager
197{
198static const auto _param_GetExpandedLocationCode =
199 utility::tuple_to_array(message::types::type_id<std::string, uint16_t>());
200static const auto _return_GetExpandedLocationCode =
201 utility::tuple_to_array(message::types::type_id<std::string>());
202} // namespace Manager
203} // namespace details
204
SunnySrivastava19849a195542020-09-07 06:04:50 -0500205int Manager::_callback_PerformVPDRecollection(sd_bus_message* msg,
206 void* context,
207 sd_bus_error* error)
208{
209 auto o = static_cast<Manager*>(context);
210
211 try
212 {
213 return sdbusplus::sdbuspp::method_callback(
214 msg, o->_intf, error,
215 std::function([=]() { return o->performVPDRecollection(); }));
216 }
217 catch (sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument& e)
218 {
219 return o->_intf->sd_bus_error_set(error, e.name(), e.description());
220 }
221
222 return 0;
223}
224
225namespace details
226{
227namespace Manager
228{
229static const auto _param_PerformVPDRecollection =
230 utility::tuple_to_array(std::make_tuple('\0'));
231static const auto _return_PerformVPDRecollection =
232 utility::tuple_to_array(std::make_tuple('\0'));
233} // namespace Manager
234} // namespace details
235
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600236const vtable::vtable_t Manager::_vtable[] = {
237 vtable::start(),
238
239 vtable::method("WriteKeyword", details::Manager::_param_WriteKeyword.data(),
240 details::Manager::_return_WriteKeyword.data(),
241 _callback_WriteKeyword),
242
243 vtable::method(
244 "GetFRUsByUnexpandedLocationCode",
245 details::Manager::_param_GetFRUsByUnexpandedLocationCode.data(),
246 details::Manager::_return_GetFRUsByUnexpandedLocationCode.data(),
247 _callback_GetFRUsByUnexpandedLocationCode),
248
249 vtable::method(
250 "GetFRUsByExpandedLocationCode",
251 details::Manager::_param_GetFRUsByExpandedLocationCode.data(),
252 details::Manager::_return_GetFRUsByExpandedLocationCode.data(),
253 _callback_GetFRUsByExpandedLocationCode),
254
255 vtable::method("GetExpandedLocationCode",
256 details::Manager::_param_GetExpandedLocationCode.data(),
257 details::Manager::_return_GetExpandedLocationCode.data(),
258 _callback_GetExpandedLocationCode),
SunnySrivastava19849a195542020-09-07 06:04:50 -0500259
260 vtable::method("PerformVPDRecollection",
261 details::Manager::_param_PerformVPDRecollection.data(),
262 details::Manager::_return_PerformVPDRecollection.data(),
263 _callback_PerformVPDRecollection),
SunnySrivastava1984b59fd092020-02-03 09:58:56 -0600264 vtable::end()};
265
266} // namespace server
267} // namespace VPD
268} // namespace ibm
269} // namespace com
270} // namespace sdbusplus