| 
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,53 @@ 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 | +    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  | 
51 | 85 |     {  | 
52 |  | -        sdbusplus::message::object_path path(object);  | 
53 |  | -        std::string leaf = path.filename();  | 
54 |  | -        if (leaf.empty())  | 
 | 86 | +        for (const auto& object : objects)  | 
55 | 87 |         {  | 
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);  | 
57 | 95 |         }  | 
58 |  | -        pathNames.push_back(leaf);  | 
59 | 96 |     }  | 
 | 97 | + | 
60 | 98 |     std::ranges::sort(pathNames, AlphanumLess<std::string>());  | 
61 | 99 | 
 
  | 
62 | 100 |     nlohmann::json& members = asyncResp->res.jsonValue[jsonKeyName];  | 
 | 
0 commit comments