Skip to content

Commit 2b0ba60

Browse files
committed
systems.hpp - initial multi-host implementation
1 parent 6b9ac4f commit 2b0ba60

File tree

3 files changed

+596
-157
lines changed

3 files changed

+596
-157
lines changed

redfish-core/include/utils/collection.hpp

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <span>
1414
#include <string>
1515
#include <string_view>
16+
#include <utility>
1617
#include <vector>
1718

1819
namespace redfish
@@ -47,16 +48,53 @@ inline void handleCollectionMembers(
4748
}
4849

4950
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+
if (collectionPath == boost::urls::url("/redfish/v1/Systems"))
57+
{
58+
for (const auto& object : objects)
59+
{
60+
sdbusplus::message::object_path path(object);
61+
/*BMCLOG*/ BMCWEB_LOG_DEBUG(
62+
"handleComputerCollectionMembers path {}", std::string(path));
63+
std::string leaf = path.filename();
64+
if (leaf.empty())
65+
{
66+
continue;
67+
}
68+
69+
if (leaf.find(/*"chassis"*/ "host") != std::string::npos)
70+
{
71+
leaf.erase(remove(leaf.begin(), leaf.end(), '\"'), leaf.end());
72+
std::string computerSystemIndex = leaf.substr(
73+
leaf.find(/*"chassis"*/ "host") + (leaf.length() - 1));
74+
75+
if (!computerSystemIndex.empty())
76+
{
77+
sdbusplus::message::object_path systemPath(
78+
"/redfish/v1/Systems/system" + computerSystemIndex);
79+
pathNames.push_back(systemPath.filename());
80+
}
81+
}
82+
}
83+
}
84+
else
5185
{
52-
sdbusplus::message::object_path path(object);
53-
std::string leaf = path.filename();
54-
if (leaf.empty())
86+
for (const auto& object : objects)
5587
{
56-
continue;
88+
sdbusplus::message::object_path path(object);
89+
std::string leaf = path.filename();
90+
if (leaf.empty())
91+
{
92+
continue;
93+
}
94+
pathNames.push_back(leaf);
5795
}
58-
pathNames.push_back(leaf);
5996
}
97+
6098
std::ranges::sort(pathNames, AlphanumLess<std::string>());
6199

62100
nlohmann::json& members = asyncResp->res.jsonValue[jsonKeyName];

0 commit comments

Comments
 (0)