Skip to content

Commit ea01c9b

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

File tree

3 files changed

+599
-159
lines changed

3 files changed

+599
-159
lines changed

redfish-core/include/utils/collection.hpp

Lines changed: 45 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,54 @@ 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+
57+
if (collectionPath == boost::urls::url("/redfish/v1/Systems"))
5158
{
52-
sdbusplus::message::object_path path(object);
53-
std::string leaf = path.filename();
54-
if (leaf.empty())
59+
for (const auto& object : objects)
5560
{
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+
}
5783
}
58-
pathNames.push_back(leaf);
5984
}
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+
6099
std::ranges::sort(pathNames, AlphanumLess<std::string>());
61100

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

0 commit comments

Comments
 (0)