bmcweb: Fix Processor collection effiecent expand
Efficient expand on Processor Collection would return internal error if
GetSubTree response returned empty for processor interfaces and there
are no services to pull processor information from.
The fix here ensures that we return the response with Member count 0
when there are no processors.
Tested: Fabric BMC 0 processors - https://paste.googleplex.com/4639265592967168
Izumi BMC Multiple processors - https://paste.googleplex.com/6490857267003392
Google-Bug-Id: 283903536
Change-Id: I54999505dcdba42f39114859bedb8e10bdcec982
Signed-off-by: Rahul Kapoor <rahulkpr@google.com>
diff --git a/recipes-phosphor/interfaces/bmcweb/0001-Processor-Remove-redundant-dbus-calls-in-expand-path.patch b/recipes-phosphor/interfaces/bmcweb/0001-Processor-Remove-redundant-dbus-calls-in-expand-path.patch
index b7f8eaf..ea1a2c4 100644
--- a/recipes-phosphor/interfaces/bmcweb/0001-Processor-Remove-redundant-dbus-calls-in-expand-path.patch
+++ b/recipes-phosphor/interfaces/bmcweb/0001-Processor-Remove-redundant-dbus-calls-in-expand-path.patch
@@ -1,4 +1,4 @@
-From 2930520196e6cbce08bcddd609161039390dda8e Mon Sep 17 00:00:00 2001
+From 9251bb9059109593f07c7a0805f571bed19d2333 Mon Sep 17 00:00:00 2001
From: Rahul Kapoor <rahulkpr@google.com>
Date: Wed, 17 May 2023 08:53:28 +0000
Subject: [PATCH] Processor: Remove redundant dbus calls in expand path.
@@ -222,14 +222,15 @@
Change-Id: Ib3cf4a4a29abdee6d4bafcbbfd9402a1e69c6015
Signed-off-by: Rahul Kapoor <rahulkpr@google.com>
+
---
include/dbus_utility.hpp | 17 +
include/openbmc_dbus_rest.hpp | 4 +-
redfish-core/include/utils/collection.hpp | 53 +-
redfish-core/include/utils/dbus_utils.hpp | 150 ++
redfish-core/include/utils/location_utils.hpp | 38 +
- redfish-core/lib/processor.hpp | 2146 ++++++++---------
- 6 files changed, 1322 insertions(+), 1086 deletions(-)
+ redfish-core/lib/processor.hpp | 2147 ++++++++---------
+ 6 files changed, 1323 insertions(+), 1086 deletions(-)
diff --git a/include/dbus_utility.hpp b/include/dbus_utility.hpp
index b2788829..a89405b3 100644
@@ -238,7 +239,7 @@
@@ -171,6 +171,23 @@ inline void
interfaces);
}
-
+
+// Overload to support span of strings for interface names.
+inline void
+ getSubTree(const std::string& path, int32_t depth,
@@ -265,7 +266,7 @@
+++ b/include/openbmc_dbus_rest.hpp
@@ -1674,7 +1674,7 @@ inline void handleEnumerate(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
asyncResp->res.jsonValue["data"] = nlohmann::json::object();
-
+
dbus::utility::getSubTree(
- objectPath, 0, {},
+ objectPath, 0, std::span<const std::string_view>{},
@@ -279,7 +280,7 @@
- });
+ });
}
-
+
inline void handleGet(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
diff --git a/redfish-core/include/utils/collection.hpp b/redfish-core/include/utils/collection.hpp
index b5bf8466..9b431543 100644
@@ -290,7 +291,7 @@
#include <nlohmann/json.hpp>
#include <sdbusplus/asio/property.hpp>
+#include <utils/dbus_utils.hpp>
-
+
-#include <span>
#include <algorithm>
+#include <span>
@@ -300,7 +301,7 @@
@@ -21,6 +22,56 @@ namespace redfish
namespace collection_util
{
-
+
+/**
+ * @brief Populate the collection "Members" from given dbus subtree.
+ *
@@ -360,13 +361,13 @@
+++ b/redfish-core/include/utils/dbus_utils.hpp
@@ -1,9 +1,13 @@
#pragma once
-
+
+#include "dbus_utility.hpp"
#include "logging.hpp"
-
+
+#include <sdbusplus/message/native_types.hpp>
#include <sdbusplus/unpack_properties.hpp>
-
+
+#include <set>
+
namespace redfish
@@ -375,7 +376,7 @@
@@ -22,5 +26,151 @@ struct UnpackErrorPrinter
}
};
-
+
+inline void getPropertiesFromManagedObjects(
+ const dbus::utility::ManagedObjectType& managedObjects,
+ const std::string& objPath, const std::string& interface,
@@ -529,17 +530,17 @@
--- a/redfish-core/include/utils/location_utils.hpp
+++ b/redfish-core/include/utils/location_utils.hpp
@@ -7,6 +7,7 @@
-
+
#include <async_resp.hpp>
#include <sdbusplus/asio/property.hpp>
+#include <utils/dbus_utils.hpp>
-
+
#include <string>
#include <unordered_set>
@@ -219,5 +220,42 @@ inline void
std::move(upstreamChassisPaths), jsonPtr));
}
-
+
+/**
+ * @brief Fill out location code of a resource from given managed objects.
+ *
@@ -580,7 +581,7 @@
} // namespace location_util
} // namespace redfish
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
-index 837247bd..2db26a80 100644
+index 837247bd..7f5432ff 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -25,6 +25,7 @@
@@ -588,7 +589,7 @@
#include "utils/dbus_utils.hpp"
#include "utils/json_utils.hpp"
+#include "utils/location_utils.hpp"
-
+
#include <boost/container/flat_map.hpp>
#include <boost/system/error_code.hpp>
@@ -45,447 +46,523 @@ namespace redfish
@@ -607,7 +608,7 @@
+
+constexpr std::array<std::string_view, 1> subProcessorThreadInterfaces = {
+ "xyz.openbmc_project.Inventory.Item.CpuThread"};
-
+
inline void getSubProcessorThreadCollectionWithExpand(
const std::shared_ptr<bmcweb::AsyncResp>& aResp,
const nlohmann::json::json_pointer& jsonPtr, uint8_t expandLevel,
@@ -616,7 +617,7 @@
+ const std::string& corePath,
+ const dbus::utility::MapperGetSubTreeResponse& subtree,
+ const ManagedObjectByServiceMap& managedObjectsMap);
-
+
inline void getSubProcessorCoreCollectionWithExpand(
const std::shared_ptr<bmcweb::AsyncResp>& aResp,
const nlohmann::json::json_pointer& jsonPtr, uint8_t expandLevel,
@@ -624,13 +625,13 @@
+ const std::string& processorId, const std::string& cpuPath,
+ const dbus::utility::MapperGetSubTreeResponse& subtree,
+ const ManagedObjectByServiceMap& managedObjectsMap);
-
+
inline void getProcessorCollectionWithExpand(
- const std::shared_ptr<bmcweb::AsyncResp>& aResp, uint8_t expandLevel);
+ const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const dbus::utility::MapperGetSubTreeResponse& subtree,
+ const ManagedObjectByServiceMap& managedObjectsMap, uint8_t expandLevel);
-
+
-// Interfaces which imply a D-Bus object represents a Processor
-constexpr std::array<std::string_view, 2> processorInterfaces = {
- "xyz.openbmc_project.Inventory.Item.Cpu",
@@ -681,7 +682,7 @@
+ }
+ return {processorInterfaces.begin(), processorInterfaces.end()};
+}
-
+
/**
* @brief Fill out uuid info of a processor by
* requesting data from the given D-Bus object.
@@ -740,7 +741,7 @@
+ aResp->res.jsonValue[jsonPtr]["UUID"] = *property;
+ }
}
-
+
-inline void getCpuDataByInterface(
+/**
+ * @brief Populates Cpu information using given dbus properties.
@@ -759,11 +760,11 @@
{
- BMCWEB_LOG_DEBUG << "Get CPU resources by interface.";
+ BMCWEB_LOG_DEBUG << "Get CPU resources from dbus properties.";
-
+
// Set the default value of state
aResp->res.jsonValue[jsonPtr]["Status"]["State"] = "Enabled";
aResp->res.jsonValue[jsonPtr]["Status"]["Health"] = "OK";
-
+
- for (const auto& interface : cpuInterfacesProperties)
+ for (const auto& property : dbusProperties)
{
@@ -1068,7 +1069,7 @@
- "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+ }
}
-
+
-inline void getCpuAssetData(std::shared_ptr<bmcweb::AsyncResp> aResp,
- const std::string& service,
- const std::string& objPath,
@@ -1141,7 +1142,7 @@
+ dbus_utils::getPropertiesFromManagedObjects(
+ dbusData, object.first.str,
+ "xyz.openbmc_project.Inventory.Item", properties);
-
+
- if (serialNumber != nullptr && !serialNumber->empty())
- {
- aResp->res.jsonValue[jsonPtr]["SerialNumber"] = *serialNumber;
@@ -1177,7 +1178,7 @@
+ aResp->res.jsonValue[jsonPtr]["TotalCores"] = totalCores;
+ }
+}
-
+
- if (manufacturer != nullptr)
- {
- aResp->res.jsonValue[jsonPtr]["Manufacturer"] = *manufacturer;
@@ -1219,7 +1220,7 @@
+ messages::internalError(aResp->res);
+ return;
+ }
-
+
- // Otherwise would be unexpected.
- if (manufacturer->find("Intel") != std::string::npos)
- {
@@ -1237,7 +1238,7 @@
+ {
+ aResp->res.jsonValue[jsonPtr]["SerialNumber"] = *serialNumber;
+ }
-
+
- if (partNumber != nullptr)
+ if ((model != nullptr) && !model->empty())
+ {
@@ -1276,7 +1277,7 @@
+ aResp->res.jsonValue[jsonPtr]["SparePartNumber"] = *sparePartNumber;
+ }
}
-
+
-inline void getCpuRevisionData(std::shared_ptr<bmcweb::AsyncResp> aResp,
- const std::string& service,
- const std::string& objPath,
@@ -1314,15 +1315,15 @@
+ dbus::utility::DBusPropertiesMap properties;
+ dbus_utils::getPropertiesFromManagedObjects(managedObjects, objPath,
+ interface, properties);
-
+
- const std::string* version = nullptr;
+ const std::string* version = nullptr;
-
+
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), properties, "Version", version);
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), properties, "Version", version);
-
+
- if (!success)
- {
- messages::internalError(aResp->res);
@@ -1333,7 +1334,7 @@
+ messages::internalError(aResp->res);
+ return;
+ }
-
+
- if (version != nullptr)
- {
- aResp->res.jsonValue[jsonPtr]["Version"] = *version;
@@ -1344,7 +1345,7 @@
+ aResp->res.jsonValue[jsonPtr]["Version"] = *version;
+ }
}
-
+
-inline void getAcceleratorDataByService(
- std::shared_ptr<bmcweb::AsyncResp> aResp, const std::string& acclrtrId,
- const std::string& service, const std::string& objPath,
@@ -1381,19 +1382,19 @@
- messages::internalError(aResp->res);
- return;
- }
-
+
- const bool* functional = nullptr;
- const bool* present = nullptr;
+ const bool* functional = nullptr;
+ const bool* present = nullptr;
-
+
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), properties, "Functional",
- functional, "Present", present);
+ dbus::utility::DBusPropertiesMap properties;
+ dbus_utils::getPropertiesFromManagedObjects(managedObjects, objPath,
+ interface, properties);
-
+
- if (!success)
- {
- messages::internalError(aResp->res);
@@ -1402,7 +1403,7 @@
+ const bool success = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), properties, "Functional", functional,
+ "Present", present);
-
+
- std::string state = "Enabled";
- std::string health = "OK";
+ if (!success)
@@ -1410,7 +1411,7 @@
+ messages::internalError(aResp->res);
+ return;
+ }
-
+
- if (present != nullptr && !*present)
- {
- state = "Absent";
@@ -1422,7 +1423,7 @@
+ {
+ state = "Absent";
+ }
-
+
- if (functional != nullptr && !*functional)
+ if (functional != nullptr && !*functional)
+ {
@@ -1435,7 +1436,7 @@
+ health = "Critical";
}
+ }
-
+
- aResp->res.jsonValue[jsonPtr]["Id"] = acclrtrId;
- aResp->res.jsonValue[jsonPtr]["Name"] = "Processor";
- aResp->res.jsonValue[jsonPtr]["Status"]["State"] = state;
@@ -1448,7 +1449,7 @@
+ aResp->res.jsonValue[jsonPtr]["Status"]["Health"] = health;
+ aResp->res.jsonValue[jsonPtr]["ProcessorType"] = "Accelerator";
}
-
+
// OperatingConfig D-Bus Types
@@ -542,138 +619,138 @@ inline void highSpeedCoreIdsHandler(
* Fill out OperatingConfig related items in a Processor resource by requesting
@@ -1479,7 +1480,7 @@
+ const dbus::utility::ManagedObjectType& managedObjects)
{
BMCWEB_LOG_INFO << "Getting CPU operating configs for " << cpuId;
-
+
- // First, GetAll CurrentOperatingConfig properties on the object
- sdbusplus::asio::getAllProperties(
- *crow::connections::systemBus, service, objPath,
@@ -1537,18 +1538,18 @@
+ appliedOperatingConfig["@odata.id"] = uri;
+ json[jsonPtr]["AppliedOperatingConfig"] =
+ std::move(appliedOperatingConfig);
-
+
- nlohmann::json& json = aResp->res.jsonValue;
+ // Once we found the current applied config, read the base freq core ids
+ // out of Operating config.
-
+
- const sdbusplus::message::object_path* appliedConfig = nullptr;
- const bool* baseSpeedPriorityEnabled = nullptr;
+ dbus::utility::DBusPropertiesMap config;
+ dbus_utils::getPropertiesFromManagedObjects(
+ managedObjects, dbusPath,
+ "xyz.openbmc_project.Inventory.Item.Cpu.OperatingConfig", config);
-
+
- const bool success = sdbusplus::unpackPropertiesNoThrow(
- dbus_utils::UnpackErrorPrinter(), properties, "AppliedConfig",
- appliedConfig, "BaseSpeedPriorityEnabled",
@@ -1556,14 +1557,14 @@
+ const bool parseConfigSuccess = sdbusplus::unpackPropertiesNoThrow(
+ dbus_utils::UnpackErrorPrinter(), config,
+ "BaseSpeedPrioritySettings", baseSpeedList);
-
+
- if (!success)
+ if (!parseConfigSuccess)
{
messages::internalError(aResp->res);
return;
}
-
+
- if (appliedConfig != nullptr)
+ if (baseSpeedList != nullptr)
{
@@ -1616,7 +1617,7 @@
+ highSpeedCoreIdsHandler(aResp, jsonPtr, *baseSpeedList);
}
+ }
-
+
- if (baseSpeedPriorityEnabled != nullptr)
- {
- json[jsonPtr]["BaseSpeedPriorityState"] =
@@ -1629,7 +1630,7 @@
+ *baseSpeedPriorityEnabled ? "Enabled" : "Disabled";
+ }
}
-
+
/**
* Populate the unique identifier in a Processor resource by requesting data
* from the given D-Bus object.
@@ -1690,7 +1691,7 @@
+ ["ProtectedIdentificationNumber"] = *id;
+ }
}
-
+
inline void getCpuChassisAssociation(
@@ -686,7 +763,7 @@ inline void getCpuChassisAssociation(
sdbusplus::asio::getProperty<std::vector<std::string>>(
@@ -1708,12 +1709,12 @@
- });
+ });
}
-
+
/**
@@ -733,75 +810,75 @@ inline void getProcessorObject(const std::shared_ptr<bmcweb::AsyncResp>& resp,
{
BMCWEB_LOG_DEBUG << "Get available system processor resources.";
-
+
- // GetSubTree on all interfaces which provide info about a Processor
- constexpr std::array<std::string_view, 8> interfaces = {
- "xyz.openbmc_project.Common.UUID",
@@ -1767,7 +1768,7 @@
+ messages::internalError(resp->res);
+ return;
}
-
+
- bool found = false;
- // Filter out objects that don't have the CPU-specific
- // interfaces to make sure we can return 404 on non-CPUs
@@ -1787,7 +1788,7 @@
+ continue;
}
- }
-
+
- if (!found)
- {
- continue;
@@ -1816,7 +1817,7 @@
});
+ });
}
-
+
-inline void getProcessorData(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
- const nlohmann::json::json_pointer& jsonPtr,
- uint8_t expandLevel,
@@ -1848,7 +1849,7 @@
@@ -825,53 +903,78 @@ inline void getProcessorData(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
"SubProcessors");
}
-
+
+ // Get service to interface map for cpu
+ dbus::utility::MapperServiceMap serviceMap;
+ for (const auto& [parsedObjectPath, parsedServiceMap] : subtree)
@@ -1939,7 +1940,7 @@
@@ -885,9 +988,8 @@ inline void getProcessorData(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
continue;
}
-
+
- aResp->res
- .jsonValue[jsonPtr]["Location"]["PartLocation"]
- ["LocationType"] = *locationType;
@@ -1969,7 +1970,7 @@
"xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
@@ -940,7 +1043,8 @@ inline void
{
-
+
crow::connections::systemBus->async_method_call(
- [processorId, coreId, aResp, handler{std::forward<Handler>(handler)}](
+ [processorId, coreId, aResp{std::move(aResp)},
@@ -1979,7 +1980,7 @@
if (ec)
@@ -958,7 +1062,7 @@ inline void
}
-
+
crow::connections::systemBus->async_method_call(
- [processorId, coreId, aResp,
+ [processorId, coreId, aResp{std::move(aResp)},
@@ -2007,7 +2008,7 @@
@@ -1004,11 +1108,15 @@ inline void
std::array<const char*, 1>{"xyz.openbmc_project.Inventory.Item.Cpu"});
}
-
+
-inline void getCoreThreadDataByService(
- const std::shared_ptr<bmcweb::AsyncResp>& aResp,
- const nlohmann::json::json_pointer& jsonPtr, const std::string& processorId,
@@ -2028,7 +2029,7 @@
@@ -1024,67 +1132,87 @@ inline void getCoreThreadDataByService(
bool present = false;
bool functional = false;
-
+
- for (const auto& [interface, properties] : interfaceMap)
+ dbus::utility::MapperServiceMap serviceMap;
+ for (const auto& [parsedObjectPath, parsedServiceMap] : subtree)
@@ -2161,7 +2162,7 @@
@@ -1125,13 +1253,11 @@ inline void getSubProcessorThreadData(
boost::beast::http::field::link,
"</redfish/v1/JsonSchemas/Processor/Processor.json>; rel=describedby");
-
+
- crow::connections::systemBus->async_method_call(
- [aResp, processorId, coreId,
- threadId](const boost::system::error_code ec2,
@@ -2180,7 +2181,7 @@
@@ -1147,60 +1273,39 @@ inline void getSubProcessorThreadData(
return;
}
-
+
- for (const auto& [objectPath, serviceMap] : subtree)
- {
- if (sdbusplus::message::object_path(objectPath).filename() !=
@@ -2190,7 +2191,7 @@
- }
+ std::vector<std::string> serviceNames =
+ dbus_utils::getServiceNamesFromSubtree(subtree);
-
+
- if (serviceMap.empty())
+ sdbusplus::message::object_path path("/xyz/openbmc_project/inventory");
+ dbus_utils::getManagedObjectsInEachService(
@@ -2224,7 +2225,7 @@
- {
- continue;
- }
-
+
- getCoreThreadDataByService(aResp, ""_json_pointer,
- processorId, coreId,
- threadId, interfaces);
@@ -2243,7 +2244,7 @@
+ managedObjectsByService);
+ return;
+ }
-
+
- // Object not found
- messages::resourceNotFound(aResp->res, "#Processor.v1_11_0.Processor",
- threadId);
@@ -2260,11 +2261,11 @@
+ });
+ });
}
-
+
inline void getSubProcessorThreadMembers(
@@ -1247,12 +1352,12 @@ inline void getSubProcessorThreadMembers(
}
-
+
inline void
- getCpuCoreDataByService(const std::shared_ptr<bmcweb::AsyncResp>& aResp,
- const nlohmann::json::json_pointer& jsonPtr,
@@ -2297,7 +2298,7 @@
@@ -1285,67 +1390,92 @@ inline void
bool present = false;
bool functional = false;
-
+
- for (const auto& [interface, properties] : interfaceMap)
+ dbus::utility::MapperServiceMap serviceMap;
+ for (const auto& [parsedObjectPath, parsedServiceMap] : subtree)
@@ -2434,7 +2435,7 @@
}
@@ -1386,12 +1516,9 @@ inline void getSubProcessorCoreData(
"</redfish/v1/JsonSchemas/Processor/Processor.json>; rel=describedby");
-
+
crow::connections::systemBus->async_method_call(
- [aResp, processorId,
+ [aResp{std::move(aResp)}, processorId,
@@ -2450,7 +2451,7 @@
@@ -1407,56 +1534,37 @@ inline void getSubProcessorCoreData(
return;
}
-
+
- for (const auto& [objectPath, serviceMap] : subtree)
- {
- if (sdbusplus::message::object_path(objectPath).filename() !=
@@ -2460,7 +2461,7 @@
- }
+ std::vector<std::string> serviceNames =
+ dbus_utils::getServiceNamesFromSubtree(subtree);
-
+
- if (serviceMap.empty())
+ sdbusplus::message::object_path path("/xyz/openbmc_project/inventory");
+ dbus_utils::getManagedObjectsInEachService(
@@ -2488,7 +2489,7 @@
- {
- continue;
- }
-
+
- getCpuCoreDataByService(aResp, ""_json_pointer, 0,
- processorId, coreId,
- interfaces, objectPath);
@@ -2516,7 +2517,7 @@
+ objectPath, subtree, managedObjectsByService);
+ return;
+ }
-
+
- return;
- },
+ // Object not found
@@ -2574,7 +2575,7 @@
+ aResp->res.jsonValue[jsonPtr]["@odata.id"] = crow::utility::urlFromPieces(
+ "redfish", "v1", "Systems", "system", "Processors", processorId,
+ "SubProcessors", coreId, "SubProcessors");
-
+
- // Pointer to Container that maps thread ID to [threadObjectPath,
- // serviceMap]
- std::unique_ptr<resourceIdToSubtreeRespMapType>
@@ -2582,7 +2583,7 @@
+ // Maps thread ID to threadObjectPath
+ std::map<std::string, std::string, AlphanumLess<std::string>>
+ threadIdToObjectPath;
-
+
- for (const auto& [objectPath, serviceMap] : subtree)
+ for (const auto& [objectPath, serviceMap] : subtree)
+ {
@@ -2601,13 +2602,13 @@
+ const std::string& threadId = threadPath.filename();
+ threadIdToObjectPath.insert({threadId, threadPath});
+ }
-
+
- std::string subProcessorsPath =
- "/redfish/v1/Systems/system/Processors/" + processorId +
- "/SubProcessors/" + coreId + "/SubProcessors";
+ BMCWEB_LOG_DEBUG << "Core path: " << corePath
+ << " thread count: " << threadIdToObjectPath.size();
-
+
- // Get numerically sorted list of thread IDs
- std::sort((*threadsPtr).begin(), (*threadsPtr).end(),
- AlphanumLess<std::string>());
@@ -2619,7 +2620,7 @@
+ aResp->res.jsonValue[jsonPtr]["Members"] = nlohmann::json::array();
+ return;
+ }
-
+
- const auto serviceMapIter = (*threadIdToSubtreeRespMapPtr).begin();
- if (serviceMapIter == (*threadIdToSubtreeRespMapPtr).end())
+ size_t threadMemberCount = 0;
@@ -2732,7 +2733,7 @@
+ }
+ aResp->res.jsonValue[jsonPtr]["Members@odata.count"] = threadMemberCount;
}
-
+
inline void getSubProcessorCoreCollectionWithExpand(
const std::shared_ptr<bmcweb::AsyncResp>& aResp,
const nlohmann::json::json_pointer& jsonPtr, uint8_t expandLevel,
@@ -2774,14 +2775,14 @@
+ aResp->res.jsonValue[jsonPtr]["@odata.id"] = crow::utility::urlFromPieces(
+ "redfish", "v1", "Systems", "system", "Processors", processorId,
+ "SubProcessors");
-
+
- // Pointer to Vector that stores numerically sorted core IDs
- std::unique_ptr<std::vector<std::string>> coresPtr(
- new std::vector<std::string>);
+ // Maps core ID to coreObjectPath
+ std::map<std::string, std::string, AlphanumLess<std::string>>
+ coreIdToObjectPath;
-
+
- // Pointer to Container that maps core ID to [coreObjectPath,
- // serviceMap]
- std::unique_ptr<resourceIdToSubtreeRespMapType>
@@ -2804,7 +2805,7 @@
+ const std::string& coreId = corePath.filename();
+ coreIdToObjectPath.insert({coreId, objectPath});
+ }
-
+
- std::string subProcessorsPath =
- "/redfish/v1/Systems/system/Processors/" + processorId +
- "/SubProcessors";
@@ -2820,7 +2821,7 @@
+ aResp->res.jsonValue[jsonPtr]["Members"] = nlohmann::json::array();
+ return;
+ }
-
+
- const auto serviceMapIter = (*coreIdToSubtreeRespMapPtr).begin();
- if (serviceMapIter == (*coreIdToSubtreeRespMapPtr).end())
+ size_t coreMemberCount = 0;
@@ -2855,7 +2856,7 @@
}
+ coreMemberCount++;
+ }
-
+
- std::string serviceName = serviceMap.begin()->first;
-
- crow::connections::systemBus->async_method_call(
@@ -2929,7 +2930,7 @@
- dbusInterfaces);
+ aResp->res.jsonValue[jsonPtr]["Members@odata.count"] = coreMemberCount;
}
-
+
inline void getProcessorCollectionWithExpand(
- const std::shared_ptr<bmcweb::AsyncResp>& aResp, uint8_t expandLevel)
+ const std::shared_ptr<bmcweb::AsyncResp>& aResp,
@@ -2937,7 +2938,7 @@
+ const ManagedObjectByServiceMap& managedObjectsMap, uint8_t expandLevel)
{
+ BMCWEB_LOG_DEBUG << "Get processor collection with expand.";
-
+
- crow::connections::systemBus->async_method_call(
- [expandLevel,
- aResp{aResp}](const boost::system::error_code ec,
@@ -2965,7 +2966,7 @@
+ // Maps cpu ID to cpuObjectPath.
+ std::map<std::string, std::string, AlphanumLess<std::string>>
+ cpuNameToObjectPath;
-
+
- // Container to map cpu ID to [cpuObjectPath, serviceMap]
- std::unordered_map<
- std::string,
@@ -2997,7 +2998,7 @@
+ const std::string& cpuId = cpuPath.filename();
+ cpuNameToObjectPath.insert({cpuId, cpuPath});
+ }
-
+
- // Get numerically sorted list of cpu IDs
- std::sort(cpus.begin(), cpus.end(), AlphanumLess<std::string>());
+ // If no cpus found, return
@@ -3008,7 +3009,7 @@
+ aResp->res.jsonValue["Members"] = nlohmann::json::array();
+ return;
+ }
-
+
- size_t cpuMemberCount = 0;
- for (std::string& cpu : cpus)
- {
@@ -3030,7 +3031,7 @@
+ cpuNameToObjectPath[cpu], subtree, managedObjectsMap);
+ cpuMemberCount++;
+ }
-
+
- aResp->res.jsonValue["Members@odata.count"] = cpuMemberCount;
- aResp->res.jsonValue["Name"] = "Processor Collection";
- },
@@ -3045,7 +3046,7 @@
+ aResp->res.jsonValue["Members@odata.count"] = cpuMemberCount;
+ aResp->res.jsonValue["Name"] = "Processor Collection";
}
-
+
/**
@@ -2072,8 +1969,20 @@ inline void patchAppliedOperatingConfig(
const std::shared_ptr<bmcweb::AsyncResp>& resp,
@@ -3069,10 +3070,10 @@
// Check that the property even exists by checking for the interface
const std::string* controlService = nullptr;
for (const auto& [serviceName, interfaceList] : serviceMap)
-@@ -2214,6 +2123,102 @@ inline void handleProcessorCollectionHead(
+@@ -2214,6 +2123,103 @@ inline void handleProcessorCollectionHead(
"</redfish/v1/JsonSchemas/ProcessorCollection/ProcessorCollection.json>; rel=describedby");
}
-
+
+inline void parseSubtreeForProcessorCollection(
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const dbus::utility::MapperGetSubTreeResponse& subtree,
@@ -3095,7 +3096,8 @@
+ if (serviceNames.empty())
+ {
+ BMCWEB_LOG_DEBUG << "Can't retrieve service names from subtree";
-+ messages::internalError(asyncResp->res);
++ asyncResp->res.jsonValue["Members@odata.count"] = 0;
++ asyncResp->res.jsonValue["Members"] = nlohmann::json::array();
+ return;
+ }
+
@@ -3171,8 +3173,8 @@
+
inline void requestRoutesOperatingConfigCollection(App& app)
{
-
-@@ -2371,32 +2376,7 @@ inline void requestRoutesProcessorCollection(App& app)
+
+@@ -2371,32 +2377,7 @@ inline void requestRoutesProcessorCollection(App& app)
systemName);
return;
}
@@ -3205,4 +3207,4 @@
+ handleProcessorCollection(asyncResp, delegated);
});
}
-
+