From 6eda7685694dca84db5a1b86b497c8d1e9fcbd06 Mon Sep 17 00:00:00 2001 From: "Kenny L. Ku" Date: Fri, 19 Jun 2020 09:48:36 -0700 Subject: Add Crashdump.Telemetry interface and trigger Tested: - Sent post requests Crashdump.OnDemand & Crashdump.Telemetry and correct trigger is received in crashdump application. - Redfish validator is run successfully. Signed-off-by: Kenny K. Ku Change-Id: Ie0f49d3230aeb4450e11dfa2d46e309946763a6a --- redfish-core/include/redfish.hpp | 1 + redfish-core/lib/log_services.hpp | 80 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp index bdff0355c0..303519bff5 100644 --- a/redfish-core/include/redfish.hpp +++ b/redfish-core/include/redfish.hpp @@ -131,6 +131,7 @@ class RedfishService nodes.emplace_back(std::make_unique(app)); nodes.emplace_back(std::make_unique(app)); nodes.emplace_back(std::make_unique(app)); + nodes.emplace_back(std::make_unique(app)); #ifdef BMCWEB_ENABLE_REDFISH_RAW_PECI nodes.emplace_back(std::make_unique(app)); #endif // BMCWEB_ENABLE_REDFISH_RAW_PECI diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp index 753334e3af..52a51a60b9 100644 --- a/redfish-core/lib/log_services.hpp +++ b/redfish-core/lib/log_services.hpp @@ -39,7 +39,6 @@ namespace redfish constexpr char const* crashdumpObject = "com.intel.crashdump"; constexpr char const* crashdumpPath = "/com/intel/crashdump"; -constexpr char const* crashdumpOnDemandPath = "/com/intel/crashdump/OnDemand"; constexpr char const* crashdumpInterface = "com.intel.crashdump"; constexpr char const* deleteAllInterface = "xyz.openbmc_project.Collection.DeleteAll"; @@ -47,6 +46,8 @@ constexpr char const* crashdumpOnDemandInterface = "com.intel.crashdump.OnDemand"; constexpr char const* crashdumpRawPECIInterface = "com.intel.crashdump.SendRawPeci"; +constexpr char const* crashdumpTelemetryInterface = + "com.intel.crashdump.Telemetry"; namespace message_registries { @@ -1980,7 +1981,10 @@ class CrashdumpService : public Node {"Oem", {{"#Crashdump.OnDemand", {{"target", "/redfish/v1/Systems/system/LogServices/Crashdump/" - "Actions/Oem/Crashdump.OnDemand"}}}}}}; + "Actions/Oem/Crashdump.OnDemand"}}}, + {"#Crashdump.Telemetry", + {{"target", "/redfish/v1/Systems/system/LogServices/Crashdump/" + "Actions/Oem/Crashdump.Telemetry"}}}}}}; #ifdef BMCWEB_ENABLE_REDFISH_RAW_PECI asyncResp->res.jsonValue["Actions"]["Oem"].push_back( @@ -2379,6 +2383,78 @@ class OnDemandCrashdump : public Node } }; +class TelemetryCrashdump : public Node +{ + public: + TelemetryCrashdump(CrowApp& app) : + Node(app, + "/redfish/v1/Systems/system/LogServices/Crashdump/Actions/Oem/" + "Crashdump.Telemetry/") + { + // Note: Deviated from redfish privilege registry for GET & HEAD + // method for security reasons. + entityPrivileges = { + {boost::beast::http::verb::get, {{"ConfigureComponents"}}}, + {boost::beast::http::verb::head, {{"ConfigureComponents"}}}, + {boost::beast::http::verb::patch, {{"ConfigureComponents"}}}, + {boost::beast::http::verb::put, {{"ConfigureComponents"}}}, + {boost::beast::http::verb::delete_, {{"ConfigureComponents"}}}, + {boost::beast::http::verb::post, {{"ConfigureComponents"}}}}; + } + + private: + void doPost(crow::Response& res, const crow::Request& req, + const std::vector& params) override + { + std::shared_ptr asyncResp = std::make_shared(res); + + auto generateTelemetryLogCallback = [asyncResp, req]( + const boost::system::error_code + ec, + const std::string& resp) { + if (ec) + { + if (ec.value() == boost::system::errc::operation_not_supported) + { + messages::resourceInStandby(asyncResp->res); + } + else if (ec.value() == + boost::system::errc::device_or_resource_busy) + { + messages::serviceTemporarilyUnavailable(asyncResp->res, + "60"); + } + else + { + messages::internalError(asyncResp->res); + } + return; + } + std::shared_ptr task = task::TaskData::createTask( + [](boost::system::error_code err, sdbusplus::message::message&, + const std::shared_ptr& taskData) { + if (!err) + { + taskData->messages.emplace_back( + messages::taskCompletedOK( + std::to_string(taskData->index))); + taskData->state = "Completed"; + } + return task::completed; + }, + "type='signal',interface='org.freedesktop.DBus.Properties'," + "member='PropertiesChanged',arg0namespace='com.intel." + "crashdump'"); + task->startTimer(std::chrono::minutes(5)); + task->populateResp(asyncResp->res); + task->payload.emplace(req); + }; + crow::connections::systemBus->async_method_call( + std::move(generateTelemetryLogCallback), crashdumpObject, + crashdumpPath, crashdumpTelemetryInterface, "GenerateTelemetryLog"); + } +}; + class SendRawPECI : public Node { public: -- cgit v1.2.3