Skip to content

Commit

Permalink
systems.hpp - initial multi-host implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mox669 committed Feb 27, 2024
1 parent 6b9ac4f commit 2b0ba60
Show file tree
Hide file tree
Showing 3 changed files with 596 additions and 157 deletions.
50 changes: 44 additions & 6 deletions redfish-core/include/utils/collection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

namespace redfish
Expand Down Expand Up @@ -47,16 +48,53 @@ inline void handleCollectionMembers(
}

std::vector<std::string> pathNames;
for (const auto& object : objects)

// add case for SystemsCollection since we want to store Systems members
// as "system0" to "systemN" instead of "chassis0" to "chassisN" or "host0"
// to "hostN" depending on which dbus interface we are using (currently
// using xyz.openbmc_project.State.Host, meaning "host0" to "hostN")
if (collectionPath == boost::urls::url("/redfish/v1/Systems"))
{
for (const auto& object : objects)
{
sdbusplus::message::object_path path(object);
/*BMCLOG*/ BMCWEB_LOG_DEBUG(
"handleComputerCollectionMembers path {}", std::string(path));
std::string leaf = path.filename();
if (leaf.empty())
{
continue;
}

if (leaf.find(/*"chassis"*/ "host") != std::string::npos)
{
leaf.erase(remove(leaf.begin(), leaf.end(), '\"'), leaf.end());
std::string computerSystemIndex = leaf.substr(
leaf.find(/*"chassis"*/ "host") + (leaf.length() - 1));

if (!computerSystemIndex.empty())
{
sdbusplus::message::object_path systemPath(
"/redfish/v1/Systems/system" + computerSystemIndex);
pathNames.push_back(systemPath.filename());
}
}
}
}
else
{
sdbusplus::message::object_path path(object);
std::string leaf = path.filename();
if (leaf.empty())
for (const auto& object : objects)
{
continue;
sdbusplus::message::object_path path(object);
std::string leaf = path.filename();
if (leaf.empty())
{
continue;
}
pathNames.push_back(leaf);
}
pathNames.push_back(leaf);
}

std::ranges::sort(pathNames, AlphanumLess<std::string>());

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

0 comments on commit 2b0ba60

Please sign in to comment.