|
13 | 13 | #include <span>
|
14 | 14 | #include <string>
|
15 | 15 | #include <string_view>
|
| 16 | +#include <utility> |
16 | 17 | #include <vector>
|
17 | 18 |
|
18 | 19 | namespace redfish
|
@@ -47,16 +48,54 @@ inline void handleCollectionMembers(
|
47 | 48 | }
|
48 | 49 |
|
49 | 50 | std::vector<std::string> pathNames;
|
50 |
| - for (const auto& object : objects) |
| 51 | + |
| 52 | + // add case for SystemsCollection since we want to store Systems members |
| 53 | + // as "system0" to "systemN" instead of "chassis0" to "chassisN" or "host0" |
| 54 | + // to "hostN" depending on which dbus interface we are using (currently |
| 55 | + // using xyz.openbmc_project.State.Host, meaning "host0" to "hostN") |
| 56 | + |
| 57 | + if (collectionPath == boost::urls::url("/redfish/v1/Systems")) |
51 | 58 | {
|
52 |
| - sdbusplus::message::object_path path(object); |
53 |
| - std::string leaf = path.filename(); |
54 |
| - if (leaf.empty()) |
| 59 | + for (const auto& object : objects) |
55 | 60 | {
|
56 |
| - continue; |
| 61 | + sdbusplus::message::object_path path(object); |
| 62 | + /*BMCLOG*/ BMCWEB_LOG_DEBUG( |
| 63 | + "handleComputerCollectionMembers path {}", std::string(path)); |
| 64 | + std::string leaf = path.filename(); |
| 65 | + if (leaf.empty()) |
| 66 | + { |
| 67 | + continue; |
| 68 | + } |
| 69 | + |
| 70 | + if (leaf.find(/*"chassis"*/ "host") != std::string::npos) |
| 71 | + { |
| 72 | + leaf.erase(remove(leaf.begin(), leaf.end(), '\"'), leaf.end()); |
| 73 | + std::string computerSystemIndex = leaf.substr( |
| 74 | + leaf.find(/*"chassis"*/ "host") + (leaf.length() - 1)); |
| 75 | + |
| 76 | + if (!computerSystemIndex.empty()) |
| 77 | + { |
| 78 | + sdbusplus::message::object_path systemPath( |
| 79 | + "/redfish/v1/Systems/system" + computerSystemIndex); |
| 80 | + pathNames.push_back(systemPath.filename()); |
| 81 | + } |
| 82 | + } |
57 | 83 | }
|
58 |
| - pathNames.push_back(leaf); |
59 | 84 | }
|
| 85 | + else |
| 86 | + { |
| 87 | + for (const auto& object : objects) |
| 88 | + { |
| 89 | + sdbusplus::message::object_path path(object); |
| 90 | + std::string leaf = path.filename(); |
| 91 | + if (leaf.empty()) |
| 92 | + { |
| 93 | + continue; |
| 94 | + } |
| 95 | + pathNames.push_back(leaf); |
| 96 | + } |
| 97 | + } |
| 98 | + |
60 | 99 | std::ranges::sort(pathNames, AlphanumLess<std::string>());
|
61 | 100 |
|
62 | 101 | nlohmann::json& members = asyncResp->res.jsonValue[jsonKeyName];
|
|
0 commit comments