Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions redfish-core/include/utils/get_chassis_names.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#pragma once

#include "dbus_singleton.hpp"

#include <boost/system/errc.hpp>
#include <boost/system/error_code.hpp>
#include <sdbusplus/message/native_types.hpp>

#include <array>
#include <string>
#include <utility>
#include <vector>

namespace redfish
{

namespace utils
{

template <typename F>
inline void getChassisNames(F&& cb)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add this function in redfish-core/include/utils/chassis_utils.hpp, and make the function without template ?

inline void getChassisNames(const boost::system::error_code& ec, 
                const std::vector<std::string>& chassisNames)
{
...
}

{
const std::array<const char*, 1> interfaces = {
"xyz.openbmc_project.Inventory.Item.Chassis"};

crow::connections::systemBus->async_method_call(
[callback = std::forward<F>(
cb)](const boost::system::error_code ec,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const boost::system::error_code& ec

const std::vector<std::string>& chassis) {
std::vector<std::string> chassisNames;

if (ec)
{
callback(ec, chassisNames);
return;
}

chassisNames.reserve(chassis.size());
for (const std::string& path : chassis)
{
sdbusplus::message::object_path dbusPath = path;
std::string name = dbusPath.filename();
if (name.empty())
{
callback(boost::system::errc::make_error_code(
boost::system::errc::invalid_argument),
chassisNames);
return;
}
chassisNames.emplace_back(std::move(name));
}

callback(ec, chassisNames);
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTreePaths",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbus::utility::getSubTreePaths()

"/xyz/openbmc_project/inventory", 0, interfaces);
}

} // namespace utils

} // namespace redfish
2 changes: 2 additions & 0 deletions redfish-core/include/utils/telemetry_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ namespace telemetry
constexpr const char* service = "xyz.openbmc_project.Telemetry";
constexpr const char* reportInterface = "xyz.openbmc_project.Telemetry.Report";

constexpr const char* metricDefinitionUri =
"/redfish/v1/TelemetryService/MetricDefinitions/";
inline std::string getDbusReportPath(std::string_view id)
{
sdbusplus::message::object_path reportsPath(
Expand Down
Loading