Manager: add ManagerDiagnosticData handler
This change adds a link in the Manager for all BMCs to an empty
ManagerDiagnosticData resource and a minimum ManagerDiagnosticData
handler.
This service is backed by phosphor-health-monitor (PHM), which is
enabled by default through the "obmc-apps" package group. If PHM is
disabled, the resource will be empty.
$ curl http://${bmc}:10080/redfish/v1/Managers/bmc/ManagerDiagnosticData
{
"@odata.id": "/redfish/v1/Managers/bmc/ManagerDiagnosticData",
"@odata.type": "#ManagerDiagnosticData.v1_0_0.ManagerDiagnosticData",
"Id": "ManagerDiagnosticData",
"Name": "Manager Diagnostic Data"
}
Also ran the Redfish Service Validator to make sure no new errors are
introduced with the introduction of ManagerDiagnosticData.
Signed-off-by: Sui Chen <suichen@google.com>
Change-Id: Iba242bc3b6ebec851dbd26e149d5c92c19a7992e
diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp
index 8c05dd7..ab635f9 100644
--- a/redfish-core/include/redfish.hpp
+++ b/redfish-core/include/redfish.hpp
@@ -24,6 +24,7 @@
#include "../lib/event_service.hpp"
#include "../lib/hypervisor_system.hpp"
#include "../lib/log_services.hpp"
+#include "../lib/manager_diagnostic_data.hpp"
#include "../lib/managers.hpp"
#include "../lib/memory.hpp"
#include "../lib/message_registries.hpp"
@@ -80,6 +81,7 @@
requestRoutesManagerResetAction(app);
requestRoutesManagerResetActionInfo(app);
requestRoutesManagerResetToDefaultsAction(app);
+ requestRoutesManagerDiagnosticData(app);
requestRoutesChassisCollection(app);
requestRoutesChassis(app);
requestRoutesChassisResetAction(app);
diff --git a/redfish-core/lib/manager_diagnostic_data.hpp b/redfish-core/lib/manager_diagnostic_data.hpp
new file mode 100644
index 0000000..f4d1698
--- /dev/null
+++ b/redfish-core/lib/manager_diagnostic_data.hpp
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <app.hpp>
+#include <async_resp.hpp>
+#include <http_request.hpp>
+#include <nlohmann/json.hpp>
+#include <privileges.hpp>
+#include <routing.hpp>
+
+#include <string>
+
+namespace redfish
+{
+
+/**
+ * handleManagerDiagnosticData supports ManagerDiagnosticData.
+ * It retrieves BMC health information from various DBus resources and returns
+ * the information through the response.
+ */
+inline void handleManagerDiagnosticDataGet(
+ crow::App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
+{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ManagerDiagnosticData.v1_0_0.ManagerDiagnosticData";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Managers/bmc/ManagerDiagnosticData";
+ asyncResp->res.jsonValue["Id"] = "ManagerDiagnosticData";
+ asyncResp->res.jsonValue["Name"] = "Manager Diagnostic Data";
+}
+
+inline void requestRoutesManagerDiagnosticData(App& app)
+{
+ BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/ManagerDiagnosticData")
+ .privileges(redfish::privileges::getManagerDiagnosticData)
+ .methods(boost::beast::http::verb::get)(
+ std::bind_front(handleManagerDiagnosticDataGet, std::ref(app)));
+}
+
+} // namespace redfish
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 039fced..52a3c85 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -15,17 +15,17 @@
*/
#pragma once
+#include "app.hpp"
+#include "dbus_utility.hpp"
#include "health.hpp"
+#include "query.hpp"
#include "redfish_util.hpp"
+#include "registries/privilege_registry.hpp"
+#include "utils/sw_utils.hpp"
+#include "utils/systemd_utils.hpp"
-#include <app.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/date_time.hpp>
-#include <dbus_utility.hpp>
-#include <query.hpp>
-#include <registries/privilege_registry.hpp>
-#include <utils/sw_utils.hpp>
-#include <utils/systemd_utils.hpp>
#include <cstdint>
#include <memory>
@@ -1954,7 +1954,7 @@
return;
}
asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers/bmc";
- asyncResp->res.jsonValue["@odata.type"] = "#Manager.v1_11_0.Manager";
+ asyncResp->res.jsonValue["@odata.type"] = "#Manager.v1_14_0.Manager";
asyncResp->res.jsonValue["Id"] = "bmc";
asyncResp->res.jsonValue["Name"] = "OpenBmc Manager";
asyncResp->res.jsonValue["Description"] =
@@ -2054,6 +2054,12 @@
managerGetLastResetTime(asyncResp);
+ // ManagerDiagnosticData is added for all BMCs.
+ nlohmann::json& managerDiagnosticData =
+ asyncResp->res.jsonValue["ManagerDiagnosticData"];
+ managerDiagnosticData["@odata.id"] =
+ "/redfish/v1/Managers/bmc/ManagerDiagnosticData";
+
auto pids = std::make_shared<GetPIDValues>(asyncResp);
pids->run();