bmcweb: Add/Move common typedefs to dbus utility
The following typedefs that are commonly used by redfish services
to get dbus subtree objects:
MapperServiceMap =
std::vector<std::pair<std::string, std::vector<std::string>>>
MapperGetSubTreeResponse =
std::vector<std::pair<std::string, MapperServiceMap>>
This commit adds the above mentioned typedefs to dbus utility namespace
and removes locally defined typedefs in processor.hpp.
Testing:
Validator: No errors
Few sample outputs from curl command:
$ curl -k -X GET https://{$bmc}/redfish/v1/Systems/system/Processors
{
"@odata.id": "/redfish/v1/Systems/system/Processors",
"@odata.type": "#ProcessorCollection.ProcessorCollection",
"Members": [
{
"@odata.id": "/redfish/v1/Systems/system/Processors/dcm0-cpu0"
},
{
"@odata.id": "/redfish/v1/Systems/system/Processors/dcm0-cpu1"
},
{
"@odata.id": "/redfish/v1/Systems/system/Processors/dcm1-cpu0"
},
{
"@odata.id": "/redfish/v1/Systems/system/Processors/dcm1-cpu1"
}
],
"Members@odata.count": 4,
"Name": "Processor Collection"
}
$ curl -k -X GET
https://{$bmc}/redfish/v1/Systems/system/Processors/dcm0-cpu0
{
"@odata.id": "/redfish/v1/Systems/system/Processors/dcm0-cpu0",
"@odata.type": "#Processor.v1_12_0.Processor",
"Id": "dcm0-cpu0",
"Location": {
"PartLocation": {
"ServiceLabel": "U78DA.ND0.WZS004K-P0-C15"
}
},
"LocationIndicatorActive": false,
"Manufacturer": "",
"MaxSpeedMHz": 0,
"Model": "5C67",
"Name": "PROCESSOR MODULE",
"PartNumber": "03JM290",
"ProcessorId": {
"EffectiveFamily": ""
},
"ProcessorType": "CPU",
"SerialNumber": "YA3936061828",
"Socket": "",
"SparePartNumber": "F210110",
"Status": {
"Health": "OK",
"State": "Enabled"
},
"SubProcessors": {
"@odata.id":
"/redfish/v1/Systems/system/Processors/dcm0-cpu0/SubProcessors"
},
"TotalCores": 8,
"TotalThreads": 0
}
$ curl -k -X GET
https://{$bmc}/redfish/v1/Systems/system/Processors/dcm0-cpu0/SubProcessors
{
"@odata.id":
"/redfish/v1/Systems/system/Processors/dcm0-cpu0/SubProcessors",
"@odata.type": "#ProcessorCollection.ProcessorCollection",
"Members": [],
"Members@odata.count": 0,
"Name": "SubProcessor Collection"
}
Signed-off-by: Shantappa Teekappanavar <sbteeks@yahoo.com>
Change-Id: I297c763af38fa5b13ef297e911b338f406b7c6e6
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index 1155000..af0fd12 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -36,14 +36,6 @@
std::string,
boost::container::flat_map<std::string, dbus::utility::DbusVariantType>>;
-// Map of service name to list of interfaces
-using MapperServiceMap =
- std::vector<std::pair<std::string, std::vector<std::string>>>;
-
-// Map of object paths to MapperServiceMaps
-using MapperGetSubTreeResponse =
- std::vector<std::pair<std::string, MapperServiceMap>>;
-
// Interfaces which imply a D-Bus object represents a Processor
constexpr std::array<const char*, 2> processorInterfaces = {
"xyz.openbmc_project.Inventory.Item.Cpu",
@@ -704,7 +696,7 @@
crow::connections::systemBus->async_method_call(
[resp, processorId, handler = std::forward<Handler>(handler)](
boost::system::error_code ec,
- const MapperGetSubTreeResponse& subtree) mutable {
+ const dbus::utility::MapperGetSubTreeResponse& subtree) mutable {
if (ec)
{
BMCWEB_LOG_DEBUG << "DBUS response error: " << ec;
@@ -768,7 +760,7 @@
inline void getProcessorData(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
const std::string& processorId,
const std::string& objectPath,
- const MapperServiceMap& serviceMap)
+ const dbus::utility::MapperServiceMap& serviceMap)
{
for (const auto& [serviceName, interfaceList] : serviceMap)
{
@@ -1008,7 +1000,8 @@
inline void patchAppliedOperatingConfig(
const std::shared_ptr<bmcweb::AsyncResp>& resp,
const std::string& processorId, const std::string& appliedConfigUri,
- const std::string& cpuObjectPath, const MapperServiceMap& serviceMap)
+ const std::string& cpuObjectPath,
+ const dbus::utility::MapperServiceMap& serviceMap)
{
// Check that the property even exists by checking for the interface
const std::string* controlService = nullptr;
@@ -1137,9 +1130,9 @@
// Ask for all objects implementing OperatingConfig so we can search
// for one with a matching name
crow::connections::systemBus->async_method_call(
- [asyncResp, cpuName, configName,
- reqUrl{req.url}](boost::system::error_code ec,
- const MapperGetSubTreeResponse& subtree) {
+ [asyncResp, cpuName, configName, reqUrl{req.url}](
+ boost::system::error_code ec,
+ const dbus::utility::MapperGetSubTreeResponse& subtree) {
if (ec)
{
BMCWEB_LOG_WARNING << "D-Bus error: " << ec << ", "
@@ -1258,7 +1251,7 @@
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& processorId,
const std::string& objectPath,
- const MapperServiceMap& serviceMap) {
+ const dbus::utility::MapperServiceMap& serviceMap) {
patchAppliedOperatingConfig(asyncResp, processorId,
appliedConfigUri,
objectPath, serviceMap);