From 1fc0d70f658da30091bcd49f9bf29aecd6b99ba7 Mon Sep 17 00:00:00 2001 From: "Jason M. Bills" Date: Thu, 6 Jan 2022 13:50:19 -0800 Subject: Update to internal 0.86 Signed-off-by: Jason M. Bills --- ...001-Firmware-update-configuration-changes.patch | 72 +-- ...uting-logic-into-host-console-connection-.patch | 2 +- ...Add-state-sensor-messages-to-the-registry.patch | 14 +- ...registry-for-subscription-related-actions.patch | 10 +- ...b-Add-BMC-Time-update-log-to-the-registry.patch | 12 +- ...-Add-generic-message-PropertySizeExceeded.patch | 25 +- ...-registry-entry-for-FirmwareResiliencyErr.patch | 84 ---- .../bmcweb/0024-Add-count-sensor-type.patch | 10 +- ...5-Add-Model-CoreCount-to-ProcessorSummary.patch | 288 +++++++++++ ...-Define-Redfish-interface-Registries-Bios.patch | 260 +++++----- .../0003-Add-support-to-ResetBios-action.patch | 64 +-- ...0004-Add-support-to-ChangePassword-action.patch | 39 +- ...fix-for-broken-feature-Pending-Attributes.patch | 149 +++--- ...d-unmerged-changes-for-http-retry-support.patch | 121 +++++ ...ervice-Fix-retry-handling-for-http-client.patch | 546 --------------------- .../0002-EventService-https-client-support.patch | 166 ++++--- .../0004-Add-Server-Sent-Events-support.patch | 56 +-- ...tyle-subscription-support-to-eventservice.patch | 50 +- .../0006-Add-EventService-SSE-filter-support.patch | 18 +- ...010-Remove-Terminated-Event-Subscriptions.patch | 34 +- ...h-while-deleting-terminated-subscriptions.patch | 141 ++++++ .../interfaces/bmcweb/eventservice/README | 28 +- ...dd-asyncResp-support-during-handleUpgrade.patch | 202 ++++++++ .../0002-Move-privileges-to-separate-entity.patch | 109 ++++ ...port-for-privilege-check-in-handleUpgrade.patch | 218 ++++++++ .../0004-Add-Privileges-to-Websockets.patch | 140 ++++++ .../0005-Add-Privileges-to-SseSockets.patch | 63 +++ ...1-Add-support-for-MetricDefinition-scheme.patch | 489 +++++++++++------- ...2-Sync-Telmetry-service-with-EventService.patch | 9 +- ...d-bmcweb-to-use-new-telemetry-service-API.patch | 2 +- ...MetricDefinition-property-in-MetricReport.patch | 21 +- ...t-Remove-LogService-from-TelemetryService.patch | 22 +- ...eneralize-ReadingType-in-MetricDefinition.patch | 93 ---- .../interfaces/bmcweb/telemetry/README | 8 +- ...1-Revert-Disable-nbd-proxy-from-the-build.patch | 26 +- ...edVia-property-to-virtual-media-item-temp.patch | 10 +- .../recipes-phosphor/interfaces/bmcweb_%.bbappend | 21 +- 37 files changed, 2194 insertions(+), 1428 deletions(-) delete mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0021-Add-message-registry-entry-for-FirmwareResiliencyErr.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0025-Add-Model-CoreCount-to-ProcessorSummary.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0001-Add-unmerged-changes-for-http-retry-support.patch delete mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0001-EventService-Fix-retry-handling-for-http-client.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0011-Fix-bmcweb-crash-while-deleting-terminated-subscriptions.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0001-Add-asyncResp-support-during-handleUpgrade.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0002-Move-privileges-to-separate-entity.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0003-Add-Support-for-privilege-check-in-handleUpgrade.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0004-Add-Privileges-to-Websockets.patch create mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0005-Add-Privileges-to-SseSockets.patch delete mode 100644 meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0008-Generalize-ReadingType-in-MetricDefinition.patch (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/interfaces') diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0001-Firmware-update-configuration-changes.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0001-Firmware-update-configuration-changes.patch index b689748ea..6621d2512 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0001-Firmware-update-configuration-changes.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0001-Firmware-update-configuration-changes.patch @@ -1,4 +1,4 @@ -From c65d6f4a6d2939335608957fba25e5c8a445813e Mon Sep 17 00:00:00 2001 +From 7c005c318a12c53ed887b3081bd4b34ea0213053 Mon Sep 17 00:00:00 2001 From: Vikram Bodireddy Date: Mon, 28 Jun 2021 21:56:18 +0530 Subject: [PATCH] Firmware update configuration changes @@ -39,18 +39,20 @@ Tested: - Successfully ran redfish validater with no new errors. +Change-Id: I25ef6d64af3f1dcea3acba93d7fd2b505130142e Signed-off-by: Vikram Bodireddy +Signed-off-by: AppaRao Puli --- - redfish-core/lib/update_service.hpp | 456 ++++++++++++++---- + redfish-core/lib/update_service.hpp | 462 ++++++++++++++---- static/redfish/v1/$metadata/index.xml | 3 + .../JsonSchemas/OemUpdateService/index.json | 69 +++ .../redfish/v1/schema/OemUpdateService_v1.xml | 40 ++ - 4 files changed, 481 insertions(+), 87 deletions(-) + 4 files changed, 484 insertions(+), 90 deletions(-) create mode 100644 static/redfish/v1/JsonSchemas/OemUpdateService/index.json create mode 100644 static/redfish/v1/schema/OemUpdateService_v1.xml diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp -index 663d48b..70c58d4 100644 +index e420130..b3270f0 100644 --- a/redfish-core/lib/update_service.hpp +++ b/redfish-core/lib/update_service.hpp @@ -26,7 +26,9 @@ @@ -211,9 +213,9 @@ index 663d48b..70c58d4 100644 softwareInterfaceAdded(const std::shared_ptr& asyncResp, + const std::vector imgUriTargets, sdbusplus::message::message& m, - const crow::Request& req) + task::Payload&& payload) { -@@ -76,22 +181,24 @@ static void +@@ -76,23 +181,25 @@ static void m.read(objPath, interfacesProperties); @@ -228,11 +230,15 @@ index 663d48b..70c58d4 100644 { // Retrieve service and activate crow::connections::systemBus->async_method_call( -- [objPath, asyncResp, +- [objPath, asyncResp, payload(std::move(payload))]( + [objPath, asyncResp, imgTargets{imgUriTargets}, - req](const boost::system::error_code errorCode, - const std::vector>>& objInfo) { ++ payload(std::move(payload))]( + const boost::system::error_code errorCode, +- const std::vector< +- std::pair>>& +- objInfo) mutable { ++ const std::vector>>& objInfo) { if (errorCode) { - BMCWEB_LOG_DEBUG << "error_code = " << errorCode; @@ -242,7 +248,7 @@ index 663d48b..70c58d4 100644 BMCWEB_LOG_DEBUG << "error msg = " << errorCode.message(); if (asyncResp) -@@ -118,7 +225,7 @@ static void +@@ -119,7 +226,7 @@ static void // is added fwAvailableTimer = nullptr; @@ -251,7 +257,7 @@ index 663d48b..70c58d4 100644 if (asyncResp) { std::shared_ptr task = -@@ -250,8 +357,7 @@ static void +@@ -251,8 +358,7 @@ static void "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetObject", objPath.str, @@ -261,7 +267,7 @@ index 663d48b..70c58d4 100644 } } } -@@ -261,7 +367,7 @@ static void +@@ -262,7 +368,7 @@ static void static void monitorForSoftwareAvailable( const std::shared_ptr& asyncResp, const crow::Request& req, const std::string& url, @@ -270,20 +276,22 @@ index 663d48b..70c58d4 100644 { // Only allow one FW update at a time if (fwUpdateInProgress != false) -@@ -301,9 +407,10 @@ static void monitorForSoftwareAvailable( +@@ -301,11 +407,12 @@ static void monitorForSoftwareAvailable( + redfish::messages::internalError(asyncResp->res); } }); - -- auto callback = [asyncResp, req](sdbusplus::message::message& m) { ++ + task::Payload payload(req); +- auto callback = [asyncResp, + auto callback = [asyncResp, imgTargets{imgUriTargets}, -+ req](sdbusplus::message::message& m) { + payload](sdbusplus::message::message& m) mutable { BMCWEB_LOG_DEBUG << "Match fired"; -- softwareInterfaceAdded(asyncResp, m, req); -+ softwareInterfaceAdded(asyncResp, imgTargets, m, req); +- softwareInterfaceAdded(asyncResp, m, std::move(payload)); ++ softwareInterfaceAdded(asyncResp, imgTargets, m, std::move(payload)); }; fwUpdateInProgress = true; -@@ -468,12 +575,15 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) +@@ -470,12 +577,15 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app) std::string fwFile = imageURI.substr(separator + 1); BMCWEB_LOG_DEBUG << "Server: " << tftpServer + " File: " << fwFile; @@ -300,7 +308,7 @@ index 663d48b..70c58d4 100644 // TFTP can take up to 10 minutes depending on image size and // connection speed. Return to caller as soon as the TFTP operation -@@ -522,6 +632,9 @@ inline void requestRoutesUpdateService(App& app) +@@ -524,6 +634,9 @@ inline void requestRoutesUpdateService(App& app) asyncResp->res.jsonValue["Name"] = "Update Service"; asyncResp->res.jsonValue["HttpPushUri"] = "/redfish/v1/UpdateService"; @@ -310,7 +318,7 @@ index 663d48b..70c58d4 100644 // UpdateService cannot be disabled asyncResp->res.jsonValue["ServiceEnabled"] = true; asyncResp->res.jsonValue["FirmwareInventory"] = { -@@ -536,7 +649,8 @@ inline void requestRoutesUpdateService(App& app) +@@ -538,7 +651,8 @@ inline void requestRoutesUpdateService(App& app) asyncResp->res .jsonValue["Actions"]["#UpdateService.SimpleUpdate"]; updateSvcSimpleUpdate["target"] = @@ -320,7 +328,7 @@ index 663d48b..70c58d4 100644 updateSvcSimpleUpdate["TransferProtocol@Redfish.AllowableValues"] = {"TFTP"}; #endif -@@ -578,89 +692,258 @@ inline void requestRoutesUpdateService(App& app) +@@ -580,89 +694,258 @@ inline void requestRoutesUpdateService(App& app) "/xyz/openbmc_project/software/apply_time", "org.freedesktop.DBus.Properties", "Get", "xyz.openbmc_project.Software.ApplyTime", "RequestedApplyTime"); @@ -457,13 +465,13 @@ index 663d48b..70c58d4 100644 - applyTime)) + std::string applyTimeNewVal; + if (applyTime == "Immediate") -+ { + { + applyTimeNewVal = + "xyz.openbmc_project.Software.ApplyTime." + "RequestedApplyTimes.Immediate"; + } + else if (applyTime == "OnReset") - { ++ { + applyTimeNewVal = + "xyz.openbmc_project.Software.ApplyTime." + "RequestedApplyTimes.OnReset"; @@ -636,7 +644,7 @@ index 663d48b..70c58d4 100644 BMCWEB_ROUTE(app, "/redfish/v1/UpdateService/") .privileges(redfish::privileges::postUpdateService) .methods(boost::beast::http::verb::post)( -@@ -670,7 +953,8 @@ inline void requestRoutesUpdateService(App& app) +@@ -672,7 +955,8 @@ inline void requestRoutesUpdateService(App& app) // Setup callback for when new software detected monitorForSoftwareAvailable(asyncResp, req, @@ -646,7 +654,7 @@ index 663d48b..70c58d4 100644 std::string filepath("/tmp/images/" + boost::uuids::to_string( -@@ -683,7 +967,7 @@ inline void requestRoutesUpdateService(App& app) +@@ -685,7 +969,7 @@ inline void requestRoutesUpdateService(App& app) out.close(); BMCWEB_LOG_DEBUG << "file upload complete!!"; }); @@ -655,7 +663,7 @@ index 663d48b..70c58d4 100644 inline void requestRoutesSoftwareInventoryCollection(App& app) { -@@ -746,8 +1030,7 @@ inline void requestRoutesSoftwareInventoryCollection(App& app) +@@ -748,8 +1032,7 @@ inline void requestRoutesSoftwareInventoryCollection(App& app) "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/xyz/openbmc_project/software", static_cast(0), @@ -665,7 +673,7 @@ index 663d48b..70c58d4 100644 }); } /* Fill related item links (i.e. bmc, bios) in for inventory */ -@@ -911,7 +1194,7 @@ inline void requestRoutesSoftwareInventory(App& app) +@@ -913,7 +1196,7 @@ inline void requestRoutesSoftwareInventory(App& app) }, obj.second[0].first, obj.first, "org.freedesktop.DBus.Properties", "GetAll", @@ -674,7 +682,7 @@ index 663d48b..70c58d4 100644 } if (!found) { -@@ -935,8 +1218,7 @@ inline void requestRoutesSoftwareInventory(App& app) +@@ -937,8 +1220,7 @@ inline void requestRoutesSoftwareInventory(App& app) "/xyz/openbmc_project/object_mapper", "xyz.openbmc_project.ObjectMapper", "GetSubTree", "/", static_cast(0), @@ -685,10 +693,10 @@ index 663d48b..70c58d4 100644 } diff --git a/static/redfish/v1/$metadata/index.xml b/static/redfish/v1/$metadata/index.xml -index eba38bf..876ebfb 100644 +index 66b6faf..f0919c9 100644 --- a/static/redfish/v1/$metadata/index.xml +++ b/static/redfish/v1/$metadata/index.xml -@@ -2346,6 +2346,9 @@ +@@ -2444,6 +2444,9 @@ diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0013-Add-UART-routing-logic-into-host-console-connection-.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0013-Add-UART-routing-logic-into-host-console-connection-.patch index 8b0d90fe0..41acb6057 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0013-Add-UART-routing-logic-into-host-console-connection-.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0013-Add-UART-routing-logic-into-host-console-connection-.patch @@ -25,7 +25,7 @@ index cdb19901e82d..9c4ae8821074 100644 static bool doingWrite = false; -+constexpr char const* uartMuxCtrlPath = "/sys/bus/platform/drivers/aspeed-uart-routing/1e78909c.uart_routing/raw"; ++constexpr char const* uartMuxCtrlPath = "/sys/bus/platform/drivers/aspeed-uart-routing/1e789098.uart-routing/hicra"; +constexpr char const* uartMuxCtrlVal = "0x03450003"; + inline void doWrite() diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0015-Add-state-sensor-messages-to-the-registry.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0015-Add-state-sensor-messages-to-the-registry.patch index b171a8b2c..1193fe9d1 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0015-Add-state-sensor-messages-to-the-registry.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0015-Add-state-sensor-messages-to-the-registry.patch @@ -1,4 +1,4 @@ -From df571ddf0596f73c0318da3a90b9813e6df19dd9 Mon Sep 17 00:00:00 2001 +From b468b508176dfffe2e8e4adb3052577b9ff70d2f Mon Sep 17 00:00:00 2001 From: "Arun P. Mohanan" Date: Wed, 27 Jan 2021 18:22:58 +0530 Subject: [PATCH] Add state sensor messages to the registry @@ -34,19 +34,19 @@ Signed-off-by: Arun P. Mohanan 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/redfish-core/include/registries/openbmc_message_registry.hpp b/redfish-core/include/registries/openbmc_message_registry.hpp -index 5eb9380..dbea97c 100644 +index 6cf503f..87b2913 100644 --- a/redfish-core/include/registries/openbmc_message_registry.hpp +++ b/redfish-core/include/registries/openbmc_message_registry.hpp @@ -29,7 +29,7 @@ const Header header = { - "0.1.0", + "0.2.0", "OpenBMC", }; --constexpr std::array registry = { -+constexpr std::array registry = { +-constexpr std::array registry = { ++constexpr std::array registry = { MessageEntry{ "ADDDCCorrectable", { -@@ -2318,6 +2318,39 @@ constexpr std::array registry = { +@@ -2331,6 +2331,39 @@ constexpr std::array registry = { {}, "None.", }}, @@ -86,7 +86,7 @@ index 5eb9380..dbea97c 100644 MessageEntry{"SystemInterfaceDisabledProvisioned", { "Indicates that the system interface is in the disabled " -@@ -2410,6 +2443,5 @@ constexpr std::array registry = { +@@ -2423,6 +2456,5 @@ constexpr std::array registry = { {"string"}, "None.", }}, diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0017-Add-msg-registry-for-subscription-related-actions.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0017-Add-msg-registry-for-subscription-related-actions.patch index d0cfd1c44..35ac7a114 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0017-Add-msg-registry-for-subscription-related-actions.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0017-Add-msg-registry-for-subscription-related-actions.patch @@ -1,4 +1,4 @@ -From 7282ab7756cdb8c844bef9affd8a8e894828678c Mon Sep 17 00:00:00 2001 +From 40895934bdedb978e8cfd47930ae5a190e19b440 Mon Sep 17 00:00:00 2001 From: Ayushi Smriti Date: Mon, 10 May 2021 12:32:30 +0530 Subject: [PATCH] Add msg registry for subscription related actions @@ -18,19 +18,19 @@ Signed-off-by: Ayushi Smriti 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/redfish-core/include/registries/openbmc_message_registry.hpp b/redfish-core/include/registries/openbmc_message_registry.hpp -index e12a138..2f981db 100644 +index 87b2913..1e493ca 100644 --- a/redfish-core/include/registries/openbmc_message_registry.hpp +++ b/redfish-core/include/registries/openbmc_message_registry.hpp @@ -29,7 +29,7 @@ const Header header = { "0.2.0", "OpenBMC", }; --constexpr std::array registry = { -+constexpr std::array registry = { +-constexpr std::array registry = { ++constexpr std::array registry = { MessageEntry{ "ADDDCCorrectable", { -@@ -417,6 +417,45 @@ constexpr std::array registry = { +@@ -417,6 +417,45 @@ constexpr std::array registry = { {}, "None.", }}, diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0018-bmcweb-Add-BMC-Time-update-log-to-the-registry.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0018-bmcweb-Add-BMC-Time-update-log-to-the-registry.patch index 829384305..54636cb3d 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0018-bmcweb-Add-BMC-Time-update-log-to-the-registry.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0018-bmcweb-Add-BMC-Time-update-log-to-the-registry.patch @@ -1,7 +1,7 @@ -From 3ec1f79d1cb29724e345586f0baefca81d98d3ae Mon Sep 17 00:00:00 2001 +From eeac51ebaaad82bb4ac65a029c81c221e32b33ea Mon Sep 17 00:00:00 2001 From: mansijos Date: Wed, 26 May 2021 17:40:04 +0530 -Subject: [PATCH] [bmcweb] Add BMC Time update log to the registry +Subject: [PATCH] Add BMC Time update log to the registry Add message in registry to log an event that indicates BMC time is set via NTP, Host or Manually. @@ -20,19 +20,19 @@ Signed-off-by: mansijos 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/redfish-core/include/registries/openbmc_message_registry.hpp b/redfish-core/include/registries/openbmc_message_registry.hpp -index 2f981db..a00d235 100644 +index 1e493ca..967713f 100644 --- a/redfish-core/include/registries/openbmc_message_registry.hpp +++ b/redfish-core/include/registries/openbmc_message_registry.hpp @@ -29,7 +29,7 @@ const Header header = { "0.2.0", "OpenBMC", }; --constexpr std::array registry = { -+constexpr std::array registry = { +-constexpr std::array registry = { ++constexpr std::array registry = { MessageEntry{ "ADDDCCorrectable", { -@@ -286,6 +286,39 @@ constexpr std::array registry = { +@@ -286,6 +286,39 @@ constexpr std::array registry = { {}, "None.", }}, diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0019-Add-generic-message-PropertySizeExceeded.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0019-Add-generic-message-PropertySizeExceeded.patch index 028119249..522f04886 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0019-Add-generic-message-PropertySizeExceeded.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0019-Add-generic-message-PropertySizeExceeded.patch @@ -1,6 +1,6 @@ -From 2b865ad20ce0616b79a453d1571976bb2303050c Mon Sep 17 00:00:00 2001 -From: Krzysztof Grobelny -Date: Wed, 14 Jul 2021 13:55:27 +0000 +From 6bc3ec77e062e8f2108f755e9f0089a014031f91 Mon Sep 17 00:00:00 2001 +From: AppaRao Puli +Date: Wed, 6 Oct 2021 21:51:16 +0000 Subject: [PATCH] Add generic message - PropertySizeExceeded Adding a generic error message "PropertySizeExceeded" @@ -12,6 +12,7 @@ Verified by explicitly sending this message as a response. Change-Id: I0e9f85f82a69c598e169fc8e9a68c3f66c0084d8 Signed-off-by: Nitin Wankhade +Signed-off-by: AppaRao Puli --- redfish-core/include/error_messages.hpp | 12 +++++++++ .../registries/base_message_registry.hpp | 17 +++++++++++- @@ -19,7 +20,7 @@ Signed-off-by: Nitin Wankhade 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp -index 922dae9..f29e326 100644 +index 3d11cc4..051cff1 100644 --- a/redfish-core/include/error_messages.hpp +++ b/redfish-core/include/error_messages.hpp @@ -222,6 +222,18 @@ nlohmann::json propertyValueFormatError(const std::string& arg1, @@ -42,19 +43,19 @@ index 922dae9..f29e326 100644 * @brief Formats PropertyValueNotInList message into JSON * Message body: "The value for the property is not in the list of diff --git a/redfish-core/include/registries/base_message_registry.hpp b/redfish-core/include/registries/base_message_registry.hpp -index 58156c8..ab9b046 100644 +index 702cd6f..193df16 100644 --- a/redfish-core/include/registries/base_message_registry.hpp +++ b/redfish-core/include/registries/base_message_registry.hpp -@@ -36,7 +36,7 @@ const Header header = { +@@ -22,7 +22,7 @@ const Header header = { constexpr const char* url = - "https://redfish.dmtf.org/registries/Base.1.10.0.json"; + "https://redfish.dmtf.org/registries/Base.1.11.0.json"; --constexpr std::array registry = { -+constexpr std::array registry = { +-constexpr std::array registry = { ++constexpr std::array registry = { MessageEntry{ "AccessDenied", { -@@ -664,6 +664,21 @@ constexpr std::array registry = { +@@ -692,6 +692,21 @@ constexpr std::array registry = { "Remove the property from the request body and resubmit " "the request if the operation failed.", }}, @@ -77,7 +78,7 @@ index 58156c8..ab9b046 100644 { "Indicates that an unknown property was included in the " diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp -index 409adb1..bebb6d8 100644 +index 9c28e8f..854a1a5 100644 --- a/redfish-core/src/error_messages.cpp +++ b/redfish-core/src/error_messages.cpp @@ -514,6 +514,33 @@ void propertyValueFormatError(crow::Response& res, const std::string& arg1, @@ -115,5 +116,5 @@ index 409adb1..bebb6d8 100644 * @internal * @brief Formats PropertyValueNotInList message into JSON for the specified -- -2.25.1 +2.17.1 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0021-Add-message-registry-entry-for-FirmwareResiliencyErr.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0021-Add-message-registry-entry-for-FirmwareResiliencyErr.patch deleted file mode 100644 index 2b8f8987c..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0021-Add-message-registry-entry-for-FirmwareResiliencyErr.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 35c9f6f0f4e1254f0512154cc46116d8047fe19b Mon Sep 17 00:00:00 2001 -From: Chalapathi Venkataramashetty -Date: Wed, 14 Jul 2021 20:44:06 +0000 -Subject: [PATCH] Add message registry entry for FirmwareResiliencyError - -Add an event log in redfish when firmware update failed due to -FirmwareResiliencyError. - -The existing message entries BMCFirmwareResiliencyError(for BMC update -failures) and BIOSFirmwareResiliencyError(for BIOS update failures) are -not useful for the new platform. The new platform's CPLD report common -error code for BMC, PCH or CPLD firmware update failures. Hence a common -message entry is required to capture the firmware update failure events. - -This event is Implemented in the following review. -https://gerrit.openbmc-project.xyz/c/openbmc/pfr-manager/+/43281 - -Tested: -Redfish Service Validator passed for this change. - -Update BMC firmware with mismatched SVN -POST: https:///redfish/v1/UpdateService/ - with binary file -After BMC reboots check for Event log in Redfish -Command: GET: https:///redfish/v1/Systems/system/LogServices/ - EventLog/Entries -Response: -{ - "@odata.id": "/redfish/v1/Systems/system/LogServices/ - EventLog/Entries/1621435142_1", - "@odata.type": "#LogEntry.v1_4_0.LogEntry", - "Created": "2021-05-19T14:39:02+00:00", - "EntryType": "Event", - "Id": "1621435142_1", - "Message": "Firmware resiliency error. Error reason: - Firmware update failed(MinorCode:0x02).", - "MessageArgs": [ - "Firmware update failed(MinorCode:0x02)" - ], - "MessageId": "OpenBMC.0.1.FirmwareResiliencyError", - "Name": "System Event Log Entry", - "Severity": "Critical" - }, - -Signed-off-by: Chalapathi Venkataramashetty ---- - .../registries/openbmc_message_registry.hpp | 14 +++++++++++++- - 1 file changed, 13 insertions(+), 1 deletion(-) - -diff --git a/redfish-core/include/registries/openbmc_message_registry.hpp b/redfish-core/include/registries/openbmc_message_registry.hpp -index a00d235..967713f 100644 ---- a/redfish-core/include/registries/openbmc_message_registry.hpp -+++ b/redfish-core/include/registries/openbmc_message_registry.hpp -@@ -29,7 +29,7 @@ const Header header = { - "0.2.0", - "OpenBMC", - }; --constexpr std::array registry = { -+constexpr std::array registry = { - MessageEntry{ - "ADDDCCorrectable", - { -@@ -560,6 +560,18 @@ constexpr std::array registry = { - {"string"}, - "None.", - }}, -+ MessageEntry{"FirmwareResiliencyError", -+ { -+ "Indicates firmware encountered resilience error.", -+ "Firmware resiliency error. Error reason: %1.", -+ "Critical", -+ "Critical", -+ 1, -+ { -+ "string", -+ }, -+ "None.", -+ }}, - MessageEntry{"FirmwareUpdateCompleted", - { - "Indicates a firmware update has completed successfully.", --- -2.17.1 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0024-Add-count-sensor-type.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0024-Add-count-sensor-type.patch index a9a4ab151..22ae05fa3 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0024-Add-count-sensor-type.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0024-Add-count-sensor-type.patch @@ -1,4 +1,4 @@ -From fb337f868543f72bd8ba24db3c4b09b4c1d888ab Mon Sep 17 00:00:00 2001 +From 94a0ae774933b7801d0c8d843b3ac3a39a5e5646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Ambro=C5=BCewicz?= Date: Fri, 30 Jul 2021 15:25:29 +0200 Subject: [PATCH] Add 'count' sensor type @@ -13,7 +13,7 @@ Testing: 1 file changed, 1 insertion(+) diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp -index cb7ea15..d72a572 100644 +index 45a1eb6..7405e5a 100644 --- a/redfish-core/lib/sensors.hpp +++ b/redfish-core/lib/sensors.hpp @@ -63,6 +63,7 @@ static const boost::container::flat_map +Date: Fri, 3 Sep 2021 02:33:43 -0500 +Subject: [PATCH] Add Model & CoreCount to ProcessorSummary + +In Redfish ComputerSystem schema, the ProcessorSummary parameter +lists summary information of the Processors on the system. This commit +adds the 'Model' and 'CoreCount' properties to ProcessorSummary. + +If the CPU Models are different, then the 'Model' field takes the first +entry in alphabetical order. + +Testing: +1. Redfish Validator Testing successfully passed. +2. Curl testing: + +curl -k -H "X-Auth-Token: $tok" https://$bmc/redfish/v1/Systems/system + +... + "ProcessorSummary": { + "CoreCount": 24, + "Count": 2, + "Model": "test_name", + "Status": { + "Health": "OK", + "HealthRollup": "OK", + "State": "Disabled" + } + }, +... + +Change-Id: I39cbf6ed35c35ce3a3551c9689237d5023775326 +Signed-off-by: Ali Ahmed +Signed-off-by: AppaRao Puli +--- + redfish-core/lib/systems.hpp | 229 ++++++++++++++++++++++------------- + 1 file changed, 147 insertions(+), 82 deletions(-) + +diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp +index 680a0ee..3b5f9e4 100644 +--- a/redfish-core/lib/systems.hpp ++++ b/redfish-core/lib/systems.hpp +@@ -139,6 +139,152 @@ inline void + } + } + ++inline void getProcessorProperties( ++ const std::shared_ptr& aResp, const std::string& service, ++ const std::string& path, ++ const std::vector>>& ++ properties) ++{ ++ ++ BMCWEB_LOG_DEBUG << "Got " << properties.size() << " Cpu properties."; ++ ++ auto getCpuPresenceState = ++ [aResp](const boost::system::error_code ec3, ++ const std::variant& cpuPresenceCheck) { ++ if (ec3) ++ { ++ BMCWEB_LOG_ERROR << "DBUS response error " << ec3; ++ return; ++ } ++ modifyCpuPresenceState(aResp, cpuPresenceCheck); ++ }; ++ ++ auto getCpuFunctionalState = ++ [aResp](const boost::system::error_code ec3, ++ const std::variant& cpuFunctionalCheck) { ++ if (ec3) ++ { ++ BMCWEB_LOG_ERROR << "DBUS response error " << ec3; ++ return; ++ } ++ modifyCpuFunctionalState(aResp, cpuFunctionalCheck); ++ }; ++ ++ // Get the Presence of CPU ++ crow::connections::systemBus->async_method_call( ++ std::move(getCpuPresenceState), service, path, ++ "org.freedesktop.DBus.Properties", "Get", ++ "xyz.openbmc_project.Inventory.Item", "Present"); ++ ++ // Get the Functional State ++ crow::connections::systemBus->async_method_call( ++ std::move(getCpuFunctionalState), service, path, ++ "org.freedesktop.DBus.Properties", "Get", ++ "xyz.openbmc_project.State.Decorator.OperationalStatus", "Functional"); ++ ++ for (const auto& property : properties) ++ { ++ if (property.first == "Family") ++ { ++ // Get the CPU Model ++ const std::string* modelStr = ++ std::get_if(&property.second); ++ if (!modelStr) ++ { ++ BMCWEB_LOG_DEBUG << "Failed to get CPU Family"; ++ // Skip it and continue with other properties ++ continue; ++ } ++ if ((*modelStr).size() < 1) ++ { ++ BMCWEB_LOG_DEBUG << "Empty CPU Family info, skipping..."; ++ continue; ++ } ++ nlohmann::json& prevModel = ++ aResp->res.jsonValue["ProcessorSummary"]["Model"]; ++ std::string* prevModelPtr = prevModel.get_ptr(); ++ ++ // If CPU Models are different, use the first entry in ++ // alphabetical order ++ ++ // If Model has never been set ++ // before, set it to *modelStr ++ if (prevModelPtr == nullptr) ++ { ++ prevModel = *modelStr; ++ } ++ // If Model has been set before, only change if new Model is ++ // higher in alphabetical order ++ else ++ { ++ if (*modelStr < *prevModelPtr) ++ { ++ prevModel = *modelStr; ++ } ++ } ++ } ++ else if (property.first == "CoreCount") ++ { ++ // Get CPU CoreCount and add it to the total ++ const uint16_t* coreCountVal = ++ std::get_if(&property.second); ++ ++ if (!coreCountVal) ++ { ++ BMCWEB_LOG_DEBUG << "Failed to get CPU Core count"; ++ // Skip it and continue with other properties ++ continue; ++ } ++ ++ nlohmann::json& coreCount = ++ aResp->res.jsonValue["ProcessorSummary"]["CoreCount"]; ++ uint64_t* coreCountPtr = coreCount.get_ptr(); ++ ++ if (coreCountPtr == nullptr) ++ { ++ coreCount = *coreCountVal; ++ } ++ else ++ { ++ *coreCountPtr += *coreCountVal; ++ } ++ } ++ } ++} ++ ++/* ++ * @brief Get ProcessorSummary fields ++ * ++ * @param[in] aResp Shared pointer for completing asynchronous calls ++ * @param[in] service dbus service for Cpu Information ++ * @param[in] path dbus path for Cpu ++ * ++ * @return None. ++ */ ++inline void getProcessorSummary(const std::shared_ptr& aResp, ++ const std::string& service, ++ const std::string& path) ++{ ++ ++ crow::connections::systemBus->async_method_call( ++ [aResp, service, ++ path](const boost::system::error_code ec2, ++ const std::vector>>& properties) { ++ if (ec2) ++ { ++ BMCWEB_LOG_ERROR << "DBUS response error " << ec2; ++ messages::internalError(aResp->res); ++ return; ++ } ++ getProcessorProperties(aResp, service, path, properties); ++ }, ++ service, path, "org.freedesktop.DBus.Properties", "GetAll", ++ "xyz.openbmc_project.Inventory.Item.Cpu"); ++} ++ + /* + * @brief Retrieves computer system properties over dbus + * +@@ -309,88 +455,7 @@ inline void + BMCWEB_LOG_DEBUG + << "Found Cpu, now get its properties."; + +- crow::connections::systemBus->async_method_call( +- [aResp, service{connection.first}, +- path](const boost::system::error_code ec2, +- const std::vector< +- std::pair>& +- properties) { +- if (ec2) +- { +- BMCWEB_LOG_ERROR +- << "DBUS response error " << ec2; +- messages::internalError(aResp->res); +- return; +- } +- BMCWEB_LOG_DEBUG << "Got " +- << properties.size() +- << " Cpu properties."; +- +- auto getCpuPresenceState = +- [aResp]( +- const boost::system::error_code ec3, +- const std::variant& +- cpuPresenceCheck) { +- if (ec3) +- { +- BMCWEB_LOG_ERROR +- << "DBUS response error " +- << ec3; +- return; +- } +- modifyCpuPresenceState( +- aResp, cpuPresenceCheck); +- }; +- +- auto getCpuFunctionalState = +- [aResp]( +- const boost::system::error_code ec3, +- const std::variant& +- cpuFunctionalCheck) { +- if (ec3) +- { +- BMCWEB_LOG_ERROR +- << "DBUS response error " +- << ec3; +- return; +- } +- modifyCpuFunctionalState( +- aResp, cpuFunctionalCheck); +- }; +- +- // Get the Presence of CPU +- crow::connections::systemBus +- ->async_method_call( +- std::move(getCpuPresenceState), +- service, path, +- "org.freedesktop.DBus." +- "Properties", +- "Get", +- "xyz.openbmc_project.Inventory." +- "Item", +- "Present"); +- +- // Get the Functional State +- crow::connections::systemBus +- ->async_method_call( +- std::move(getCpuFunctionalState), +- service, path, +- "org.freedesktop.DBus." +- "Properties", +- "Get", +- "xyz.openbmc_project.State." +- "Decorator." +- "OperationalStatus", +- "Functional"); +- +- // Get the MODEL from +- // xyz.openbmc_project.Inventory.Decorator.Asset +- // support it later as Model is Empty +- // currently. +- }, +- connection.first, path, +- "org.freedesktop.DBus.Properties", "GetAll", +- "xyz.openbmc_project.Inventory.Item.Cpu"); ++ getProcessorSummary(aResp, connection.first, path); + + cpuHealth->inventory.emplace_back(path); + } +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0001-Define-Redfish-interface-Registries-Bios.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0001-Define-Redfish-interface-Registries-Bios.patch index 93bbb7494..19a392873 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0001-Define-Redfish-interface-Registries-Bios.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0001-Define-Redfish-interface-Registries-Bios.patch @@ -1,7 +1,7 @@ -From 501003876765f51799152bace657d97b7fa2b60e Mon Sep 17 00:00:00 2001 +From bde7f728d5a87522674bcd5515baaa02bf7b9373 Mon Sep 17 00:00:00 2001 From: Kuiying Wang Date: Fri, 4 Sep 2020 19:24:25 +0800 -Subject: [PATCH 1/5] Define Redfish interface "/Registries/Bios" and enable +Subject: [PATCH] Define Redfish interface "/Registries/Bios" and enable Attributes property 1. Define Redfish interface "/Registries/Bios" for BIOS Attribute Registry @@ -225,33 +225,36 @@ Oem - Resource.Oem No Optional Change-Id: Iecc61018c350f0b8c89df59b2864b941508b1916 Signed-off-by: Kuiying Wang +Signed-off-by: Snehalatha Venkatesh --- - redfish-core/include/redfish.hpp | 2 + - .../include/registries/bios_registry.hpp | 31 + - redfish-core/lib/bios.hpp | 528 ++++++++++++++++++ - redfish-core/lib/message_registries.hpp | 6 + - 4 files changed, 567 insertions(+) + redfish-core/include/redfish.hpp | 3 + + .../include/registries/bios_registry.hpp | 41 ++ + redfish-core/lib/bios.hpp | 511 ++++++++++++++++++ + redfish-core/lib/message_registries.hpp | 11 +- + 4 files changed, 565 insertions(+), 1 deletion(-) create mode 100644 redfish-core/include/registries/bios_registry.hpp diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp -index c15062d..3388498 100644 +index 0a97150..07a9417 100644 --- a/redfish-core/include/redfish.hpp +++ b/redfish-core/include/redfish.hpp -@@ -152,6 +152,8 @@ class RedfishService +@@ -148,7 +148,10 @@ class RedfishService requestRoutesSystemActionsReset(app); requestRoutesSystemResetActionInfo(app); requestRoutesBiosService(app); + requestRoutesBiosSettings(app); + requestRoutesBiosAttributeRegistry(app); requestRoutesBiosReset(app); ++ requestRoutesBiosChangePassword(app); #ifdef BMCWEB_ENABLE_VM_NBDPROXY + requestNBDVirtualMediaRoutes(app); diff --git a/redfish-core/include/registries/bios_registry.hpp b/redfish-core/include/registries/bios_registry.hpp new file mode 100644 -index 0000000..88ef782 +index 0000000..c80937a --- /dev/null +++ b/redfish-core/include/registries/bios_registry.hpp -@@ -0,0 +1,31 @@ +@@ -0,0 +1,41 @@ +/* +// Copyright (c) 2020 Intel Corporation +// @@ -268,6 +271,7 @@ index 0000000..88ef782 +// limitations under the License. +*/ +#pragma once ++#include + +namespace redfish::message_registries::bios +{ @@ -282,10 +286,18 @@ index 0000000..88ef782 + "1.0.0", + "OpenBMC", +}; ++// BiosAttributeRegistry registry is not defined in DMTF, We should use ++// OEM defined registries for this purpose. ++// Below link is wrong - We need to define OEM registries and use ++// appropriate data here. ++constexpr const char* url = ++ "https://redfish.dmtf.org/registries/BiosAttributeRegistry.1.0.0.json"; ++ ++constexpr std::array registry = { ++}; +} // namespace redfish::message_registries::bios -\ No newline at end of file diff --git a/redfish-core/lib/bios.hpp b/redfish-core/lib/bios.hpp -index 604b8e7..c1a5c56 100644 +index c2fb284..87536d6 100644 --- a/redfish-core/lib/bios.hpp +++ b/redfish-core/lib/bios.hpp @@ -3,8 +3,140 @@ @@ -429,109 +441,96 @@ index 604b8e7..c1a5c56 100644 /** * BiosService class supports handle get method for bios. */ -@@ -29,8 +161,404 @@ inline void requestRoutesBiosService(App& app) - // Get the ActiveSoftwareImage and SoftwareImages - fw_util::populateFirmwareInformation( - asyncResp, fw_util::biosPurpose, "", true); -+ asyncResp->res.jsonValue["@Redfish.Settings"] = { -+ {"@odata.type", "#Settings.v1_3_0.Settings"}, -+ {"SettingsObject", -+ {{"@odata.id", -+ "/redfish/v1/Systems/system/Bios/Settings"}}}}; -+ asyncResp->res.jsonValue["AttributeRegistry"] = -+ "BiosAttributeRegistry"; -+ asyncResp->res.jsonValue["Attributes"] = {}; +@@ -23,6 +155,85 @@ inline void + // Get the ActiveSoftwareImage and SoftwareImages + fw_util::populateFirmwareInformation(asyncResp, fw_util::biosPurpose, "", + true); + -+ crow::connections::systemBus->async_method_call( -+ [asyncResp](const boost::system::error_code ec, -+ const GetObjectType& getObjectType) { -+ if (ec) ++ asyncResp->res.jsonValue["@Redfish.Settings"] = { ++ {"@odata.type", "#Settings.v1_3_0.Settings"}, ++ {"SettingsObject", ++ {{"@odata.id", "/redfish/v1/Systems/system/Bios/Settings"}}}}; ++ asyncResp->res.jsonValue["AttributeRegistry"] = "BiosAttributeRegistry"; ++ asyncResp->res.jsonValue["Attributes"] = {}; ++ ++ crow::connections::systemBus->async_method_call( ++ [asyncResp](const boost::system::error_code ec, ++ const GetObjectType& getObjectType) { ++ if (ec) ++ { ++ BMCWEB_LOG_ERROR << "ObjectMapper::GetObject call failed: " ++ << ec; ++ messages::internalError(asyncResp->res); ++ ++ return; ++ } ++ const std::string& service = getObjectType.begin()->first; ++ ++ crow::connections::systemBus->async_method_call( ++ [asyncResp]( ++ const boost::system::error_code ec, ++ const std::variant& retBiosTable) { ++ if (ec) ++ { ++ BMCWEB_LOG_ERROR << "getBiosAttributes DBUS error: " ++ << ec; ++ messages::internalError(asyncResp->res); ++ return; ++ } ++ const BiosBaseTableType* baseBiosTable = ++ std::get_if(&retBiosTable); ++ nlohmann::json& attributesJson = ++ asyncResp->res.jsonValue["Attributes"]; ++ if (baseBiosTable == nullptr) ++ { ++ BMCWEB_LOG_ERROR << "baseBiosTable == nullptr "; ++ messages::internalError(asyncResp->res); ++ return; ++ } ++ for (const BiosBaseTableItemType& item : *baseBiosTable) ++ { ++ const std::string& key = item.first; ++ const std::string& itemType = ++ std::get(item.second); ++ std::string attrType = mapAttrTypeToRedfish(itemType); ++ if (attrType == "String") + { -+ BMCWEB_LOG_ERROR -+ << "ObjectMapper::GetObject call failed: " -+ << ec; ++ const std::string* currValue = ++ std::get_if( ++ &std::get(item.second)); ++ attributesJson.emplace( ++ key, currValue != nullptr ? *currValue : ""); ++ } ++ else if (attrType == "Integer") ++ { ++ const int64_t* currValue = std::get_if( ++ &std::get(item.second)); ++ attributesJson.emplace( ++ key, currValue != nullptr ? *currValue : 0); ++ } ++ else ++ { ++ BMCWEB_LOG_ERROR << "Unsupported attribute type."; + messages::internalError(asyncResp->res); -+ -+ return; + } -+ const std::string& service = -+ getObjectType.begin()->first; -+ -+ crow::connections::systemBus->async_method_call( -+ [asyncResp](const boost::system::error_code ec, -+ const std::variant& -+ retBiosTable) { -+ if (ec) -+ { -+ BMCWEB_LOG_ERROR -+ << "getBiosAttributes DBUS error: " -+ << ec; -+ messages::internalError(asyncResp->res); -+ return; -+ } -+ const BiosBaseTableType* baseBiosTable = -+ std::get_if( -+ &retBiosTable); -+ nlohmann::json& attributesJson = -+ asyncResp->res.jsonValue["Attributes"]; -+ if (baseBiosTable == nullptr) -+ { -+ BMCWEB_LOG_ERROR -+ << "baseBiosTable == nullptr "; -+ messages::internalError(asyncResp->res); -+ return; -+ } -+ for (const BiosBaseTableItemType& item : -+ *baseBiosTable) -+ { -+ const std::string& key = item.first; -+ const std::string& itemType = -+ std::get(item.second); -+ std::string attrType = -+ mapAttrTypeToRedfish(itemType); -+ if (attrType == "String") -+ { -+ const std::string* currValue = -+ std::get_if( -+ &std::get( -+ item.second)); -+ attributesJson.emplace( -+ key, currValue != nullptr -+ ? *currValue -+ : ""); -+ } -+ else if (attrType == "Integer") -+ { -+ const int64_t* currValue = -+ std::get_if( -+ &std::get( -+ item.second)); -+ attributesJson.emplace( -+ key, currValue != nullptr -+ ? *currValue -+ : 0); -+ } -+ else -+ { -+ BMCWEB_LOG_ERROR -+ << "Unsupported attribute type."; -+ messages::internalError(asyncResp->res); -+ } -+ } -+ }, -+ service, "/xyz/openbmc_project/bios_config/manager", -+ "org.freedesktop.DBus.Properties", "Get", -+ "xyz.openbmc_project.BIOSConfig.Manager", -+ "BaseBIOSTable"); -+ }, -+ "xyz.openbmc_project.ObjectMapper", -+ "/xyz/openbmc_project/object_mapper", -+ "xyz.openbmc_project.ObjectMapper", "GetObject", -+ "/xyz/openbmc_project/bios_config/manager", -+ std::array()); - }); ++ } ++ }, ++ service, "/xyz/openbmc_project/bios_config/manager", ++ "org.freedesktop.DBus.Properties", "Get", ++ "xyz.openbmc_project.BIOSConfig.Manager", "BaseBIOSTable"); ++ }, ++ "xyz.openbmc_project.ObjectMapper", ++ "/xyz/openbmc_project/object_mapper", ++ "xyz.openbmc_project.ObjectMapper", "GetObject", ++ "/xyz/openbmc_project/bios_config/manager", ++ std::array()); } -+ + inline void requestRoutesBiosService(App& app) + { +@@ -31,6 +242,306 @@ inline void requestRoutesBiosService(App& app) + .methods(boost::beast::http::verb::get)(handleBiosServiceGet); + } + +/** + * BiosSettings class supports handle GET/PATCH method for + * BIOS configuration pending settings. @@ -831,11 +830,12 @@ index 604b8e7..c1a5c56 100644 + std::array()); + }); +} ++ /** * BiosReset class supports handle POST method for Reset bios. * The class retrieves and sends data directly to D-Bus. diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp -index e3bd5bf..f1f130a 100644 +index 43359e3..b2fb43c 100644 --- a/redfish-core/lib/message_registries.hpp +++ b/redfish-core/lib/message_registries.hpp @@ -17,6 +17,7 @@ @@ -846,18 +846,30 @@ index e3bd5bf..f1f130a 100644 #include "registries/openbmc_message_registry.hpp" #include "registries/resource_event_message_registry.hpp" #include "registries/task_event_message_registry.hpp" -@@ -87,6 +88,11 @@ inline void requestRoutesMessageRegistryFile(App& app) - header = &message_registries::resource_event::header; - url = message_registries::resource_event::url; - } -+ else if (registry == "BiosAttributeRegistry") -+ { -+ header = &message_registries::bios::header; -+ dmtf.clear(); -+ } - else - { - messages::resourceNotFound( +@@ -125,7 +126,6 @@ inline void requestRoutesMessageRegistryFile(App& app) + inline void handleMessageRegistryGet( + const crow::Request&, const std::shared_ptr& asyncResp, + const std::string& registry, const std::string& registryMatch) +- + { + const message_registries::Header* header; + std::vector registryEntries; +@@ -165,6 +165,15 @@ inline void handleMessageRegistryGet( + registryEntries.emplace_back(&entry); + } + } ++ else if (registry == "BiosAttributeRegistry") ++ { ++ header = &message_registries::bios::header; ++ for (const message_registries::MessageEntry& entry : ++ message_registries::bios::registry) ++ { ++ registryEntries.emplace_back(&entry); ++ } ++ } + else + { + messages::resourceNotFound( -- 2.17.1 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0003-Add-support-to-ResetBios-action.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0003-Add-support-to-ResetBios-action.patch index a5c55afd1..5ed92cc3e 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0003-Add-support-to-ResetBios-action.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0003-Add-support-to-ResetBios-action.patch @@ -1,6 +1,6 @@ -From 415b5079ff45c1dabad15e0f751001a6265412e4 Mon Sep 17 00:00:00 2001 +From b7adca60dd69ac9566dc8f417065e244198fc711 Mon Sep 17 00:00:00 2001 From: AppaRao Puli -Date: Fri, 27 Aug 2021 13:02:20 +0000 +Date: Wed, 6 Oct 2021 22:27:20 +0000 Subject: [PATCH] Add support to ResetBios action Tested: @@ -10,44 +10,44 @@ POST https://IP_ADDR/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios Change-Id: Ic719c55705e5f634539b3dd858b60922e505a8d0 Signed-off-by: Kuiying Wang +Signed-off-by: AppaRao Puli + Signed-off-by: AppaRao Puli --- - redfish-core/lib/bios.hpp | 14 ++++++++++---- - 1 file changed, 10 insertions(+), 4 deletions(-) + redfish-core/lib/bios.hpp | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/redfish-core/lib/bios.hpp b/redfish-core/lib/bios.hpp -index 85ccaaa..360a749 100644 +index f5aa7b7..f613613 100644 --- a/redfish-core/lib/bios.hpp +++ b/redfish-core/lib/bios.hpp -@@ -737,18 +737,24 @@ inline void requestRoutesBiosReset(App& app) - .methods(boost::beast::http::verb::post)( - [](const crow::Request&, - const std::shared_ptr& asyncResp) { -+ std::string resetFlag = "xyz.openbmc_project.BIOSConfig." -+ "Manager.ResetFlag.FactoryDefaults"; +@@ -648,17 +648,23 @@ inline void + handleBiosResetPost(const crow::Request&, + const std::shared_ptr& asyncResp) + { ++ std::string resetFlag = ++ "xyz.openbmc_project.BIOSConfig.Manager.ResetFlag.FactoryDefaults"; + - crow::connections::systemBus->async_method_call( - [asyncResp](const boost::system::error_code ec) { - if (ec) - { -- BMCWEB_LOG_ERROR << "Failed to reset bios: " << ec; -+ BMCWEB_LOG_ERROR << "doPost bios reset got error " -+ << ec; - messages::internalError(asyncResp->res); - return; - } - }, -- "org.open_power.Software.Host.Updater", -- "/xyz/openbmc_project/software", -- "xyz.openbmc_project.Common.FactoryReset", "Reset"); -+ "xyz.openbmc_project.BIOSConfigManager", -+ "/xyz/openbmc_project/bios_config/manager", -+ "org.freedesktop.DBus.Properties", "Set", -+ "xyz.openbmc_project.BIOSConfig.Manager", -+ "ResetBIOSSettings", std::variant(resetFlag)); - }); + crow::connections::systemBus->async_method_call( + [asyncResp](const boost::system::error_code ec) { + if (ec) + { +- BMCWEB_LOG_ERROR << "Failed to reset bios: " << ec; ++ BMCWEB_LOG_ERROR << "doPost bios reset got error " << ec; + messages::internalError(asyncResp->res); + return; + } + }, +- "org.open_power.Software.Host.Updater", "/xyz/openbmc_project/software", +- "xyz.openbmc_project.Common.FactoryReset", "Reset"); ++ "xyz.openbmc_project.BIOSConfigManager", ++ "/xyz/openbmc_project/bios_config/manager", ++ "org.freedesktop.DBus.Properties", "Set", ++ "xyz.openbmc_project.BIOSConfig.Manager", "ResetBIOSSettings", ++ std::variant(resetFlag)); } - } // namespace redfish + + inline void requestRoutesBiosReset(App& app) -- 2.17.1 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0004-Add-support-to-ChangePassword-action.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0004-Add-support-to-ChangePassword-action.patch index 9a2fada9e..4bfca3006 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0004-Add-support-to-ChangePassword-action.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0004-Add-support-to-ChangePassword-action.patch @@ -1,7 +1,7 @@ -From 34f8680b21a134e2133bdcf41e1e83e4b4a05d28 Mon Sep 17 00:00:00 2001 -From: Krzysztof Grobelny -Date: Wed, 30 Jun 2021 15:37:47 +0000 -Subject: [PATCH 4/5] Add support to ChangePassword action +From 22956921a228f6f1cbbbd3045a3cc3969732dca3 Mon Sep 17 00:00:00 2001 +From: Arun Lal K M +Date: Fri, 8 Oct 2021 20:56:00 +0000 +Subject: [PATCH] Add support to ChangePassword action Tested: @@ -29,28 +29,29 @@ root@intel-obmc:~# cat /var/lib/bios-settings-manager/passwordData "UserName": "Administrator" } -Change-Id: I90319a68da0b0a7f9c5cd65a8cb8cf52269a5f52 +Signed-off-by: Arun Lal K M Signed-off-by: Kuiying Wang --- - redfish-core/lib/bios.hpp | 58 +++++++++++++++++++++++++++++++++++++++ - 1 file changed, 58 insertions(+) + redfish-core/lib/bios.hpp | 59 +++++++++++++++++++++++++++++++++++++++ + 1 file changed, 59 insertions(+) diff --git a/redfish-core/lib/bios.hpp b/redfish-core/lib/bios.hpp -index 49c0fd0..0250c59 100644 +index f613613..b06a904 100644 --- a/redfish-core/lib/bios.hpp +++ b/redfish-core/lib/bios.hpp -@@ -180,6 +180,9 @@ inline void requestRoutesBiosService(App& app) - asyncResp->res.jsonValue["Actions"]["#Bios.ResetBios"] = { - {"target", - "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios"}}; -+ asyncResp->res.jsonValue["Actions"]["#Bios.ChangePassword"] = { -+ {"target", "/redfish/v1/Systems/system/Bios/Actions/" -+ "Bios.ChangePassword"}}; +@@ -175,6 +175,10 @@ inline void + asyncResp->res.jsonValue["Actions"]["#Bios.ResetBios"] = { + {"target", "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios"}}; - // Get the ActiveSoftwareImage and SoftwareImages - fw_util::populateFirmwareInformation( -@@ -283,6 +286,61 @@ inline void requestRoutesBiosService(App& app) - }); ++ asyncResp->res.jsonValue["Actions"]["#Bios.ChangePassword"] = { ++ {"target", "/redfish/v1/Systems/system/Bios/Actions/" ++ "Bios.ChangePassword"}}; ++ + // Get the ActiveSoftwareImage and SoftwareImages + fw_util::populateFirmwareInformation(asyncResp, fw_util::biosPurpose, "", + true); +@@ -265,6 +269,61 @@ inline void requestRoutesBiosService(App& app) + .methods(boost::beast::http::verb::get)(handleBiosServiceGet); } +/** diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0006-Add-fix-for-broken-feature-Pending-Attributes.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0006-Add-fix-for-broken-feature-Pending-Attributes.patch index 0e4fc4903..2e72a639d 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0006-Add-fix-for-broken-feature-Pending-Attributes.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/biosconfig/0006-Add-fix-for-broken-feature-Pending-Attributes.patch @@ -1,6 +1,6 @@ -From 9814f83f36afafffa55bd19481654c064840e73d Mon Sep 17 00:00:00 2001 +From f75beb0472a42d5af512661470aadf12ac460470 Mon Sep 17 00:00:00 2001 From: Arun Lal K M -Date: Mon, 16 Aug 2021 17:49:11 +0000 +Date: Fri, 8 Oct 2021 21:30:33 +0000 Subject: [PATCH] Add fix for broken feature 'Pending Attributes'. Fix is added for the following: @@ -8,6 +8,8 @@ Fix is added for the following: 2) PATCH to 'redfish/v1/Systems/system/Bios/Settings'. 3) GET to 'redfish/v1/Systems/system/Bios/Settings'. 4) Fix for incremental duplicate values in BiosAttributeRegistry. +5) POST to '/redfish/v1/Systems/system/Bios/Actions + /Bios.ChangePassword/'. Tested: By giving PATCH to 'redfish/v1/Systems/system/Bios/Settings' @@ -105,6 +107,10 @@ Response: "Name": "Bios Settings Version 1" } +By giving POST to '/redfish/v1/Systems/system/Bios/Actions +/Bios.ChangePassword/' +Response: Success + By running Redfish-Service-Validator Result: Elapsed time: 0:09:36 @@ -124,14 +130,14 @@ warnDeprecated: 230 warningPresent: 54 Validation has succeeded. -Change-Id: Ib92eb7a1b81bef5adaf432b9225a183d7a78ebef Signed-off-by: Arun Lal K M +Signed-off-by: Snehalatha Venkatesh --- - redfish-core/lib/bios.hpp | 583 ++++++++++++++++++++++++-------------- - 1 file changed, 374 insertions(+), 209 deletions(-) + redfish-core/lib/bios.hpp | 586 ++++++++++++++++++++++++-------------- + 1 file changed, 376 insertions(+), 210 deletions(-) diff --git a/redfish-core/lib/bios.hpp b/redfish-core/lib/bios.hpp -index 360a749..a927772 100644 +index 0bb0b9e..de79be2 100644 --- a/redfish-core/lib/bios.hpp +++ b/redfish-core/lib/bios.hpp @@ -12,13 +12,15 @@ map{attributeName,struct{attributeType,readonlyStatus,displayname, @@ -249,49 +255,52 @@ index 360a749..a927772 100644 static std::string mapBoundTypeToRedfish(const std::string_view typeDbus) { std::string ret; -@@ -208,6 +170,15 @@ inline void requestRoutesBiosService(App& app) +@@ -201,6 +163,15 @@ inline void - return; - } + return; + } + -+ if (getObjectType.empty()) -+ { -+ BMCWEB_LOG_ERROR << "getObjectType is empty."; -+ messages::internalError(asyncResp->res); ++ if (getObjectType.empty()) ++ { ++ BMCWEB_LOG_ERROR << "getObjectType is empty."; ++ messages::internalError(asyncResp->res); + -+ return; -+ } ++ return; ++ } + - const std::string& service = - getObjectType.begin()->first; + const std::string& service = getObjectType.begin()->first; -@@ -231,7 +202,7 @@ inline void requestRoutesBiosService(App& app) - if (baseBiosTable == nullptr) - { - BMCWEB_LOG_ERROR -- << "baseBiosTable == nullptr "; -+ << "baseBiosTable is empty"; - messages::internalError(asyncResp->res); - return; - } -@@ -269,7 +240,6 @@ inline void requestRoutesBiosService(App& app) - { - BMCWEB_LOG_ERROR - << "Unsupported attribute type."; -- messages::internalError(asyncResp->res); - } - } - }, -@@ -293,7 +263,7 @@ inline void requestRoutesBiosService(App& app) + crow::connections::systemBus->async_method_call( +@@ -220,7 +191,7 @@ inline void + asyncResp->res.jsonValue["Attributes"]; + if (baseBiosTable == nullptr) + { +- BMCWEB_LOG_ERROR << "baseBiosTable == nullptr "; ++ BMCWEB_LOG_ERROR << "baseBiosTable is empty"; + messages::internalError(asyncResp->res); + return; + } +@@ -248,7 +219,6 @@ inline void + else + { + BMCWEB_LOG_ERROR << "Unsupported attribute type."; +- messages::internalError(asyncResp->res); + } + } + }, +@@ -275,8 +245,9 @@ inline void requestRoutesBiosService(App& app) + */ inline void requestRoutesBiosChangePassword(App& app) { - BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/") +- BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/") - .privileges({{"ConfigureComponents"}}) ++ BMCWEB_ROUTE(app, ++ "/redfish/v1/Systems/system/Bios/Actions/Bios.ChangePassword/") + .privileges(redfish::privileges::postBios) .methods(boost::beast::http::verb::post)( [](const crow::Request& req, const std::shared_ptr& asyncResp) { -@@ -359,180 +329,298 @@ inline void requestRoutesBiosSettings(App& app) +@@ -342,180 +313,298 @@ inline void requestRoutesBiosSettings(App& app) { BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/Settings") .privileges(redfish::privileges::getBios) @@ -341,9 +350,7 @@ index 360a749..a927772 100644 - return; - } - std::string service = getObjectType.begin()->first; -+ return; -+ } - +- - crow::connections::systemBus->async_method_call( - [asyncResp]( - const boost::system::error_code ec, @@ -372,6 +379,9 @@ index 360a749..a927772 100644 - } - for (const PendingAttributesItemType& item : - *pendingAttributes) ++ return; ++ } ++ + if (getObjectType.empty()) + { + BMCWEB_LOG_ERROR << "getObjectType is empty."; @@ -525,32 +535,24 @@ index 360a749..a927772 100644 - [](const crow::Request& req, - const std::shared_ptr& asyncResp) { - nlohmann::json inpJson; -- -- if (!redfish::json_util::readJson(req, asyncResp->res, "data", -- inpJson)) -- { -- return; -- } + .privileges(redfish::privileges::patchBios) + .methods( + boost::beast::http::verb:: + patch)([](const crow::Request& req, + const std::shared_ptr& asyncResp) { + nlohmann::json inpJson; -+ + +- if (!redfish::json_util::readJson(req, asyncResp->res, "data", +- inpJson)) +- { +- return; +- } + if (!redfish::json_util::readJson(req, asyncResp->res, "data", + inpJson)) + { + BMCWEB_LOG_ERROR << "No 'data' in req!"; + return; + } -+ -+ if (inpJson.empty()) -+ { -+ messages::invalidObject(asyncResp->res, "data"); -+ BMCWEB_LOG_ERROR << "No input in req!"; -+ return; -+ } - for (auto& attrInfo : inpJson) - { @@ -573,6 +575,13 @@ index 360a749..a927772 100644 - } - if (!json_util::getValueFromJsonObject( - attrInfo, "AttributeValue", attrValue)) ++ if (inpJson.empty()) ++ { ++ messages::invalidObject(asyncResp->res, "data"); ++ BMCWEB_LOG_ERROR << "No input in req!"; ++ return; ++ } ++ + crow::connections::systemBus->async_method_call( + [asyncResp, inpJson](const boost::system::error_code ec, + const GetObjectType& getObjectType) { @@ -616,9 +625,9 @@ index 360a749..a927772 100644 BMCWEB_LOG_ERROR - << "doPatch resp_handler got error " << ec; + << "getBiosAttributes DBUS error: " << ec; - messages::internalError(asyncResp->res); - return; - } ++ messages::internalError(asyncResp->res); ++ return; ++ } + + const BiosBaseTableType* baseBiosTable = + std::get_if(&retBiosTable); @@ -626,9 +635,9 @@ index 360a749..a927772 100644 + if (baseBiosTable == nullptr) + { + BMCWEB_LOG_ERROR << "baseBiosTable is empty."; -+ messages::internalError(asyncResp->res); -+ return; -+ } + messages::internalError(asyncResp->res); + return; + } + + PendingAttributesType pendingAttributes{}; + @@ -732,7 +741,7 @@ index 360a749..a927772 100644 } /** * BiosAttributeRegistry class supports handle get method for BIOS attribute -@@ -572,6 +660,15 @@ inline void requestRoutesBiosAttributeRegistry(App& app) +@@ -555,6 +644,15 @@ inline void requestRoutesBiosAttributeRegistry(App& app) return; } @@ -748,7 +757,7 @@ index 360a749..a927772 100644 std::string service = getObjectType.begin()->first; crow::connections::systemBus->async_method_call( -@@ -592,8 +689,6 @@ inline void requestRoutesBiosAttributeRegistry(App& app) +@@ -575,8 +673,6 @@ inline void requestRoutesBiosAttributeRegistry(App& app) nlohmann::json& attributeArray = asyncResp->res .jsonValue["RegistryEntries"]["Attributes"]; @@ -757,7 +766,7 @@ index 360a749..a927772 100644 if (baseBiosTable == nullptr) { BMCWEB_LOG_ERROR << "baseBiosTable == nullptr "; -@@ -609,10 +704,11 @@ inline void requestRoutesBiosAttributeRegistry(App& app) +@@ -592,10 +688,11 @@ inline void requestRoutesBiosAttributeRegistry(App& app) mapAttrTypeToRedfish(itemType); if (attrType == "UNKNOWN") { @@ -772,7 +781,7 @@ index 360a749..a927772 100644 nlohmann::json attributeItem; attributeItem["AttributeName"] = item.first; attributeItem["Type"] = attrType; -@@ -632,10 +728,30 @@ inline void requestRoutesBiosAttributeRegistry(App& app) +@@ -615,10 +712,30 @@ inline void requestRoutesBiosAttributeRegistry(App& app) std::get_if( &std::get( item.second)); @@ -803,7 +812,7 @@ index 360a749..a927772 100644 attributeItem["CurrentValue"] = currValue != nullptr ? *currValue : ""; attributeItem["DefaultValue"] = -@@ -647,10 +763,30 @@ inline void requestRoutesBiosAttributeRegistry(App& app) +@@ -630,10 +747,30 @@ inline void requestRoutesBiosAttributeRegistry(App& app) std::get_if( &std::get( item.second)); @@ -834,7 +843,7 @@ index 360a749..a927772 100644 attributeItem["CurrentValue"] = currValue != nullptr ? *currValue : 0; attributeItem["DefaultValue"] = -@@ -658,12 +794,13 @@ inline void requestRoutesBiosAttributeRegistry(App& app) +@@ -641,12 +778,13 @@ inline void requestRoutesBiosAttributeRegistry(App& app) } else { @@ -852,7 +861,7 @@ index 360a749..a927772 100644 const std::vector& optionsVector = std::get(item.second); -@@ -678,9 +815,9 @@ inline void requestRoutesBiosAttributeRegistry(App& app) +@@ -661,9 +799,9 @@ inline void requestRoutesBiosAttributeRegistry(App& app) if (optItemTypeRedfish == "UNKNOWN") { BMCWEB_LOG_ERROR @@ -865,7 +874,7 @@ index 360a749..a927772 100644 } if (optItemTypeRedfish == "OneOf") { -@@ -688,6 +825,17 @@ inline void requestRoutesBiosAttributeRegistry(App& app) +@@ -671,6 +809,17 @@ inline void requestRoutesBiosAttributeRegistry(App& app) std::get_if( &std::get( optItem)); @@ -883,7 +892,7 @@ index 360a749..a927772 100644 optItemJson[optItemTypeRedfish] = currValue != nullptr ? *currValue : ""; -@@ -698,6 +846,17 @@ inline void requestRoutesBiosAttributeRegistry(App& app) +@@ -681,6 +830,17 @@ inline void requestRoutesBiosAttributeRegistry(App& app) std::get_if( &std::get( optItem)); @@ -901,7 +910,7 @@ index 360a749..a927772 100644 optItemJson[optItemTypeRedfish] = currValue != nullptr ? *currValue : 0; -@@ -706,6 +865,12 @@ inline void requestRoutesBiosAttributeRegistry(App& app) +@@ -689,6 +849,12 @@ inline void requestRoutesBiosAttributeRegistry(App& app) optionsArray.push_back(optItemJson); } diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0001-Add-unmerged-changes-for-http-retry-support.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0001-Add-unmerged-changes-for-http-retry-support.patch new file mode 100644 index 000000000..52135e255 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0001-Add-unmerged-changes-for-http-retry-support.patch @@ -0,0 +1,121 @@ +From 6ff897d2b5513f15445f18aae16d8439ed94f377 Mon Sep 17 00:00:00 2001 +From: P Dheeraj Srujan Kumar +Date: Mon, 11 Oct 2021 18:41:27 +0530 +Subject: [PATCH] Add unmerged changes for http retry support + +The http retry support added upstream as a single patch was slpit into +3 patches, but only 2 of them was merged. +This commit pulls in the differentail changes required to complete the +entire http retry support. and also allow for other subsequent patches +to be appplied easily. + +Change-Id: Id8ccd991b7ffc505196b1a92b23e1cd51e00bc89 +Signed-off-by: P Dheeraj Srujan Kumar +--- + http/http_client.hpp | 44 +++++++++++-------- + .../include/event_service_manager.hpp | 2 +- + 2 files changed, 27 insertions(+), 19 deletions(-) + +diff --git a/http/http_client.hpp b/http/http_client.hpp +index ab20eb0..aad1cce 100644 +--- a/http/http_client.hpp ++++ b/http/http_client.hpp +@@ -68,7 +68,6 @@ class HttpClient : public std::enable_shared_from_this + std::optional< + boost::beast::http::response_parser> + parser; +- std::vector> headers; + boost::circular_buffer_space_optimized requestDataQueue{}; + + ConnState state; +@@ -137,18 +136,6 @@ class HttpClient : public std::enable_shared_from_this + + BMCWEB_LOG_DEBUG << __FUNCTION__ << "(): " << host << ":" << port; + +- req.version(static_cast(11)); // HTTP 1.1 +- req.target(uri); +- req.method(boost::beast::http::verb::post); +- +- // Set headers +- for (const auto& [key, value] : headers) +- { +- req.set(key, value); +- } +- req.set(boost::beast::http::field::host, host); +- req.keep_alive(true); +- + req.body() = data; + req.prepare_payload(); + +@@ -204,6 +191,17 @@ class HttpClient : public std::enable_shared_from_this + BMCWEB_LOG_DEBUG << "recvMessage() data: " + << self->parser->get(); + ++ // Check if the response and header are received ++ if (!self->parser->is_done()) ++ { ++ // The parser failed to receive the response ++ BMCWEB_LOG_ERROR ++ << "recvMessage() parser failed to receive response"; ++ self->state = ConnState::recvFailed; ++ self->handleConnState(); ++ return; ++ } ++ + unsigned int respCode = self->parser->get().result_int(); + BMCWEB_LOG_DEBUG << "recvMessage() Header Response Code: " + << respCode; +@@ -398,11 +396,17 @@ class HttpClient : public std::enable_shared_from_this + const std::string& destIP, const std::string& destPort, + const std::string& destUri) : + conn(ioc), +- timer(ioc), subId(id), host(destIP), port(destPort), uri(destUri), +- retryCount(0), maxRetryAttempts(5), retryIntervalSecs(0), ++ timer(ioc), req(boost::beast::http::verb::post, destUri, 11), ++ state(ConnState::initialized), subId(id), host(destIP), port(destPort), ++ uri(destUri), retryCount(0), maxRetryAttempts(5), retryIntervalSecs(0), + retryPolicyAction("TerminateAfterRetries"), runningTimer(false) + { +- state = ConnState::initialized; ++ // Set the request header ++ req.set(boost::beast::http::field::host, host); ++ req.set(boost::beast::http::field::content_type, "application/json"); ++ req.keep_alive(true); ++ ++ requestDataQueue.set_capacity(maxRequestQueueSize); + } + + void sendData(const std::string& data) +@@ -425,10 +429,14 @@ class HttpClient : public std::enable_shared_from_this + return; + } + +- void setHeaders( ++ void addHeaders( + const std::vector>& httpHeaders) + { +- headers = httpHeaders; ++ // Set custom headers ++ for (const auto& [key, value] : httpHeaders) ++ { ++ req.set(key, value); ++ } + } + + void setRetryConfig(const uint32_t retryAttempts, +diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp +index 8042803..0a63b8c 100644 +--- a/redfish-core/include/event_service_manager.hpp ++++ b/redfish-core/include/event_service_manager.hpp +@@ -412,7 +412,7 @@ class Subscription : public persistent_data::UserSubscription + reqHeaders.emplace_back(std::pair(key, val)); + } + } +- conn->setHeaders(reqHeaders); ++ conn->addHeaders(reqHeaders); + conn->sendData(msg); + this->eventSeqNum++; + } +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0001-EventService-Fix-retry-handling-for-http-client.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0001-EventService-Fix-retry-handling-for-http-client.patch deleted file mode 100644 index 7a6818008..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0001-EventService-Fix-retry-handling-for-http-client.patch +++ /dev/null @@ -1,546 +0,0 @@ -From f74393a9bca899e353be3d0e2dc5c224539fe432 Mon Sep 17 00:00:00 2001 -From: Sunitha Harish -Date: Fri, 19 Feb 2021 13:38:31 +0530 -Subject: [PATCH] EventService : Fix retry handling for http-client - -When the event send/receive is failed, the bmcweb does not handle -the failure to tear-down the complete connection and start a fresh - -The keep-alive header from the event listener is read to update -the connection states, so that the connection will be kept alive -or closed as per the subscriber's specifications - -Updated the connection state machine to handle retry logic properly. -Avoided multiple simultaneous async calls which crashes the bmcweb. So -added connBusy flag which protects simultaneous async calls. - -Used boost http response parser as parser for producing the response -message. Set the parser skip option to handle the empty response message -from listening server. - -Tested by: - - Subscribe for the events at BMC using DMTF event listener - - Generate an event and see the same is received at the listener's console - - Update the listner to change the keep-alive to true/false and - observe the http-client connection states at bmcweb - - Changed listener client to return non success HTTP status code - and observed retry logic gets trigrred in http-client. - - Gave wrong fqdn and observed async resolve failure and retry logc. - - Stopped listener after connect and verified timeouts on http-client - side. - -Change-Id: Ibb45691f139916ba2954da37beda9d4f91c7cef3 -Signed-off-by: Sunitha Harish -Signed-off-by: AppaRao Puli ---- - http/http_client.hpp | 288 ++++++++++-------- - .../include/event_service_manager.hpp | 2 +- - 2 files changed, 162 insertions(+), 128 deletions(-) - -diff --git a/http/http_client.hpp b/http/http_client.hpp -index 992ac2b..feabbba 100644 ---- a/http/http_client.hpp -+++ b/http/http_client.hpp -@@ -34,22 +34,28 @@ namespace crow - { - - static constexpr uint8_t maxRequestQueueSize = 50; -+static constexpr unsigned int httpReadBodyLimit = 8192; - - enum class ConnState - { - initialized, - resolveInProgress, - resolveFailed, -+ resolved, - connectInProgress, - connectFailed, - connected, - sendInProgress, - sendFailed, -+ recvInProgress, - recvFailed, - idle, -- suspended, -+ closeInProgress, - closed, -- terminated -+ suspended, -+ terminated, -+ abortConnection, -+ retry - }; - - class HttpClient : public std::enable_shared_from_this -@@ -58,11 +64,13 @@ class HttpClient : public std::enable_shared_from_this - crow::async_resolve::Resolver resolver; - boost::beast::tcp_stream conn; - boost::asio::steady_timer timer; -- boost::beast::flat_buffer buffer; -+ boost::beast::flat_static_buffer buffer; - boost::beast::http::request req; -- boost::beast::http::response res; -- std::vector> headers; -- std::queue requestDataQueue; -+ std::optional< -+ boost::beast::http::response_parser> -+ parser; -+ boost::circular_buffer_space_optimized requestDataQueue{}; -+ std::vector endPoints; - ConnState state; - std::string subId; - std::string host; -@@ -76,12 +84,7 @@ class HttpClient : public std::enable_shared_from_this - - void doResolve() - { -- if (state == ConnState::resolveInProgress) -- { -- return; -- } - state = ConnState::resolveInProgress; -- - BMCWEB_LOG_DEBUG << "Trying to resolve: " << host << ":" << port; - - auto respHandler = -@@ -89,78 +92,56 @@ class HttpClient : public std::enable_shared_from_this - const boost::beast::error_code ec, - const std::vector& - endpointList) { -- if (ec) -+ if (ec || (endpointList.size() == 0)) - { - BMCWEB_LOG_ERROR << "Resolve failed: " << ec.message(); - self->state = ConnState::resolveFailed; -- self->checkQueue(); -+ self->handleConnState(); - return; - } - BMCWEB_LOG_DEBUG << "Resolved"; -- self->doConnect(endpointList); -+ self->endPoints.assign(endpointList.begin(), -+ endpointList.end()); -+ self->state = ConnState::resolved; -+ self->handleConnState(); - }; - resolver.asyncResolve(host, port, std::move(respHandler)); - } - -- void doConnect( -- const std::vector& endpointList) -+ void doConnect() - { -- if (state == ConnState::connectInProgress) -- { -- return; -- } - state = ConnState::connectInProgress; - - BMCWEB_LOG_DEBUG << "Trying to connect to: " << host << ":" << port; - - conn.expires_after(std::chrono::seconds(30)); - conn.async_connect( -- endpointList, [self(shared_from_this())]( -- const boost::beast::error_code ec, -- const boost::asio::ip::tcp::endpoint& endpoint) { -+ endPoints, [self(shared_from_this())]( -+ const boost::beast::error_code ec, -+ const boost::asio::ip::tcp::endpoint& endpoint) { - if (ec) - { - BMCWEB_LOG_ERROR << "Connect " << endpoint - << " failed: " << ec.message(); - self->state = ConnState::connectFailed; -- self->checkQueue(); -+ self->handleConnState(); - return; - } -- self->state = ConnState::connected; - BMCWEB_LOG_DEBUG << "Connected to: " << endpoint; -- -- self->checkQueue(); -+ self->state = ConnState::connected; -+ self->handleConnState(); - }); - } - - void sendMessage(const std::string& data) - { -- if (state == ConnState::sendInProgress) -- { -- return; -- } - state = ConnState::sendInProgress; - - BMCWEB_LOG_DEBUG << __FUNCTION__ << "(): " << host << ":" << port; - -- req.version(static_cast(11)); // HTTP 1.1 -- req.target(uri); -- req.method(boost::beast::http::verb::post); -- -- // Set headers -- for (const auto& [key, value] : headers) -- { -- req.set(key, value); -- } -- req.set(boost::beast::http::field::host, host); -- req.keep_alive(true); -- - req.body() = data; - req.prepare_payload(); - -- // Set a timeout on the operation -- conn.expires_after(std::chrono::seconds(30)); -- - // Send the HTTP request to the remote host - boost::beast::http::async_write( - conn, req, -@@ -171,7 +152,7 @@ class HttpClient : public std::enable_shared_from_this - BMCWEB_LOG_ERROR << "sendMessage() failed: " - << ec.message(); - self->state = ConnState::sendFailed; -- self->checkQueue(); -+ self->handleConnState(); - return; - } - BMCWEB_LOG_DEBUG << "sendMessage() bytes transferred: " -@@ -184,9 +165,17 @@ class HttpClient : public std::enable_shared_from_this - - void recvMessage() - { -+ state = ConnState::recvInProgress; -+ -+ parser.emplace(std::piecewise_construct, std::make_tuple()); -+ parser->body_limit(httpReadBodyLimit); -+ -+ // Check only for the response header -+ parser->skip(true); -+ - // Receive the HTTP response - boost::beast::http::async_read( -- conn, buffer, res, -+ conn, buffer, *parser, - [self(shared_from_this())](const boost::beast::error_code& ec, - const std::size_t& bytesTransferred) { - if (ec) -@@ -194,30 +183,47 @@ class HttpClient : public std::enable_shared_from_this - BMCWEB_LOG_ERROR << "recvMessage() failed: " - << ec.message(); - self->state = ConnState::recvFailed; -- self->checkQueue(); -+ self->handleConnState(); - return; - } - BMCWEB_LOG_DEBUG << "recvMessage() bytes transferred: " - << bytesTransferred; -- boost::ignore_unused(bytesTransferred); -- -- // Discard received data. We are not interested. -- BMCWEB_LOG_DEBUG << "recvMessage() data: " << self->res; -+ BMCWEB_LOG_DEBUG << "recvMessage() data: " -+ << self->parser->get(); - - // Send is successful, Lets remove data from queue - // check for next request data in queue. -- self->requestDataQueue.pop(); -+ if (!self->requestDataQueue.empty()) -+ { -+ self->requestDataQueue.pop_front(); -+ } - self->state = ConnState::idle; -- self->checkQueue(); -+ -+ // Keep the connection alive if server supports it -+ // Else close the connection -+ BMCWEB_LOG_DEBUG << "recvMessage() keepalive : " -+ << self->parser->keep_alive(); -+ if (!self->parser->keep_alive()) -+ { -+ // Abort the connection since server is not keep-alive -+ // enabled -+ self->state = ConnState::abortConnection; -+ } -+ -+ // Returns ownership of the parsed message -+ self->parser->release(); -+ -+ self->handleConnState(); - }); - } - - void doClose() - { -+ state = ConnState::closeInProgress; - boost::beast::error_code ec; - conn.socket().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec); -+ conn.close(); - -- state = ConnState::closed; - // not_connected happens sometimes so don't bother reporting it. - if (ec && ec != boost::beast::errc::not_connected) - { -@@ -225,112 +231,139 @@ class HttpClient : public std::enable_shared_from_this - return; - } - BMCWEB_LOG_DEBUG << "Connection closed gracefully"; -- } -- -- void checkQueue(const bool newRecord = false) -- { -- if (requestDataQueue.empty()) -+ if ((state != ConnState::suspended) && (state != ConnState::terminated)) - { -- // TODO: Having issue in keeping connection alive. So lets close if -- // nothing to be transferred. -- doClose(); -- -- BMCWEB_LOG_DEBUG << "requestDataQueue is empty\n"; -- return; -+ state = ConnState::closed; -+ handleConnState(); - } -+ } - -+ void waitAndRetry() -+ { - if (retryCount >= maxRetryAttempts) - { -- BMCWEB_LOG_ERROR << "Maximum number of retries is reached."; -+ BMCWEB_LOG_ERROR << "Maximum number of retries reached."; - - // Clear queue. - while (!requestDataQueue.empty()) - { -- requestDataQueue.pop(); -+ requestDataQueue.pop_front(); - } - -- BMCWEB_LOG_DEBUG << "Retry policy is set to " << retryPolicyAction; -+ BMCWEB_LOG_DEBUG << "Retry policy: " << retryPolicyAction; - if (retryPolicyAction == "TerminateAfterRetries") - { - // TODO: delete subscription - state = ConnState::terminated; -- return; - } - if (retryPolicyAction == "SuspendRetries") - { - state = ConnState::suspended; -- return; - } -- // keep retrying, reset count and continue. -+ // Reset the retrycount to zero so that client can try connecting -+ // again if needed - retryCount = 0; -+ handleConnState(); -+ return; - } - -- if ((state == ConnState::connectFailed) || -- (state == ConnState::sendFailed) || -- (state == ConnState::recvFailed)) -+ if (runningTimer) - { -- if (newRecord) -- { -- // We are already running async wait and retry. -- // Since record is added to queue, it gets the -- // turn in FIFO. -- return; -- } -- -- if (runningTimer) -- { -- BMCWEB_LOG_DEBUG << "Retry timer is already running."; -- return; -- } -- runningTimer = true; -- -- retryCount++; -- -- BMCWEB_LOG_DEBUG << "Attempt retry after " << retryIntervalSecs -- << " seconds. RetryCount = " << retryCount; -- timer.expires_after(std::chrono::seconds(retryIntervalSecs)); -- timer.async_wait( -- [self = shared_from_this()](const boost::system::error_code&) { -- self->runningTimer = false; -- self->connStateCheck(); -- }); -+ BMCWEB_LOG_DEBUG << "Retry timer is already running."; - return; - } -- // reset retry count. -- retryCount = 0; -- connStateCheck(); -+ runningTimer = true; -+ -+ retryCount++; -+ -+ BMCWEB_LOG_DEBUG << "Attempt retry after " << retryIntervalSecs -+ << " seconds. RetryCount = " << retryCount; -+ timer.expires_after(std::chrono::seconds(retryIntervalSecs)); -+ timer.async_wait( -+ [self = shared_from_this()](const boost::system::error_code ec) { -+ if (ec) -+ { -+ BMCWEB_LOG_ERROR << "async_wait failed: " << ec.message(); -+ // Ignore the error and continue the retry loop to attempt -+ // sending the event as per the retry policy -+ } -+ self->runningTimer = false; - -+ // Lets close connection and start from resolve. -+ self->doClose(); -+ }); - return; - } - -- void connStateCheck() -+ void handleConnState() - { - switch (state) - { - case ConnState::resolveInProgress: - case ConnState::connectInProgress: - case ConnState::sendInProgress: -- case ConnState::suspended: -- case ConnState::terminated: -- // do nothing -+ case ConnState::recvInProgress: -+ case ConnState::closeInProgress: -+ { -+ BMCWEB_LOG_DEBUG << "Async operation is already in progress"; - break; -+ } - case ConnState::initialized: - case ConnState::closed: -+ { -+ if (requestDataQueue.empty()) -+ { -+ BMCWEB_LOG_DEBUG << "requestDataQueue is empty"; -+ return; -+ } -+ doResolve(); -+ break; -+ } -+ case ConnState::resolved: -+ { -+ doConnect(); -+ break; -+ } -+ case ConnState::suspended: -+ case ConnState::terminated: -+ { -+ doClose(); -+ break; -+ } -+ case ConnState::resolveFailed: - case ConnState::connectFailed: - case ConnState::sendFailed: - case ConnState::recvFailed: -- case ConnState::resolveFailed: -+ case ConnState::retry: - { -- doResolve(); -+ // In case of failures during connect and handshake -+ // the retry policy will be applied -+ waitAndRetry(); - break; - } - case ConnState::connected: - case ConnState::idle: - { -+ // State idle means, previous attempt is successful -+ // State connected means, client connection is established -+ // successfully -+ if (requestDataQueue.empty()) -+ { -+ BMCWEB_LOG_DEBUG << "requestDataQueue is empty"; -+ return; -+ } - std::string data = requestDataQueue.front(); - sendMessage(data); - break; - } -+ case ConnState::abortConnection: -+ { -+ // Server did not want to keep alive the session -+ doClose(); -+ break; -+ } -+ default: -+ break; - } - } - -@@ -339,37 +372,38 @@ class HttpClient : public std::enable_shared_from_this - const std::string& destIP, const std::string& destPort, - const std::string& destUri) : - conn(ioc), -- timer(ioc), subId(id), host(destIP), port(destPort), uri(destUri), -- retryCount(0), maxRetryAttempts(5), retryIntervalSecs(0), -+ timer(ioc), req(boost::beast::http::verb::post, destUri, 11), -+ state(ConnState::initialized), subId(id), host(destIP), port(destPort), -+ uri(destUri), retryCount(0), maxRetryAttempts(5), retryIntervalSecs(0), - retryPolicyAction("TerminateAfterRetries"), runningTimer(false) - { -- state = ConnState::initialized; -+ // Set the request header -+ req.set(boost::beast::http::field::host, host); -+ req.set(boost::beast::http::field::content_type, "application/json"); -+ req.keep_alive(true); -+ -+ requestDataQueue.set_capacity(maxRequestQueueSize); - } - - void sendData(const std::string& data) - { -- if (state == ConnState::suspended) -+ if ((state == ConnState::suspended) || (state == ConnState::terminated)) - { - return; - } -- -- if (requestDataQueue.size() <= maxRequestQueueSize) -- { -- requestDataQueue.push(data); -- checkQueue(true); -- } -- else -- { -- BMCWEB_LOG_ERROR << "Request queue is full. So ignoring data."; -- } -- -+ requestDataQueue.push_back(data); -+ handleConnState(); - return; - } - -- void setHeaders( -+ void addHeaders( - const std::vector>& httpHeaders) - { -- headers = httpHeaders; -+ // Set custom headers -+ for (const auto& [key, value] : httpHeaders) -+ { -+ req.set(key, value); -+ } - } - - void setRetryConfig(const uint32_t retryAttempts, -diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp -index 11190ef..a8f7517 100644 ---- a/redfish-core/include/event_service_manager.hpp -+++ b/redfish-core/include/event_service_manager.hpp -@@ -422,7 +422,7 @@ class Subscription - reqHeaders.emplace_back(std::pair(key, val)); - } - } -- conn->setHeaders(reqHeaders); -+ conn->addHeaders(reqHeaders); - conn->sendData(msg); - this->eventSeqNum++; - } --- -2.25.1 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0002-EventService-https-client-support.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0002-EventService-https-client-support.patch index eef0ff065..aeeafc421 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0002-EventService-https-client-support.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0002-EventService-https-client-support.patch @@ -1,28 +1,27 @@ -From 4df4a36d6d2cc11c51cc9d53cd441178cc97e39b Mon Sep 17 00:00:00 2001 +From 3f2ad28e6e124249cde3df50c9e18c283fbcbf3e Mon Sep 17 00:00:00 2001 From: AppaRao Puli Date: Mon, 22 Feb 2021 17:07:47 +0000 Subject: [PATCH] EventService: https client support -Add https client support for push style -eventing. Using this BMC can push the event -logs/telemetry data to event listener over -secure http channel. +Add https client support for push style eventing. Using this BMC can +push the event logs/telemetry data to event listener over secure http +channel. Tested: - - Created subscription with https destination - url. Using SubmitTestEvent action set the - event and can see event on event listener. + - Created subscription with https destination url. Using + SubmitTestEvent action set the event and can see event on event + listener. - Validator passed. Change-Id: I44c3918b39baa2eb5fddda9d635f99aa280a422a Signed-off-by: AppaRao Puli --- - http/http_client.hpp | 257 ++++++++++++------ + http/http_client.hpp | 307 ++++++++++++------ .../include/event_service_manager.hpp | 2 +- - 2 files changed, 176 insertions(+), 83 deletions(-) + 2 files changed, 202 insertions(+), 107 deletions(-) diff --git a/http/http_client.hpp b/http/http_client.hpp -index feabbba..aaf1b2d 100644 +index aad1cce..5e7ff47 100644 --- a/http/http_client.hpp +++ b/http/http_client.hpp @@ -20,6 +20,7 @@ @@ -33,8 +32,8 @@ index feabbba..aaf1b2d 100644 #include #include -@@ -44,6 +45,8 @@ enum class ConnState - resolved, +@@ -43,6 +44,8 @@ enum class ConnState + resolveFailed, connectInProgress, connectFailed, + handshakeInProgress, @@ -42,7 +41,7 @@ index feabbba..aaf1b2d 100644 connected, sendInProgress, sendFailed, -@@ -62,7 +65,9 @@ class HttpClient : public std::enable_shared_from_this +@@ -61,7 +64,9 @@ class HttpClient : public std::enable_shared_from_this { private: crow::async_resolve::Resolver resolver; @@ -52,8 +51,8 @@ index feabbba..aaf1b2d 100644 boost::asio::steady_timer timer; boost::beast::flat_static_buffer buffer; boost::beast::http::request req; -@@ -111,23 +116,52 @@ class HttpClient : public std::enable_shared_from_this - void doConnect() +@@ -108,23 +113,52 @@ class HttpClient : public std::enable_shared_from_this + const std::vector& endpointList) { state = ConnState::connectInProgress; + sslConn.emplace(conn, ctx); @@ -83,10 +82,10 @@ index feabbba..aaf1b2d 100644 + }; conn.expires_after(std::chrono::seconds(30)); - conn.async_connect( -- endPoints, [self(shared_from_this())]( -- const boost::beast::error_code ec, -- const boost::asio::ip::tcp::endpoint& endpoint) { -+ conn.async_connect(endPoints, std::move(respHandler)); +- endpointList, [self(shared_from_this())]( +- const boost::beast::error_code ec, +- const boost::asio::ip::tcp::endpoint& endpoint) { ++ conn.async_connect(endpointList, std::move(respHandler)); + } + + void performHandshake() @@ -113,7 +112,7 @@ index feabbba..aaf1b2d 100644 self->state = ConnState::connected; self->handleConnState(); }); -@@ -135,106 +169,159 @@ class HttpClient : public std::enable_shared_from_this +@@ -132,132 +166,187 @@ class HttpClient : public std::enable_shared_from_this void sendMessage(const std::string& data) { @@ -125,6 +124,19 @@ index feabbba..aaf1b2d 100644 req.body() = data; req.prepare_payload(); +- // Set a timeout on the operation +- conn.expires_after(std::chrono::seconds(30)); ++ auto respHandler = [self(shared_from_this())]( ++ const boost::beast::error_code ec, ++ const std::size_t& bytesTransferred) { ++ if (ec) ++ { ++ BMCWEB_LOG_ERROR << "sendMessage() failed: " << ec.message(); ++ self->state = ConnState::sendFailed; ++ self->handleConnState(); ++ return; ++ } + - // Send the HTTP request to the remote host - boost::beast::http::async_write( - conn, req, @@ -141,26 +153,15 @@ index feabbba..aaf1b2d 100644 - BMCWEB_LOG_DEBUG << "sendMessage() bytes transferred: " - << bytesTransferred; - boost::ignore_unused(bytesTransferred); -+ auto respHandler = [self(shared_from_this())]( -+ const boost::beast::error_code ec, -+ const std::size_t& bytesTransferred) { -+ if (ec) -+ { -+ BMCWEB_LOG_ERROR << "sendMessage() failed: " << ec.message(); -+ self->state = ConnState::sendFailed; -+ self->handleConnState(); -+ return; -+ } - -- self->recvMessage(); -- }); -- } + BMCWEB_LOG_DEBUG << "sendMessage() bytes transferred: " + << bytesTransferred; + boost::ignore_unused(bytesTransferred); + self->recvMessage(); + }; +- self->recvMessage(); +- }); ++ // Set a timeout on the operation + conn.expires_after(std::chrono::seconds(30)); + if (sslConn) + { @@ -171,7 +172,8 @@ index feabbba..aaf1b2d 100644 + { + boost::beast::http::async_write(conn, req, std::move(respHandler)); + } -+ } + } +- void recvMessage() { state = ConnState::recvInProgress; @@ -191,6 +193,33 @@ index feabbba..aaf1b2d 100644 + BMCWEB_LOG_DEBUG << "recvMessage() bytes transferred: " + << bytesTransferred; + boost::ignore_unused(bytesTransferred); ++ ++ // Check if the response and header are received ++ if (!self->parser->is_done()) ++ { ++ // The parser failed to receive the response ++ BMCWEB_LOG_ERROR ++ << "recvMessage() parser failed to receive response"; ++ self->state = ConnState::recvFailed; ++ self->handleConnState(); ++ return; ++ } ++ ++ unsigned int respCode = self->parser->get().result_int(); ++ BMCWEB_LOG_DEBUG << "recvMessage() Header Response Code: " ++ << respCode; ++ ++ // 2XX response is considered to be successful ++ if ((respCode < 200) || (respCode >= 300)) ++ { ++ // The listener failed to receive the Sent-Event ++ BMCWEB_LOG_ERROR << "recvMessage() Listener Failed to " ++ "receive Sent-Event"; ++ self->state = ConnState::recvFailed; ++ self->handleConnState(); ++ return; ++ } ++ + // Send is successful, Lets remove data from queue + // check for next request data in queue. + if (!self->requestDataQueue.empty()) @@ -271,34 +300,56 @@ index feabbba..aaf1b2d 100644 - BMCWEB_LOG_DEBUG << "recvMessage() data: " - << self->parser->get(); - -- // Send is successful, Lets remove data from queue -- // check for next request data in queue. -- if (!self->requestDataQueue.empty()) +- // Check if the response and header are received +- if (!self->parser->is_done()) + else { -- self->requestDataQueue.pop_front(); +- // The parser failed to receive the response +- BMCWEB_LOG_ERROR +- << "recvMessage() parser failed to receive response"; +- self->state = ConnState::recvFailed; +- self->handleConnState(); +- return; + BMCWEB_LOG_DEBUG << "Connection closed gracefully..."; } -- self->state = ConnState::idle; + self->conn.close(); +- unsigned int respCode = self->parser->get().result_int(); +- BMCWEB_LOG_DEBUG << "recvMessage() Header Response Code: " +- << respCode; +- +- // 2XX response is considered to be successful +- if ((respCode < 200) || (respCode >= 300)) ++ if ((self->state != ConnState::suspended) && ++ (self->state != ConnState::terminated)) + { +- // The listener failed to receive the Sent-Event +- BMCWEB_LOG_ERROR << "recvMessage() Listener Failed to " +- "receive Sent-Event"; +- self->state = ConnState::recvFailed; ++ self->state = ConnState::closed; + self->handleConnState(); +- return; + } +- +- // Send is successful, Lets remove data from queue +- // check for next request data in queue. +- if (!self->requestDataQueue.empty()) +- { +- self->requestDataQueue.pop_front(); +- } +- self->state = ConnState::idle; +- - // Keep the connection alive if server supports it - // Else close the connection - BMCWEB_LOG_DEBUG << "recvMessage() keepalive : " - << self->parser->keep_alive(); - if (!self->parser->keep_alive()) -+ if ((self->state != ConnState::suspended) && -+ (self->state != ConnState::terminated)) - { +- { - // Abort the connection since server is not keep-alive - // enabled - self->state = ConnState::abortConnection; -+ self->state = ConnState::closed; -+ self->handleConnState(); - } -- -- // Returns ownership of the parsed message -- self->parser->release(); +- } - - self->handleConnState(); }); @@ -345,7 +396,7 @@ index feabbba..aaf1b2d 100644 } } -@@ -301,6 +388,7 @@ class HttpClient : public std::enable_shared_from_this +@@ -330,6 +419,7 @@ class HttpClient : public std::enable_shared_from_this { case ConnState::resolveInProgress: case ConnState::connectInProgress: @@ -353,7 +404,7 @@ index feabbba..aaf1b2d 100644 case ConnState::sendInProgress: case ConnState::recvInProgress: case ConnState::closeInProgress: -@@ -332,6 +420,7 @@ class HttpClient : public std::enable_shared_from_this +@@ -356,6 +446,7 @@ class HttpClient : public std::enable_shared_from_this } case ConnState::resolveFailed: case ConnState::connectFailed: @@ -361,7 +412,7 @@ index feabbba..aaf1b2d 100644 case ConnState::sendFailed: case ConnState::recvFailed: case ConnState::retry: -@@ -370,7 +459,8 @@ class HttpClient : public std::enable_shared_from_this +@@ -394,7 +485,8 @@ class HttpClient : public std::enable_shared_from_this public: explicit HttpClient(boost::asio::io_context& ioc, const std::string& id, const std::string& destIP, const std::string& destPort, @@ -371,7 +422,7 @@ index feabbba..aaf1b2d 100644 conn(ioc), timer(ioc), req(boost::beast::http::verb::post, destUri, 11), state(ConnState::initialized), subId(id), host(destIP), port(destPort), -@@ -383,8 +473,11 @@ class HttpClient : public std::enable_shared_from_this +@@ -407,8 +499,11 @@ class HttpClient : public std::enable_shared_from_this req.keep_alive(true); requestDataQueue.set_capacity(maxRequestQueueSize); @@ -385,10 +436,10 @@ index feabbba..aaf1b2d 100644 { if ((state == ConnState::suspended) || (state == ConnState::terminated)) diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp -index a8f7517..d4a5bc5 100644 +index 08d0b98..f1ce0c0 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp -@@ -397,7 +397,7 @@ class Subscription +@@ -385,7 +385,7 @@ class Subscription : public persistent_data::UserSubscription { conn = std::make_shared( crow::connections::systemBus->get_io_context(), id, host, port, @@ -398,4 +449,5 @@ index a8f7517..d4a5bc5 100644 Subscription(const std::shared_ptr& adaptor) : -- -2.25.1 +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0004-Add-Server-Sent-Events-support.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0004-Add-Server-Sent-Events-support.patch index da281467e..ea521a7e4 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0004-Add-Server-Sent-Events-support.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0004-Add-Server-Sent-Events-support.patch @@ -1,4 +1,4 @@ -From 54bdd897bd416fef4c043224b398b1b6d47fd271 Mon Sep 17 00:00:00 2001 +From d7a2660f200c38e74bfcbfe55b8da1b8bed08833 Mon Sep 17 00:00:00 2001 From: AppaRao Puli Date: Fri, 12 Mar 2021 18:53:25 +0000 Subject: [PATCH] Add Server-Sent-Events support @@ -21,47 +21,37 @@ Tested: Change-Id: I36956565cbba30c2007852c9471f477f6d1736e9 Signed-off-by: AppaRao Puli +Signed-off-by: P Dheeraj Srujan Kumar --- - http/http_connection.hpp | 14 +- + http/http_connection.hpp | 10 +- http/http_response.hpp | 7 +- http/routing.hpp | 71 ++++++++++ http/server_sent_event.hpp | 279 +++++++++++++++++++++++++++++++++++++ - 4 files changed, 365 insertions(+), 6 deletions(-) + 4 files changed, 362 insertions(+), 5 deletions(-) create mode 100644 http/server_sent_event.hpp diff --git a/http/http_connection.hpp b/http/http_connection.hpp -index a1a7045..90535c5 100644 +index 8e53afa..a1bbfce 100644 --- a/http/http_connection.hpp +++ b/http/http_connection.hpp -@@ -331,7 +331,7 @@ class Connection : - BMCWEB_LOG_INFO << "Request: " - << " " << this << " HTTP/" << req->version() / 10 << "." - << req->version() % 10 << ' ' << req->methodString() -- << " " << req->target() << " " << req->ipAddress; -+ << " " << req->url << " " << req->ipAddress; +@@ -378,11 +378,13 @@ class Connection : + [self] { self->completeRequest(); }); + }); - needToCallAfterHandlers = false; - -@@ -350,11 +350,15 @@ class Connection : - boost::asio::post(self->adaptor.get_executor(), - [self] { self->completeRequest(); }); - }); -- if (req->isUpgrade() && -- boost::iequals( -- req->getHeaderValue(boost::beast::http::field::upgrade), -- "websocket")) -+ -+ if ((req->isUpgrade() && -+ boost::iequals(req->getHeaderValue( -+ boost::beast::http::field::upgrade), -+ "websocket")) || -+ (req->url == "/sse")) - { -+ BMCWEB_LOG_DEBUG << "Request: " << this -+ << " is getting upgraded"; - handler->handleUpgrade(*req, res, std::move(adaptor)); - // delete lambda with self shared_ptr - // to enable connection destruction +- if (thisReq.isUpgrade() && +- boost::iequals( +- thisReq.getHeaderValue(boost::beast::http::field::upgrade), +- "websocket")) ++ if ((thisReq.isUpgrade() && ++ boost::iequals( ++ thisReq.getHeaderValue(boost::beast::http::field::upgrade), ++ "websocket")) || ++ (req->url == "/sse")) + { ++ BMCWEB_LOG_DEBUG << "Request: " << this << " is getting upgraded"; + handler->handleUpgrade(thisReq, res, std::move(adaptor)); + // delete lambda with self shared_ptr + // to enable connection destruction diff --git a/http/http_response.hpp b/http/http_response.hpp index a983d4a..07b0265 100644 --- a/http/http_response.hpp @@ -93,7 +83,7 @@ index a983d4a..07b0265 100644 // In case of a JSON object, set the Content-Type header void jsonMode() diff --git a/http/routing.hpp b/http/routing.hpp -index d2a10b2..25e4ce8 100644 +index 5d9c8e3..bfff107 100644 --- a/http/routing.hpp +++ b/http/routing.hpp @@ -6,6 +6,7 @@ diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0005-Add-SSE-style-subscription-support-to-eventservice.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0005-Add-SSE-style-subscription-support-to-eventservice.patch index 42a1ebbf0..ee69081ef 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0005-Add-SSE-style-subscription-support-to-eventservice.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0005-Add-SSE-style-subscription-support-to-eventservice.patch @@ -1,4 +1,4 @@ -From 36c1391749e19e4a25ca6e57d369457f48e6bb11 Mon Sep 17 00:00:00 2001 +From 799e47842e179f7c752712004f0e96d3219eee11 Mon Sep 17 00:00:00 2001 From: AppaRao Puli Date: Tue, 16 Mar 2021 15:37:24 +0000 Subject: [PATCH] Add SSE style subscription support to eventservice @@ -18,33 +18,33 @@ Tested: response. - Ran RedfishValidation and its passed. -Signed-off-by: AppaRao Puli -Signed-off-by: Nitin Wankhade Change-Id: I7f4b7a34974080739c4ba968ed570489af0474de +Signed-off-by: AppaRao Puli +Signed-off-by: P Dheeraj Srujan Kumar --- http/http_connection.hpp | 2 +- include/eventservice_sse.hpp | 75 +++++ - .../include/event_service_manager.hpp | 111 +++++-- + .../include/event_service_manager.hpp | 109 +++++-- redfish-core/include/server_sent_events.hpp | 290 ------------------ redfish-core/lib/event_service.hpp | 8 +- src/webserver_main.cpp | 2 + - 6 files changed, 165 insertions(+), 323 deletions(-) + 6 files changed, 164 insertions(+), 322 deletions(-) create mode 100644 include/eventservice_sse.hpp delete mode 100644 redfish-core/include/server_sent_events.hpp diff --git a/http/http_connection.hpp b/http/http_connection.hpp -index 90535c5..37c0a0b 100644 +index a1bbfce..2d08501 100644 --- a/http/http_connection.hpp +++ b/http/http_connection.hpp -@@ -355,7 +355,7 @@ class Connection : - boost::iequals(req->getHeaderValue( - boost::beast::http::field::upgrade), - "websocket")) || -- (req->url == "/sse")) -+ (req->url == "/redfish/v1/EventService/Subscriptions/SSE")) - { - BMCWEB_LOG_DEBUG << "Request: " << this - << " is getting upgraded"; +@@ -382,7 +382,7 @@ class Connection : + boost::iequals( + thisReq.getHeaderValue(boost::beast::http::field::upgrade), + "websocket")) || +- (req->url == "/sse")) ++ (req->url == "/redfish/v1/EventService/Subscriptions/SSE")) + { + BMCWEB_LOG_DEBUG << "Request: " << this << " is getting upgraded"; + handler->handleUpgrade(thisReq, res, std::move(adaptor)); diff --git a/include/eventservice_sse.hpp b/include/eventservice_sse.hpp new file mode 100644 index 0000000..14daf00 @@ -127,7 +127,7 @@ index 0000000..14daf00 +} // namespace eventservice_sse +} // namespace redfish diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp -index ca46aa7..9397271 100644 +index 3f398d7..dd833ce 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -22,15 +22,17 @@ @@ -217,23 +217,23 @@ index ca46aa7..9397271 100644 ~Subscription() = default; -@@ -412,13 +412,14 @@ class Subscription : public persistent_data::UserSubscription - } - conn->addHeaders(reqHeaders); - conn->sendData(msg); -- this->eventSeqNum++; - } +@@ -417,7 +417,7 @@ class Subscription : public persistent_data::UserSubscription if (sseConn != nullptr) { - sseConn->sendData(eventSeqNum, msg); + sseConn->sendEvent(std::to_string(eventSeqNum), msg); } -+ + } + +@@ -508,6 +508,7 @@ class Subscription : public persistent_data::UserSubscription + + this->sendEvent( + msg.dump(2, ' ', true, nlohmann::json::error_handler_t::replace)); + this->eventSeqNum++; } + #endif - void sendTestEventLog() @@ -578,14 +579,39 @@ class Subscription : public persistent_data::UserSubscription return eventSeqNum; } @@ -622,7 +622,7 @@ index 7613d7b..0000000 - -} // namespace crow diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp -index 67ad014..f8a2dac 100644 +index 8609862..249e594 100644 --- a/redfish-core/lib/event_service.hpp +++ b/redfish-core/lib/event_service.hpp @@ -37,8 +37,6 @@ static constexpr const std::array supportedResourceTypes = { diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0006-Add-EventService-SSE-filter-support.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0006-Add-EventService-SSE-filter-support.patch index 9043bd0b9..3914cc81a 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0006-Add-EventService-SSE-filter-support.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0006-Add-EventService-SSE-filter-support.patch @@ -1,4 +1,4 @@ -From 22c6b6cfb468f8de9ff3ea051dffdba05778645e Mon Sep 17 00:00:00 2001 +From 769f0e20d0a7e786d7091ffb7ee57d35204dfa28 Mon Sep 17 00:00:00 2001 From: AppaRao Puli Date: Wed, 17 Mar 2021 01:16:50 +0000 Subject: [PATCH] Add EventService SSE filter support @@ -41,7 +41,7 @@ Change-Id: I55c6f53bb5e57aa1f2d1601f1a16525a33b13bd2 5 files changed, 181 insertions(+), 9 deletions(-) diff --git a/include/eventservice_sse.hpp b/include/eventservice_sse.hpp -index 14daf00..2f22f98 100644 +index 14daf00..fed7fec 100644 --- a/include/eventservice_sse.hpp +++ b/include/eventservice_sse.hpp @@ -23,16 +23,153 @@ static bool createSubscription(std::shared_ptr& conn, @@ -203,7 +203,7 @@ index 14daf00..2f22f98 100644 std::string id = redfish::EventServiceManager::getInstance().addSubscription(subValue, diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp -index 10567d1..f29e326 100644 +index 3d11cc4..90084e3 100644 --- a/redfish-core/include/error_messages.hpp +++ b/redfish-core/include/error_messages.hpp @@ -971,6 +971,15 @@ nlohmann::json mutualExclusiveProperties(const std::string& arg1, @@ -223,10 +223,10 @@ index 10567d1..f29e326 100644 } // namespace redfish diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp -index 5886d81..c3e7f61 100644 +index dd833ce..861f4cb 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp -@@ -56,6 +56,11 @@ static constexpr const char* eventServiceFile = +@@ -55,6 +55,11 @@ static constexpr const char* eventServiceFile = static constexpr const uint8_t maxNoOfSubscriptions = 20; static constexpr const uint8_t maxNoOfSSESubscriptions = 10; @@ -239,10 +239,10 @@ index 5886d81..c3e7f61 100644 static std::optional inotifyConn; static constexpr const char* redfishEventLogDir = "/var/log"; diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp -index 2e7c3f3..9def549 100644 +index 249e594..6f01707 100644 --- a/redfish-core/lib/event_service.hpp +++ b/redfish-core/lib/event_service.hpp -@@ -25,11 +25,6 @@ +@@ -21,11 +21,6 @@ namespace redfish { @@ -255,10 +255,10 @@ index 2e7c3f3..9def549 100644 "TerminateAfterRetries", "SuspendRetries", "RetryForever"}; diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp -index 48edaf1..bebb6d8 100644 +index 9c28e8f..2394398 100644 --- a/redfish-core/src/error_messages.cpp +++ b/redfish-core/src/error_messages.cpp -@@ -2174,6 +2174,32 @@ void mutualExclusiveProperties(crow::Response& res, const std::string& arg1, +@@ -2173,6 +2173,32 @@ void mutualExclusiveProperties(crow::Response& res, const std::string& arg1, addMessageToErrorJson(res.jsonValue, mutualExclusiveProperties(arg1, arg2)); } diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0010-Remove-Terminated-Event-Subscriptions.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0010-Remove-Terminated-Event-Subscriptions.patch index 7fcc235d2..9af5a066b 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0010-Remove-Terminated-Event-Subscriptions.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0010-Remove-Terminated-Event-Subscriptions.patch @@ -1,6 +1,6 @@ -From adaa5cb4c494148430b90edb248260eb2e66bca7 Mon Sep 17 00:00:00 2001 -From: P Dheeraj Srujan Kumar -Date: Wed, 8 Sep 2021 15:42:52 +0530 +From f665ba085bb2310f008b7534f827fb401ad973c2 Mon Sep 17 00:00:00 2001 +From: Krzysztof Grobelny +Date: Tue, 12 Oct 2021 08:19:51 +0000 Subject: [PATCH] Delete/Remove Terminated Event Subscription(s) Added functionality to delete/remove event subscription(s) which are @@ -23,14 +23,14 @@ Change-Id: If447acb2db74fb29a5d1cfe6194b77cda82bc8a1 Signed-off-by: P Dheeraj Srujan Kumar --- http/http_client.hpp | 43 +++++++++++++++---- - .../include/event_service_manager.hpp | 37 ++++++++++++++++ - 2 files changed, 71 insertions(+), 9 deletions(-) + .../include/event_service_manager.hpp | 36 ++++++++++++++++ + 2 files changed, 70 insertions(+), 9 deletions(-) diff --git a/http/http_client.hpp b/http/http_client.hpp -index aaf1b2d..4f62c40 100644 +index 5e7ff47..54ae2c3 100644 --- a/http/http_client.hpp +++ b/http/http_client.hpp -@@ -56,6 +56,8 @@ enum class ConnState +@@ -55,6 +55,8 @@ enum class ConnState closeInProgress, closed, suspended, @@ -39,7 +39,7 @@ index aaf1b2d..4f62c40 100644 terminated, abortConnection, retry -@@ -263,7 +265,14 @@ class HttpClient : public std::enable_shared_from_this +@@ -288,7 +290,14 @@ class HttpClient : public std::enable_shared_from_this } void doClose() { @@ -55,7 +55,7 @@ index aaf1b2d..4f62c40 100644 // Set the timeout on the tcp stream socket for the async operation conn.expires_after(std::chrono::seconds(30)); -@@ -293,8 +302,11 @@ class HttpClient : public std::enable_shared_from_this +@@ -318,8 +327,11 @@ class HttpClient : public std::enable_shared_from_this } self->conn.close(); @@ -69,7 +69,7 @@ index aaf1b2d..4f62c40 100644 { self->state = ConnState::closed; self->handleConnState(); -@@ -316,8 +328,11 @@ class HttpClient : public std::enable_shared_from_this +@@ -341,8 +353,11 @@ class HttpClient : public std::enable_shared_from_this } conn.close(); @@ -83,7 +83,7 @@ index aaf1b2d..4f62c40 100644 { state = ConnState::closed; handleConnState(); -@@ -340,8 +355,7 @@ class HttpClient : public std::enable_shared_from_this +@@ -365,8 +380,7 @@ class HttpClient : public std::enable_shared_from_this BMCWEB_LOG_DEBUG << "Retry policy: " << retryPolicyAction; if (retryPolicyAction == "TerminateAfterRetries") { @@ -93,7 +93,7 @@ index aaf1b2d..4f62c40 100644 } if (retryPolicyAction == "SuspendRetries") { -@@ -392,6 +406,7 @@ class HttpClient : public std::enable_shared_from_this +@@ -423,6 +437,7 @@ class HttpClient : public std::enable_shared_from_this case ConnState::sendInProgress: case ConnState::recvInProgress: case ConnState::closeInProgress: @@ -101,7 +101,7 @@ index aaf1b2d..4f62c40 100644 { BMCWEB_LOG_DEBUG << "Async operation is already in progress"; break; -@@ -413,7 +428,7 @@ class HttpClient : public std::enable_shared_from_this +@@ -439,7 +454,7 @@ class HttpClient : public std::enable_shared_from_this break; } case ConnState::suspended: @@ -110,7 +110,7 @@ index aaf1b2d..4f62c40 100644 { doClose(); break; -@@ -480,7 +495,8 @@ class HttpClient : public std::enable_shared_from_this +@@ -506,7 +521,8 @@ class HttpClient : public std::enable_shared_from_this } void sendData(const std::string& data) { @@ -120,7 +120,7 @@ index aaf1b2d..4f62c40 100644 { return; } -@@ -489,6 +505,15 @@ class HttpClient : public std::enable_shared_from_this +@@ -524,6 +540,15 @@ class HttpClient : public std::enable_shared_from_this return; } @@ -137,7 +137,7 @@ index aaf1b2d..4f62c40 100644 const std::vector>& httpHeaders) { diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp -index 8d7067b..79618f6 100644 +index 6f60a31..363adb0 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -591,6 +591,14 @@ class Subscription : public persistent_data::UserSubscription @@ -254,5 +254,5 @@ index 8d7067b..79618f6 100644 { std::shared_ptr entry = it.second; -- -2.17.1 +2.25.1 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0011-Fix-bmcweb-crash-while-deleting-terminated-subscriptions.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0011-Fix-bmcweb-crash-while-deleting-terminated-subscriptions.patch new file mode 100644 index 000000000..585f7bf09 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/0011-Fix-bmcweb-crash-while-deleting-terminated-subscriptions.patch @@ -0,0 +1,141 @@ +From 5b87bb61b58e92a8c5af37a7959347747409a65c Mon Sep 17 00:00:00 2001 +From: P Dheeraj Srujan Kumar +Date: Thu, 14 Oct 2021 02:56:11 +0530 +Subject: [PATCH] Fix bmcweb crash while deleting terminated subscriptions + +This commit fixes bmcweb crash while deleting the terminated +subscriptions. In the earlier implementation, detection of subscription +to be deleted and the deletion(erase) was happening in the same loop. +Due to this, if the Subscription to be deleted is the last one in the +list, the loop will enter into infinite loop. The fix is to keep the +detection and deletion loop separate. +Also, this commit adds code to : + - Delete from persistent storage + - Add journal entry for deleted entry + - update number of subcribers and update persistent storage. + +Apart from this, this commit also moves the retry timer check to the top +to avoid multiple calls to close when the retry count is 3 and timer is +running. + +Tested: + - Checked journal logs to confirm each retry is actually spanned to be + 30 secs + - Verified Journal entry for deleted subscription after retires. + - Verified Event service functionality by making three subscriptions: + retry for ever, terminate after retires and suspend after retries. + +Change-Id: I425a6c749923ce86c457a36394deb0fbbee232db +Signed-off-by: P Dheeraj Srujan Kumar +--- + http/http_client.hpp | 11 ++-- + .../include/event_service_manager.hpp | 59 ++++++++++++++++--- + 2 files changed, 58 insertions(+), 12 deletions(-) + +diff --git a/http/http_client.hpp b/http/http_client.hpp +index 54ae2c3..162cb09 100644 +--- a/http/http_client.hpp ++++ b/http/http_client.hpp +@@ -367,6 +367,12 @@ class HttpClient : public std::enable_shared_from_this + + void waitAndRetry() + { ++ if (runningTimer) ++ { ++ BMCWEB_LOG_DEBUG << "Retry timer is already running."; ++ return; ++ } ++ + if (retryCount >= maxRetryAttempts) + { + BMCWEB_LOG_ERROR << "Maximum number of retries reached."; +@@ -393,11 +399,6 @@ class HttpClient : public std::enable_shared_from_this + return; + } + +- if (runningTimer) +- { +- BMCWEB_LOG_DEBUG << "Retry timer is already running."; +- return; +- } + runningTimer = true; + + retryCount++; +diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp +index 363adb0..7af7a4d 100644 +--- a/redfish-core/include/event_service_manager.hpp ++++ b/redfish-core/include/event_service_manager.hpp +@@ -857,18 +857,63 @@ class EventServiceManager + + void deleteTerminatedSubcriptions() + { +- boost::container::flat_map>::iterator it = +- subscriptionsMap.begin(); +- while (it != subscriptionsMap.end()) ++ BMCWEB_LOG_ERROR << "Map size Before Delete : " ++ << subscriptionsMap.size(); ++ ++ std::vector deleteIds; ++ ++ // Determine Subscription ID's to be deleted. ++ for (const auto& it : subscriptionsMap) + { +- std::shared_ptr entry = it->second; ++ std::shared_ptr entry = it.second; + if (entry->isTerminated()) + { +- subscriptionsMap.erase(it); ++ deleteIds.emplace_back(it.first); ++ } ++ } ++ ++ // Delete the Terminated Subcriptions ++ for (std::string& id : deleteIds) ++ { ++ auto map1 = subscriptionsMap.find(id); ++ if (map1 != subscriptionsMap.end()) ++ { ++ subscriptionsMap.erase(map1); ++ auto map2 = persistent_data::EventServiceStore::getInstance() ++ .subscriptionsConfigMap.find(id); ++ if (map2 != persistent_data::EventServiceStore::getInstance() ++ .subscriptionsConfigMap.end()) ++ { ++ persistent_data::EventServiceStore::getInstance() ++ .subscriptionsConfigMap.erase(map2); ++ } ++ else ++ { ++ BMCWEB_LOG_ERROR << "Couldn't find ID: " << id ++ << " in subscriptionsConfigMap"; ++ } ++ ++ /* Log event for subscription delete. */ ++ sd_journal_send("MESSAGE=Event subscription removed.(Id = %s)", ++ id.c_str(), "PRIORITY=%i", LOG_INFO, ++ "REDFISH_MESSAGE_ID=%s", ++ "OpenBMC.0.1.EventSubscriptionRemoved", ++ "REDFISH_MESSAGE_ARGS=%s", id.c_str(), NULL); ++ } ++ else ++ { ++ BMCWEB_LOG_ERROR << "Couldn't find ID: " << id ++ << " in subscriptionsMap"; + } +- it++; + } ++ if (deleteIds.size()) ++ { ++ updateNoOfSubscribersCount(); ++ persistSubscriptionData(); ++ } ++ ++ BMCWEB_LOG_ERROR << "Map size After Delete : " ++ << subscriptionsMap.size(); + } + + void updateNoOfSubscribersCount() +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/README b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/README index cd2e1c2bc..c09967456 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/README +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/eventservice/README @@ -3,26 +3,32 @@ the upstream patches. These will be remove as soon as thee gets merged upstream. Upstream revision information: - - EventService : Fix retry handling for http-client - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/40731/21 + - EventService : Add unmerged changes for http retry support (Downstream patch) + file://eventservice/0001-Add-unmerged-changes-for-http-retry-support.patch - EventService: https client support - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/31735/40 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/31735/40 (Rebased on latest bmcweb) - Add Server-Sent-Events support - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/41258/7 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/41258/9 - Add SSE style subscription support to eventservice - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/41319/8 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/41319/10 - Add EventService SSE filter support - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/41349/5 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/41349/7 (Modified boost::urls::query_params_view to boost::urls::url_view::params_type) - - EventService Log events for subscription actions - file://telemetry/0007-EventService-Log-events-for-subscription-actions.patch + - EventService Log events for subscription actions (Downstream patch) + file://eventservice/0007-EventService-Log-events-for-subscription-actions.patch - - Add checks on Event-Subscription input parameters - file://telemetry/0008-Add-checks-on-Event-Subscription-input-parameters.patch + - Add checks on Event-Subscription input parameters (Downstream patch) + file://eventservice//0008-Add-checks-on-Event-Subscription-input-parameters.patch - Restructure Redifsh EventLog Transmit code flow - file://telemetry/0009-Restructure-Redifsh-EventLog-Transmit-code-flow.patch + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/44449/3 + + - Remove Terminated Event Subscriptions (Downstream patch) + file://eventservice/0010-Remove-Terminated-Event-Subscriptions.patch + + - Fix bmcweb crash while deleting terminated subscriptions (Downstream patch) + file://eventservice/0011-Fix-bmcweb-crash-while-deleting-terminated-subscriptions.patch diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0001-Add-asyncResp-support-during-handleUpgrade.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0001-Add-asyncResp-support-during-handleUpgrade.patch new file mode 100644 index 000000000..b3aa11774 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0001-Add-asyncResp-support-during-handleUpgrade.patch @@ -0,0 +1,202 @@ +From f2c3271c8eb405a05a3ec383791e1adc3c4a7f86 Mon Sep 17 00:00:00 2001 +From: P Dheeraj Srujan Kumar +Date: Mon, 18 Oct 2021 22:45:37 +0530 +Subject: [PATCH] Add asyncResp support during handleUpgrade + +The current implementation uses the earlier method of using the response +object and calling response.end() to initiate completion handler. +This commit modifies the implementation to use asyncResp, where the +completion handler gets called asynchronously as the response object +goes out of scope. + +Tested : + - websocket_test.py Passed + - KVM was functional in WebUI. + - POST to /redfish/v1/EventService/Subscriptions/SSE returned an error + message as expected and the connection was kept alive. + - GET on /redfish/v1/EventService/Subscriptions/SSE (SSE subscription) + was successful. The existing connection was successfully closed and + upgraded to SSE connection. + +Change-Id: I2d76b34a49a6432c507d939b21b37c1ced761f8e +Signed-off-by: P Dheeraj Srujan Kumar +--- + http/app.hpp | 6 ++++-- + http/http_connection.hpp | 30 +++++++++++++++++++++++++----- + http/routing.hpp | 37 +++++++++++++++++++++---------------- + 3 files changed, 50 insertions(+), 23 deletions(-) + +diff --git a/http/app.hpp b/http/app.hpp +index 4735197..c46dcf7 100644 +--- a/http/app.hpp ++++ b/http/app.hpp +@@ -45,9 +45,11 @@ class App + } + + template +- void handleUpgrade(const Request& req, Response& res, Adaptor&& adaptor) ++ void handleUpgrade(const Request& req, ++ const std::shared_ptr& asyncResp, ++ Adaptor&& adaptor) + { +- router.handleUpgrade(req, res, std::move(adaptor)); ++ router.handleUpgrade(req, asyncResp, std::move(adaptor)); + } + + void handle(Request& req, +diff --git a/http/http_connection.hpp b/http/http_connection.hpp +index 9d53c17..cdd3707 100644 +--- a/http/http_connection.hpp ++++ b/http/http_connection.hpp +@@ -361,6 +361,7 @@ class Connection : + boost::asio::post(self->adaptor.get_executor(), + [self] { self->completeRequest(); }); + }); ++ auto asyncResp = std::make_shared(res); + + if ((thisReq.isUpgrade() && + boost::iequals( +@@ -369,13 +370,32 @@ class Connection : + (req->url == "/redfish/v1/EventService/Subscriptions/SSE")) + { + BMCWEB_LOG_DEBUG << "Request: " << this << " is getting upgraded"; +- handler->handleUpgrade(thisReq, res, std::move(adaptor)); +- // delete lambda with self shared_ptr +- // to enable connection destruction +- res.setCompleteRequestHandler(nullptr); ++ res.setCompleteRequestHandler([self(shared_from_this())] { ++ if (self->res.resultInt() != 200) ++ { ++ // When any error occurs during handle upgradation, ++ // the result in response will be set to respective ++ // error. By default the Result will be OK (200), ++ // which implies successful handle upgrade. Response ++ // needs to be sent over this connection only on ++ // failure. ++ boost::asio::post(self->adaptor.get_executor(), ++ [self] { self->completeRequest(); }); ++ } ++ else ++ { ++ // Set Complete request handler to NULL to remove ++ // the shared pointer of connection to enable ++ // connection destruction. As the connection would ++ // get upgraded, we wouldn't need this connection ++ // any longer ++ self->res.setCompleteRequestHandler(nullptr); ++ } ++ }); ++ handler->handleUpgrade(thisReq, asyncResp, std::move(adaptor)); + return; + } +- auto asyncResp = std::make_shared(res); ++ + handler->handle(thisReq, asyncResp); + } + +diff --git a/http/routing.hpp b/http/routing.hpp +index 25e4ce8..858f146 100644 +--- a/http/routing.hpp ++++ b/http/routing.hpp +@@ -1202,12 +1202,13 @@ class Router + } + + template +- void handleUpgrade(const Request& req, Response& res, Adaptor&& adaptor) ++ void handleUpgrade(const Request& req, ++ const std::shared_ptr& asyncResp, ++ Adaptor&& adaptor) + { + if (static_cast(req.method()) >= perMethods.size()) + { +- res.result(boost::beast::http::status::not_found); +- res.end(); ++ asyncResp->res.result(boost::beast::http::status::not_found); + return; + } + +@@ -1220,8 +1221,7 @@ class Router + if (!ruleIndex) + { + BMCWEB_LOG_DEBUG << "Cannot match rules " << req.url; +- res.result(boost::beast::http::status::not_found); +- res.end(); ++ asyncResp->res.result(boost::beast::http::status::not_found); + return; + } + +@@ -1234,23 +1234,24 @@ class Router + { + BMCWEB_LOG_INFO << "Redirecting to a url with trailing slash: " + << req.url; +- res.result(boost::beast::http::status::moved_permanently); ++ asyncResp->res.result( ++ boost::beast::http::status::moved_permanently); + + // TODO absolute url building + if (req.getHeaderValue("Host").empty()) + { +- res.addHeader("Location", std::string(req.url) + "/"); ++ asyncResp->res.addHeader("Location", ++ std::string(req.url) + "/"); + } + else + { +- res.addHeader( ++ asyncResp->res.addHeader( + "Location", + req.isSecure + ? "https://" + : "http://" + std::string(req.getHeaderValue("Host")) + + std::string(req.url) + "/"); + } +- res.end(); + return; + } + +@@ -1261,8 +1262,7 @@ class Router + << " with " << req.methodString() << "(" + << static_cast(req.method()) << ") / " + << rules[ruleIndex]->getMethods(); +- res.result(boost::beast::http::status::not_found); +- res.end(); ++ asyncResp->res.result(boost::beast::http::status::not_found); + return; + } + +@@ -1273,13 +1273,18 @@ class Router + // any uncaught exceptions become 500s + try + { +- rules[ruleIndex]->handleUpgrade(req, res, std::move(adaptor)); ++ // Creating temporary response object to call handleUpgrade ++ // We cannot pass the asyncResp as it will be destroyed ++ // The response object is not initialized as handleUpgrade wouldn't ++ // be using this object ++ crow::Response resp; ++ rules[ruleIndex]->handleUpgrade(req, resp, std::move(adaptor)); + } + catch (std::exception& e) + { + BMCWEB_LOG_ERROR << "An uncaught exception occurred: " << e.what(); +- res.result(boost::beast::http::status::internal_server_error); +- res.end(); ++ asyncResp->res.result( ++ boost::beast::http::status::internal_server_error); + return; + } + catch (...) +@@ -1287,8 +1292,8 @@ class Router + BMCWEB_LOG_ERROR + << "An uncaught exception occurred. The type was unknown " + "so no information was available."; +- res.result(boost::beast::http::status::internal_server_error); +- res.end(); ++ asyncResp->res.result( ++ boost::beast::http::status::internal_server_error); + return; + } + } +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0002-Move-privileges-to-separate-entity.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0002-Move-privileges-to-separate-entity.patch new file mode 100644 index 000000000..1217147b4 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0002-Move-privileges-to-separate-entity.patch @@ -0,0 +1,109 @@ +From 6483f0af926391e8d1f256ba0f23f3640260cfd1 Mon Sep 17 00:00:00 2001 +From: P Dheeraj Srujan Kumar +Date: Mon, 18 Oct 2021 22:52:17 +0530 +Subject: [PATCH] Move privileges to separate entity + +The privilege property of a rule is currently part of RuleParameterTraits +structure. Moving this property (member function) out into a separate +entity PrivilegeParameterTraits. +This move is required to enable inheriting this entity into Weksockets +and SseSockets. + +Tested: + - bmcweb is functional and is responding to Redfish URI's + - User Privilege check for URI's is functional. + +Change-Id: I288ab12258c15ae5a626f4409fc3b4a9cc574ea3 +Signed-off-by: P Dheeraj Srujan Kumar +--- + http/routing.hpp | 53 +++++++++++++++++++++++++++--------------------- + 1 file changed, 30 insertions(+), 23 deletions(-) + +diff --git a/http/routing.hpp b/http/routing.hpp +index 858f146..acc99dc 100644 +--- a/http/routing.hpp ++++ b/http/routing.hpp +@@ -102,6 +102,8 @@ class BaseRule + friend class Router; + template + friend struct RuleParameterTraits; ++ template ++ friend struct PrivilegeParameterTraits; + }; + + namespace detail +@@ -316,6 +318,33 @@ struct Wrapped + } // namespace routing_handler_call_helper + } // namespace detail + ++template ++struct PrivilegeParameterTraits ++{ ++ using self_t = T; ++ self_t& privileges( ++ const std::initializer_list>& p) ++ { ++ self_t* self = static_cast(this); ++ for (const std::initializer_list& privilege : p) ++ { ++ self->privilegesSet.emplace_back(privilege); ++ } ++ return *self; ++ } ++ ++ template ++ self_t& privileges(const std::array& p) ++ { ++ self_t* self = static_cast(this); ++ for (const redfish::Privileges& privilege : p) ++ { ++ self->privilegesSet.emplace_back(privilege); ++ } ++ return *self; ++ } ++}; ++ + class WebSocketRule : public BaseRule + { + using self_t = WebSocketRule; +@@ -462,7 +491,7 @@ class SseSocketRule : public BaseRule + }; + + template +-struct RuleParameterTraits ++struct RuleParameterTraits : public PrivilegeParameterTraits + { + using self_t = T; + WebSocketRule& websocket() +@@ -503,28 +532,6 @@ struct RuleParameterTraits + self->methodsBitfield |= 1U << static_cast(method); + return *self; + } +- +- self_t& privileges( +- const std::initializer_list>& p) +- { +- self_t* self = static_cast(this); +- for (const std::initializer_list& privilege : p) +- { +- self->privilegesSet.emplace_back(privilege); +- } +- return *self; +- } +- +- template +- self_t& privileges(const std::array& p) +- { +- self_t* self = static_cast(this); +- for (const redfish::Privileges& privilege : p) +- { +- self->privilegesSet.emplace_back(privilege); +- } +- return *self; +- } + }; + + class DynamicRule : public BaseRule, public RuleParameterTraits +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0003-Add-Support-for-privilege-check-in-handleUpgrade.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0003-Add-Support-for-privilege-check-in-handleUpgrade.patch new file mode 100644 index 000000000..1ba584616 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0003-Add-Support-for-privilege-check-in-handleUpgrade.patch @@ -0,0 +1,218 @@ +From aabe4718b8e6c1f7b91af29cbaf85d5fa1fa0a99 Mon Sep 17 00:00:00 2001 +From: P Dheeraj Srujan Kumar +Date: Mon, 18 Oct 2021 22:55:38 +0530 +Subject: [PATCH] Add Support for privilege check in handleUpgrade + +This commit enables privilege check for user(s) in case of upgraded +connections. +Currently users with no privileges will also be able to access +Websockets connections (Ex: KVM). + +Tested: + - websocket_test.py Passed + - Admin and Operator users were able to access KVM on WebUI + - Readonly User was unable to access KVM on WebUI + +Change-Id: Id9d33aeca24d8fafb2e9dcc28c46a48930740cd6 +Signed-off-by: P Dheeraj Srujan Kumar +--- + http/app.hpp | 2 +- + http/routing.hpp | 162 +++++++++++++++++++++++++++++++++++++++-------- + 2 files changed, 136 insertions(+), 28 deletions(-) + +diff --git a/http/app.hpp b/http/app.hpp +index c46dcf7..dd51eee 100644 +--- a/http/app.hpp ++++ b/http/app.hpp +@@ -45,7 +45,7 @@ class App + } + + template +- void handleUpgrade(const Request& req, ++ void handleUpgrade(Request& req, + const std::shared_ptr& asyncResp, + Adaptor&& adaptor) + { +diff --git a/http/routing.hpp b/http/routing.hpp +index acc99dc..e2a8fbb 100644 +--- a/http/routing.hpp ++++ b/http/routing.hpp +@@ -1209,7 +1209,7 @@ class Router + } + + template +- void handleUpgrade(const Request& req, ++ void handleUpgrade(Request& req, + const std::shared_ptr& asyncResp, + Adaptor&& adaptor) + { +@@ -1277,32 +1277,140 @@ class Router + << "' " << static_cast(req.method()) << " / " + << rules[ruleIndex]->getMethods(); + +- // any uncaught exceptions become 500s +- try +- { +- // Creating temporary response object to call handleUpgrade +- // We cannot pass the asyncResp as it will be destroyed +- // The response object is not initialized as handleUpgrade wouldn't +- // be using this object +- crow::Response resp; +- rules[ruleIndex]->handleUpgrade(req, resp, std::move(adaptor)); +- } +- catch (std::exception& e) +- { +- BMCWEB_LOG_ERROR << "An uncaught exception occurred: " << e.what(); +- asyncResp->res.result( +- boost::beast::http::status::internal_server_error); +- return; +- } +- catch (...) +- { +- BMCWEB_LOG_ERROR +- << "An uncaught exception occurred. The type was unknown " +- "so no information was available."; +- asyncResp->res.result( +- boost::beast::http::status::internal_server_error); +- return; +- } ++ crow::connections::systemBus->async_method_call( ++ [&req, asyncResp, &rules, ruleIndex, &adaptor]( ++ const boost::system::error_code ec, ++ std::map>> ++ userInfo) { ++ if (ec) ++ { ++ BMCWEB_LOG_ERROR << "GetUserInfo failed..."; ++ asyncResp->res.result( ++ boost::beast::http::status::internal_server_error); ++ return; ++ } ++ ++ const std::string* userRolePtr = nullptr; ++ auto userInfoIter = userInfo.find("UserPrivilege"); ++ if (userInfoIter != userInfo.end()) ++ { ++ userRolePtr = ++ std::get_if(&userInfoIter->second); ++ } ++ ++ std::string userRole{}; ++ if (userRolePtr != nullptr) ++ { ++ userRole = *userRolePtr; ++ BMCWEB_LOG_DEBUG << "userName = " << req.session->username ++ << " userRole = " << *userRolePtr; ++ } ++ ++ bool* remoteUserPtr = nullptr; ++ auto remoteUserIter = userInfo.find("RemoteUser"); ++ if (remoteUserIter != userInfo.end()) ++ { ++ remoteUserPtr = std::get_if(&remoteUserIter->second); ++ } ++ if (remoteUserPtr == nullptr) ++ { ++ BMCWEB_LOG_ERROR ++ << "RemoteUser property missing or wrong type"; ++ asyncResp->res.result( ++ boost::beast::http::status::internal_server_error); ++ return; ++ } ++ bool remoteUser = *remoteUserPtr; ++ ++ bool passwordExpired = false; // default for remote user ++ if (!remoteUser) ++ { ++ bool* passwordExpiredPtr = nullptr; ++ auto passwordExpiredIter = ++ userInfo.find("UserPasswordExpired"); ++ if (passwordExpiredIter != userInfo.end()) ++ { ++ passwordExpiredPtr = ++ std::get_if(&passwordExpiredIter->second); ++ } ++ if (passwordExpiredPtr != nullptr) ++ { ++ passwordExpired = *passwordExpiredPtr; ++ } ++ else ++ { ++ BMCWEB_LOG_ERROR ++ << "UserPasswordExpired property is expected for" ++ " local user but is missing or wrong type"; ++ asyncResp->res.result( ++ boost::beast::http::status::internal_server_error); ++ return; ++ } ++ } ++ ++ // Get the userprivileges from the role ++ redfish::Privileges userPrivileges = ++ redfish::getUserPrivileges(userRole); ++ ++ // Set isConfigureSelfOnly based on D-Bus results. This ++ // ignores the results from both pamAuthenticateUser and the ++ // value from any previous use of this session. ++ req.session->isConfigureSelfOnly = passwordExpired; ++ ++ // Modifyprivileges if isConfigureSelfOnly. ++ if (req.session->isConfigureSelfOnly) ++ { ++ // Remove allprivileges except ConfigureSelf ++ userPrivileges = userPrivileges.intersection( ++ redfish::Privileges{"ConfigureSelf"}); ++ BMCWEB_LOG_DEBUG << "Operation limited to ConfigureSelf"; ++ } ++ ++ if (!rules[ruleIndex]->checkPrivileges(userPrivileges)) ++ { ++ asyncResp->res.result( ++ boost::beast::http::status::forbidden); ++ if (req.session->isConfigureSelfOnly) ++ { ++ redfish::messages::passwordChangeRequired( ++ asyncResp->res, ++ "/redfish/v1/AccountService/Accounts/" + ++ req.session->username); ++ } ++ return; ++ } ++ ++ req.userRole = userRole; ++ ++ // any uncaught exceptions become 500s ++ try ++ { ++ crow::Response resp; ++ rules[ruleIndex]->handleUpgrade(req, resp, ++ std::move(adaptor)); ++ } ++ catch (std::exception& e) ++ { ++ BMCWEB_LOG_ERROR << "An uncaught exception occurred: " ++ << e.what(); ++ asyncResp->res.result( ++ boost::beast::http::status::internal_server_error); ++ return; ++ } ++ catch (...) ++ { ++ BMCWEB_LOG_ERROR ++ << "An uncaught exception occurred. The type was " ++ "unknown so no information was available."; ++ asyncResp->res.result( ++ boost::beast::http::status::internal_server_error); ++ return; ++ } ++ }, ++ "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user", ++ "xyz.openbmc_project.User.Manager", "GetUserInfo", ++ req.session->username); + } + + void handle(Request& req, +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0004-Add-Privileges-to-Websockets.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0004-Add-Privileges-to-Websockets.patch new file mode 100644 index 000000000..64e235ce3 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0004-Add-Privileges-to-Websockets.patch @@ -0,0 +1,140 @@ +From 9b27d3e7c1670d53cfb1c0a88cc75155ebfba71a Mon Sep 17 00:00:00 2001 +From: P Dheeraj Srujan Kumar +Date: Mon, 18 Oct 2021 22:58:29 +0530 +Subject: [PATCH] Add Privileges to Websockets + +This commit adds Privileges to Websockets. +In the current implementation, once a rule is upgraded (i.e. from +BaseRule to WebSocket), there is no provosion to add priviliges. +In this commit, WebSocket inherits PrivilegeParameterTraits to enable +privileges. + +Also, in the earlier implementation, .privilege() was called after +BMCWEB_ROUTE(). This results in adding those privileges to the Base rule +that is created. By moving the privileges() below websocket(), the +privileges are applied to the websocket. + +Tested: + - websocket_test.py Passed + - Admin and Operator users were able to access KVM on WebUI + - Readonly User was unable to access KVM on WebUI + +Change-Id: Iff2051dbb7d363c902fd463fa446f280adc6d648 +Signed-off-by: P Dheeraj Srujan Kumar +--- + http/routing.hpp | 4 +++- + include/dbus_monitor.hpp | 3 ++- + include/kvm_websocket.hpp | 4 +++- + include/obmc_console.hpp | 4 +++- + include/vm_websocket.hpp | 4 +++- + 5 files changed, 14 insertions(+), 5 deletions(-) + +diff --git a/http/routing.hpp b/http/routing.hpp +index e2a8fbb..6ea3185 100644 +--- a/http/routing.hpp ++++ b/http/routing.hpp +@@ -345,7 +345,9 @@ struct PrivilegeParameterTraits + } + }; + +-class WebSocketRule : public BaseRule ++class WebSocketRule : ++ public BaseRule, ++ public PrivilegeParameterTraits + { + using self_t = WebSocketRule; + +diff --git a/include/dbus_monitor.hpp b/include/dbus_monitor.hpp +index a6c86c6..163f884 100644 +--- a/include/dbus_monitor.hpp ++++ b/include/dbus_monitor.hpp +@@ -5,6 +5,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -105,8 +106,8 @@ inline int onPropertyUpdate(sd_bus_message* m, void* userdata, + inline void requestRoutes(App& app) + { + BMCWEB_ROUTE(app, "/subscribe") +- .privileges({{"Login"}}) + .websocket() ++ .privileges(redfish::privileges::privilegeSetLogin) + .onopen([&](crow::websocket::Connection& conn, + const std::shared_ptr&) { + BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened"; +diff --git a/include/kvm_websocket.hpp b/include/kvm_websocket.hpp +index a9dc8ea..3f124a2 100644 +--- a/include/kvm_websocket.hpp ++++ b/include/kvm_websocket.hpp +@@ -4,6 +4,7 @@ + #include + #include + #include ++#include + #include + + namespace crow +@@ -159,8 +160,9 @@ inline void requestRoutes(App& app) + sessions.reserve(maxSessions); + + BMCWEB_ROUTE(app, "/kvm/0") +- .privileges({{"ConfigureComponents", "ConfigureManager"}}) + .websocket() ++ .privileges(redfish::privileges:: ++ privilegeSetConfigureManagerOrConfigureComponents) + .onopen([](crow::websocket::Connection& conn, + const std::shared_ptr&) { + BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened"; +diff --git a/include/obmc_console.hpp b/include/obmc_console.hpp +index ff0a51f..22a49a8 100644 +--- a/include/obmc_console.hpp ++++ b/include/obmc_console.hpp +@@ -6,6 +6,7 @@ + #include + #include + #include ++#include + #include + + namespace crow +@@ -136,8 +137,9 @@ inline void connectHandler(const boost::system::error_code& ec) + inline void requestRoutes(App& app) + { + BMCWEB_ROUTE(app, "/console0") +- .privileges({{"ConfigureComponents", "ConfigureManager"}}) + .websocket() ++ .privileges(redfish::privileges:: ++ privilegeSetConfigureManagerOrConfigureComponents) + .onopen([](crow::websocket::Connection& conn, + const std::shared_ptr&) { + BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened"; +diff --git a/include/vm_websocket.hpp b/include/vm_websocket.hpp +index 02f958a..ebbe68f 100644 +--- a/include/vm_websocket.hpp ++++ b/include/vm_websocket.hpp +@@ -3,6 +3,7 @@ + #include + #include + #include ++#include + #include + + #include +@@ -156,8 +157,9 @@ static std::shared_ptr handler; + inline void requestRoutes(App& app) + { + BMCWEB_ROUTE(app, "/vm/0/0") +- .privileges({{"ConfigureComponents", "ConfigureManager"}}) + .websocket() ++ .privileges(redfish::privileges:: ++ privilegeSetConfigureManagerOrConfigureComponents) + .onopen([](crow::websocket::Connection& conn, + const std::shared_ptr&) { + BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened"; +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0005-Add-Privileges-to-SseSockets.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0005-Add-Privileges-to-SseSockets.patch new file mode 100644 index 000000000..06ffb3a46 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/http_routing/0005-Add-Privileges-to-SseSockets.patch @@ -0,0 +1,63 @@ +From 0ceb343809ff498cbfa389c54a158d255a2cca88 Mon Sep 17 00:00:00 2001 +From: P Dheeraj Srujan Kumar +Date: Mon, 18 Oct 2021 23:02:00 +0530 +Subject: [PATCH] Add Privileges to SseSockets + +This commit adds Privileges to Ssesockets. +In the current implementation, once a rule is upgraded (i.e. from +BaseRule to SseSocket), there is no provision to add priviliges. +In this commit, SseSocket inherits PrivilegeParameterTraits to +enable privileges. + +Also, in the earlier implementation, .privilege() was called after +BMCWEB_ROUTE(). This results in adding those privileges to the Base +rule that is created. By moving the privileges() below websocket(), +the privileges are applied to the Ssesocket. + +Tested: + - SSE Subscription was successful with Admin and Operator Users + - SSE Subscription was rejected while using Readonly User + - websocket_test.py Passed + - Admin and Operator users were able to access KVM on WebUI + - Readonly User was unable to access KVM on WebUI + +Change-Id: I41739401893b1c2bf718e11ec7676d69f954c98f +Signed-off-by: P Dheeraj Srujan Kumar +--- + http/routing.hpp | 4 +++- + include/eventservice_sse.hpp | 3 ++- + 2 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/http/routing.hpp b/http/routing.hpp +index 6ea3185..13174b2 100644 +--- a/http/routing.hpp ++++ b/http/routing.hpp +@@ -430,7 +430,9 @@ class WebSocketRule : + std::function errorHandler; + }; + +-class SseSocketRule : public BaseRule ++class SseSocketRule : ++ public BaseRule, ++ public PrivilegeParameterTraits + { + using self_t = SseSocketRule; + +diff --git a/include/eventservice_sse.hpp b/include/eventservice_sse.hpp +index 2f22f98..f880344 100644 +--- a/include/eventservice_sse.hpp ++++ b/include/eventservice_sse.hpp +@@ -192,8 +192,9 @@ static void deleteSubscription(std::shared_ptr& conn) + inline void requestRoutes(App& app) + { + BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/SSE") +- .privileges({{"ConfigureComponents", "ConfigureManager"}}) + .serverSentEvent() ++ .privileges(redfish::privileges:: ++ privilegeSetConfigureManagerOrConfigureComponents) + .onopen([](std::shared_ptr& conn, + const crow::Request& req, crow::Response& res) { + BMCWEB_LOG_DEBUG << "Connection " << conn << " opened."; +-- +2.17.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Add-support-for-MetricDefinition-scheme.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Add-support-for-MetricDefinition-scheme.patch index c19691cdc..f5226fe6e 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Add-support-for-MetricDefinition-scheme.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0001-Add-support-for-MetricDefinition-scheme.patch @@ -1,4 +1,4 @@ -From 80608f0d72da62426bb00e03a42fbf5daed931c9 Mon Sep 17 00:00:00 2001 +From 32e557279450226ed9c06312649d90b802f3d4c5 Mon Sep 17 00:00:00 2001 From: Krzysztof Grobelny Date: Tue, 13 Apr 2021 13:00:18 +0000 Subject: [PATCH] Add support for MetricDefinition scheme @@ -11,10 +11,11 @@ MetricDefinitions contains all physical sensors supported by redfish, algorithm iterates through all chassis and collects results for each node available in that chassis (Power, Thermal, Sensors). -When https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/40169 will -be merge it will be possible to optimize this algorithm to only get -sensors from Sensors node. Currently Sensors node doesn't contain all -available sensors. +When BMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM will be enabled by +default (meson option redfish-new-powersubsystem-thermalsubsystem) it +will be possible to optimize this algorithm to only get sensors from +Sensors node. Currently Sensors node doesn't contain all available +sensors. Tested: - MetricDefinitions response is filled with existing sensors, it works @@ -30,47 +31,54 @@ GET /redfish/v1/TelemetryService/MetricDefinitions "@odata.type": "#MetricDefinitionCollection.MetricDefinitionCollection", "Members": [ { - "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Rotational" + "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Fan_Pwm" }, { - "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Percent" + "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Fan_Tach" }, { - "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Temperature" + "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/HostCpuUtilization" }, { - "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Power" + "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/HostMemoryBandwidthUtilization" }, { - "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/AirFlow" + "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/HostPciBandwidthUtilization" + }, + { + "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Inlet_BRD_Temp" + }, + { + "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Left_Rear_Board_Temp" } ], - "Members@odata.count": 5, + "Members@odata.count": 7, "Name": "Metric Definition Collection" } -GET /redfish/v1/TelemetryService/MetricDefinitions/Rotational +GET /redfish/v1/TelemetryService/MetricDefinitions/Fan_Tach { - "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Rotational", + "@odata.id": "/redfish/v1/TelemetryService/MetricDefinitions/Fan_Tach", "@odata.type": "#MetricDefinition.v1_0_3.MetricDefinition", - "Id": "Rotational", - "Implementation": "PhysicalSensor", + "Id": "Fan_Tach", "IsLinear": true, + "MaxReadingRange": 25000.0, "MetricDataType": "Decimal", "MetricProperties": [ - "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/0/Reading", - "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/1/Reading", - "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/2/Reading", - "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/3/Reading", - "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/4/Reading", - "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/5/Reading", - "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/6/Reading", - "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/7/Reading", - "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/8/Reading", - "/redfish/v1/Chassis/Chassis0/Thermal#/Fans/9/Reading" + "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/0/Reading", + "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/1/Reading", + "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/2/Reading", + "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/3/Reading", + "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/4/Reading", + "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/5/Reading", + "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/6/Reading", + "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/7/Reading", + "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/8/Reading", + "/redfish/v1/Chassis/AC_Baseboard/Thermal#/Fans/9/Reading" ], - "MetricType": "Numeric", - "Name": "Rotational", + "MetricType": "Gauge", + "MinReadingRange": 0.0, + "Name": "Fan_Tach", "Units": "RPM" } @@ -109,16 +117,16 @@ Signed-off-by: Krzysztof Grobelny Change-Id: I3086e1302e1ba2e5442d1367939fd5507a0cbc00 --- redfish-core/include/redfish.hpp | 3 + - .../include/utils/get_chassis_names.hpp | 58 ++++ + .../include/utils/get_chassis_names.hpp | 58 +++ .../include/utils/telemetry_utils.hpp | 2 + - redfish-core/lib/metric_definition.hpp | 258 ++++++++++++++++++ - redfish-core/lib/telemetry_service.hpp | 2 + - 5 files changed, 323 insertions(+) + redfish-core/lib/metric_definition.hpp | 368 ++++++++++++++++++ + redfish-core/lib/telemetry_service.hpp | 3 +- + 5 files changed, 433 insertions(+), 1 deletion(-) create mode 100644 redfish-core/include/utils/get_chassis_names.hpp create mode 100644 redfish-core/lib/metric_definition.hpp diff --git a/redfish-core/include/redfish.hpp b/redfish-core/include/redfish.hpp -index 1c7b695..9983b88 100644 +index 0a97150..67c5af2 100644 --- a/redfish-core/include/redfish.hpp +++ b/redfish-core/include/redfish.hpp @@ -26,6 +26,7 @@ @@ -129,7 +137,7 @@ index 1c7b695..9983b88 100644 #include "../lib/metric_report.hpp" #include "../lib/metric_report_definition.hpp" #include "../lib/network_protocol.hpp" -@@ -199,6 +200,8 @@ class RedfishService +@@ -200,6 +201,8 @@ class RedfishService requestRoutesMetricReportDefinition(app); requestRoutesMetricReportCollection(app); requestRoutesMetricReport(app); @@ -217,10 +225,10 @@ index 5872350..1b4f75d 100644 constexpr const char* metricReportUri = diff --git a/redfish-core/lib/metric_definition.hpp b/redfish-core/lib/metric_definition.hpp new file mode 100644 -index 0000000..019168b +index 0000000..347c297 --- /dev/null +++ b/redfish-core/lib/metric_definition.hpp -@@ -0,0 +1,258 @@ +@@ -0,0 +1,368 @@ +#pragma once + +#include "async_resp.hpp" @@ -236,55 +244,160 @@ index 0000000..019168b +namespace telemetry +{ + -+bool containsOdata(const nlohmann::json& json, const std::string& odataId) ++struct ValueVisitor +{ -+ const auto it = std::find_if( -+ json.begin(), json.end(), [&odataId](const nlohmann::json& item) { -+ auto kt = item.find("@odata.id"); -+ if (kt == item.end()) ++ ValueVisitor(boost::system::error_code& ec) : ec(ec) ++ {} ++ ++ template ++ double operator()(T value) const ++ { ++ return static_cast(value); ++ } ++ ++ double operator()(std::monostate) const ++ { ++ ec = boost::system::errc::make_error_code( ++ boost::system::errc::invalid_argument); ++ return double{}; ++ } ++ ++ boost::system::error_code& ec; ++}; ++ ++inline void getReadingRange( ++ const std::string& service, const std::string& path, ++ const std::string& property, ++ std::function callback) ++{ ++ crow::connections::systemBus->async_method_call( ++ [callback = std::move(callback)]( ++ boost::system::error_code ec, ++ const std::variant& ++ valueVariant) { ++ if (ec) + { -+ return false; ++ callback(ec, double{}); ++ return; + } -+ const std::string* value = kt->get_ptr(); -+ if (!value) ++ ++ const double value = std::visit(ValueVisitor(ec), valueVariant); ++ ++ callback(ec, value); ++ }, ++ service, path, "org.freedesktop.DBus.Properties", "Get", ++ "xyz.openbmc_project.Sensor.Value", property); ++} ++ ++inline void ++ fillMinMaxReadingRange(const std::shared_ptr& asyncResp, ++ const std::string& serviceName, ++ const std::string& sensorPath) ++{ ++ asyncResp->res.jsonValue["MetricType"] = "Numeric"; ++ ++ telemetry::getReadingRange( ++ serviceName, sensorPath, "MinValue", ++ [asyncResp](boost::system::error_code ec, double readingRange) { ++ if (ec) + { -+ return false; ++ messages::internalError(asyncResp->res); ++ return; ++ } ++ ++ if (std::isfinite(readingRange)) ++ { ++ asyncResp->res.jsonValue["MetricType"] = "Gauge"; ++ ++ asyncResp->res.jsonValue["MinReadingRange"] = readingRange; + } -+ return *value == odataId; + }); + -+ return it != json.end(); ++ telemetry::getReadingRange( ++ serviceName, sensorPath, "MaxValue", ++ [asyncResp](boost::system::error_code ec, double readingRange) { ++ if (ec) ++ { ++ messages::internalError(asyncResp->res); ++ return; ++ } ++ ++ if (std::isfinite(readingRange)) ++ { ++ asyncResp->res.jsonValue["MetricType"] = "Gauge"; ++ ++ asyncResp->res.jsonValue["MaxReadingRange"] = readingRange; ++ } ++ }); +} + -+void addMembers(crow::Response& res, -+ const boost::container::flat_map& el) ++inline void getSensorService( ++ const std::string& sensorPath, ++ std::function callback) +{ -+ for (const auto& [_, dbusSensor] : el) -+ { -+ sdbusplus::message::object_path path(dbusSensor); -+ sdbusplus::message::object_path parentPath = path.parent_path(); -+ const std::string type = parentPath.filename(); ++ using ResultType = std::pair< ++ std::string, ++ std::vector>>>; + -+ if (type.empty()) -+ { -+ BMCWEB_LOG_ERROR << "Received invalid DBus Sensor Path = " -+ << dbusSensor; -+ continue; -+ } ++ crow::connections::systemBus->async_method_call( ++ [sensorPath, callback = std::move(callback)]( ++ boost::system::error_code ec, ++ const std::vector& result) { ++ if (ec) ++ { ++ callback(ec, std::string{}); ++ return; ++ } ++ ++ for (const auto& [path, serviceToInterfaces] : result) ++ { ++ if (path == sensorPath) ++ { ++ for (const auto& [service, interfaces] : ++ serviceToInterfaces) ++ { ++ callback(boost::system::errc::make_error_code( ++ boost::system::errc::success), ++ service); ++ return; ++ } ++ } ++ } + -+ nlohmann::json& members = res.jsonValue["Members"]; ++ callback(boost::system::errc::make_error_code( ++ boost::system::errc::no_such_file_or_directory), ++ std::string{}); ++ }, ++ "xyz.openbmc_project.ObjectMapper", ++ "/xyz/openbmc_project/object_mapper", ++ "xyz.openbmc_project.ObjectMapper", "GetSubTree", ++ "/xyz/openbmc_project/sensors", 2, ++ std::array{"xyz.openbmc_project.Sensor.Value"}); ++} + -+ const std::string odataId = -+ std::string(telemetry::metricDefinitionUri) + -+ sensors::toReadingType(type); ++constexpr auto metricDefinitionMapping = std::array{ ++ std::pair{"fan_pwm", "Fan_Pwm"}, std::pair{"fan_tach", "Fan_Tach"}}; + -+ if (!containsOdata(members, odataId)) -+ { -+ members.push_back({{"@odata.id", odataId}}); -+ } ++std::string mapSensorToMetricDefinition(const std::string& sensorPath) ++{ ++ sdbusplus::message::object_path sensorObjectPath{sensorPath}; ++ ++ const auto it = std::find_if( ++ metricDefinitionMapping.begin(), metricDefinitionMapping.end(), ++ [&sensorObjectPath](const auto& item) { ++ return item.first == sensorObjectPath.parent_path().filename(); ++ }); ++ ++ const char* metricDefinitionPath = ++ "/redfish/v1/TelemetryService/MetricDefinitions/"; + -+ res.jsonValue["Members@odata.count"] = members.size(); ++ if (it != metricDefinitionMapping.end()) ++ { ++ return std::string{metricDefinitionPath} + it->second; + } ++ ++ return metricDefinitionPath + sensorObjectPath.filename(); +} + +template @@ -300,8 +413,11 @@ index 0000000..019168b + return; + } + ++ auto counter = std::make_shared, size_t>>(); ++ + auto handleRetrieveUriToDbusMap = -+ [callback = std::move(callback)]( ++ [counter, callback = std::move(callback)]( + const boost::beast::http::status status, + const boost::container::flat_map& + uriToDbus) { @@ -310,21 +426,31 @@ index 0000000..019168b + BMCWEB_LOG_ERROR << "Failed to retrieve URI to dbus " + "sensors map with err " + << static_cast(status); ++ counter->second = 0u; + callback(boost::system::errc::make_error_code( + boost::system::errc::io_error), + {}); + return; + } + -+ callback(boost::system::errc::make_error_code( -+ boost::system::errc::success), -+ uriToDbus); ++ for (const auto& [key, value] : uriToDbus) ++ { ++ counter->first[key] = value; ++ } ++ ++ if (--counter->second == 0u) ++ { ++ callback(boost::system::errc::make_error_code( ++ boost::system::errc::success), ++ counter->first); ++ } + }; + + for (const std::string& chassisName : chassisNames) + { + for (const auto& [sensorNode, dbusPaths] : sensors::dbus::paths) + { ++ ++counter->second; + retrieveUriToDbusMap(chassisName, sensorNode.data(), + handleRetrieveUriToDbusMap); + } @@ -354,7 +480,23 @@ index 0000000..019168b + return; + } + -+ telemetry::addMembers(asyncResp->res, uriToDbus); ++ std::set members; ++ ++ for (const auto& [uri, dbusPath] : uriToDbus) ++ { ++ members.insert( ++ telemetry::mapSensorToMetricDefinition( ++ dbusPath)); ++ } ++ ++ for (const std::string& odataId : members) ++ { ++ asyncResp->res.jsonValue["Members"].push_back( ++ {{"@odata.id", odataId}}); ++ } ++ ++ asyncResp->res.jsonValue["Members@odata.count"] = ++ asyncResp->res.jsonValue["Members"].size(); + }); + + asyncResp->res.jsonValue["@odata.type"] = @@ -369,128 +511,109 @@ index 0000000..019168b + }); +} + -+namespace telemetry -+{ -+ -+bool isSensorIdSupported(std::string_view readingType) -+{ -+ for (const std::pair>& -+ typeToPaths : sensors::dbus::paths) -+ { -+ for (const char* supportedPath : typeToPaths.second) -+ { -+ if (readingType == -+ sensors::toReadingType( -+ sdbusplus::message::object_path(supportedPath).filename())) -+ { -+ return true; -+ } -+ } -+ } -+ return false; -+} -+ -+void addMetricProperty( -+ bmcweb::AsyncResp& asyncResp, const std::string& readingType, -+ const boost::container::flat_map& el) -+{ -+ nlohmann::json& metricProperties = -+ asyncResp.res.jsonValue["MetricProperties"]; -+ -+ for (const auto& [redfishSensor, dbusSensor] : el) -+ { -+ std::string sensorId; -+ if (dbus::utility::getNthStringFromPath(dbusSensor, 3, sensorId)) -+ { -+ if (sensors::toReadingType(sensorId) == readingType) -+ { -+ metricProperties.push_back(redfishSensor); -+ } -+ } -+ } -+} -+ -+inline const char* readingTypeToReadingUnits(const std::string& readingType) -+{ -+ for (const auto& [node, paths] : sensors::dbus::paths) -+ { -+ for (const char* path : paths) -+ { -+ const sdbusplus::message::object_path sensorPath = -+ sdbusplus::message::object_path(path); -+ if (sensors::toReadingType(sensorPath.filename()) == readingType) -+ { -+ return sensors::toReadingUnits(sensorPath.filename()); -+ } -+ } -+ } -+ return ""; -+} -+ -+} // namespace telemetry -+ +inline void requestRoutesMetricDefinition(App& app) +{ + BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/MetricDefinitions//") + .privileges(privileges::getTelemetryService) -+ .methods(boost::beast::http::verb::get)( -+ [](const crow::Request&, -+ const std::shared_ptr& asyncResp, -+ const std::string& readingType) { -+ if (!telemetry::isSensorIdSupported(readingType)) -+ { -+ messages::resourceNotFound(asyncResp->res, -+ "MetricDefinition", readingType); -+ return; -+ } -+ -+ telemetry::mapRedfishUriToDbusPath( -+ [asyncResp, -+ readingType](boost::system::error_code ec, -+ const boost::container::flat_map< -+ std::string, std::string>& uriToDbus) { -+ if (ec) ++ .methods( ++ boost::beast::http::verb::get)([](const crow::Request&, ++ const std::shared_ptr< ++ bmcweb::AsyncResp>& asyncResp, ++ const std::string& name) { ++ telemetry::mapRedfishUriToDbusPath( ++ [asyncResp, name]( ++ boost::system::error_code ec, ++ const boost::container::flat_map& ++ uriToDbus) { ++ if (ec) ++ { ++ messages::internalError(asyncResp->res); ++ BMCWEB_LOG_ERROR << "mapRedfishUriToDbusPath error: " ++ << ec.value(); ++ return; ++ } ++ ++ std::string odataId = telemetry::metricDefinitionUri + name; ++ boost::container::flat_map ++ matchingUris; ++ ++ for (const auto& [uri, dbusPath] : uriToDbus) ++ { ++ if (telemetry::mapSensorToMetricDefinition(dbusPath) == ++ odataId) + { -+ messages::internalError(asyncResp->res); -+ BMCWEB_LOG_ERROR -+ << "mapRedfishUriToDbusPath error: " -+ << ec.value(); -+ return; ++ matchingUris.emplace(uri, dbusPath); + } -+ -+ asyncResp->res.jsonValue["Id"] = readingType; -+ asyncResp->res.jsonValue["Name"] = readingType; -+ asyncResp->res.jsonValue["@odata.id"] = -+ telemetry::metricDefinitionUri + readingType; -+ asyncResp->res.jsonValue["@odata.type"] = -+ "#MetricDefinition.v1_0_3.MetricDefinition"; -+ asyncResp->res.jsonValue["MetricDataType"] = "Decimal"; -+ asyncResp->res.jsonValue["MetricType"] = "Numeric"; -+ asyncResp->res.jsonValue["IsLinear"] = true; -+ asyncResp->res.jsonValue["Implementation"] = -+ "PhysicalSensor"; -+ asyncResp->res.jsonValue["Units"] = -+ telemetry::readingTypeToReadingUnits(readingType); -+ -+ telemetry::addMetricProperty(*asyncResp, readingType, -+ uriToDbus); -+ }); -+ }); ++ } ++ ++ if (matchingUris.empty()) ++ { ++ messages::resourceNotFound(asyncResp->res, ++ "MetricDefinition", name); ++ return; ++ } ++ ++ std::string sensorPath = matchingUris.begin()->second; ++ ++ telemetry::getSensorService( ++ sensorPath, ++ [asyncResp, name, odataId = std::move(odataId), ++ sensorPath, matchingUris = std::move(matchingUris)]( ++ boost::system::error_code ec, ++ const std::string& serviceName) { ++ if (ec) ++ { ++ messages::internalError(asyncResp->res); ++ BMCWEB_LOG_ERROR << "getServiceSensorFailed: " ++ << ec.value(); ++ return; ++ } ++ ++ asyncResp->res.jsonValue["Id"] = name; ++ asyncResp->res.jsonValue["Name"] = name; ++ asyncResp->res.jsonValue["@odata.id"] = odataId; ++ asyncResp->res.jsonValue["@odata.type"] = ++ "#MetricDefinition.v1_0_3.MetricDefinition"; ++ asyncResp->res.jsonValue["MetricDataType"] = ++ "Decimal"; ++ asyncResp->res.jsonValue["IsLinear"] = true; ++ asyncResp->res.jsonValue["Units"] = ++ sensors::toReadingUnits( ++ sdbusplus::message::object_path{sensorPath} ++ .parent_path() ++ .filename()); ++ ++ for (const auto& [uri, dbusPath] : matchingUris) ++ { ++ asyncResp->res.jsonValue["MetricProperties"] ++ .push_back(uri); ++ } ++ ++ telemetry::fillMinMaxReadingRange( ++ asyncResp, serviceName, sensorPath); ++ }); ++ }); ++ }); +} + +} // namespace redfish diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp -index ad86d5c..c4962e9 100644 +index 8ecc591..027b51b 100644 --- a/redfish-core/lib/telemetry_service.hpp +++ b/redfish-core/lib/telemetry_service.hpp -@@ -29,6 +29,8 @@ inline void requestRoutesTelemetryService(App& app) - "/redfish/v1/TelemetryService/MetricReportDefinitions"; - asyncResp->res.jsonValue["MetricReports"]["@odata.id"] = - "/redfish/v1/TelemetryService/MetricReports"; -+ asyncResp->res.jsonValue["MetricDefinitions"]["@odata.id"] = -+ "/redfish/v1/TelemetryService/MetricDefinitions"; +@@ -18,11 +18,12 @@ inline void handleTelemetryServiceGet( + asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TelemetryService"; + asyncResp->res.jsonValue["Id"] = "TelemetryService"; + asyncResp->res.jsonValue["Name"] = "Telemetry Service"; +- + asyncResp->res.jsonValue["MetricReportDefinitions"]["@odata.id"] = + "/redfish/v1/TelemetryService/MetricReportDefinitions"; + asyncResp->res.jsonValue["MetricReports"]["@odata.id"] = + "/redfish/v1/TelemetryService/MetricReports"; ++ asyncResp->res.jsonValue["MetricDefinitions"]["@odata.id"] = ++ "/redfish/v1/TelemetryService/MetricDefinitions"; - crow::connections::systemBus->async_method_call( - [asyncResp]( + crow::connections::systemBus->async_method_call( + [asyncResp](const boost::system::error_code ec, -- 2.25.1 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Sync-Telmetry-service-with-EventService.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Sync-Telmetry-service-with-EventService.patch index d32c85356..3088a7f9d 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Sync-Telmetry-service-with-EventService.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0002-Sync-Telmetry-service-with-EventService.patch @@ -1,4 +1,4 @@ -From 77e8a0b5037a555b1520823b667595ac8780c675 Mon Sep 17 00:00:00 2001 +From 541353a4e4b06de42b6a9a400629f5a5fba04e86 Mon Sep 17 00:00:00 2001 From: "Wludzik, Jozef" Date: Tue, 15 Dec 2020 12:30:31 +0100 Subject: [PATCH] Sync Telmetry service with EventService @@ -16,13 +16,14 @@ Tested: Change-Id: I2fc1841a6c9259a8bff30b34bddc0d4aabd41912 Signed-off-by: Wludzik, Jozef +Signed-off-by: Lukasz Kazmierczak --- .../include/event_service_manager.hpp | 156 ++++++------------ redfish-core/lib/metric_report.hpp | 28 ++-- 2 files changed, 69 insertions(+), 115 deletions(-) diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp -index d89b789..4faaddd 100644 +index 3f398d7..cf9f658 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -14,6 +14,7 @@ @@ -212,12 +213,12 @@ index d89b789..4faaddd 100644 + }); + if (found == props.end()) + { -+ BMCWEB_LOG_ERROR ++ BMCWEB_LOG_INFO + << "Failed to get Readings from Report properties"; + return; + } + -+ std::variant& readings = ++ const std::variant& readings = + found->second; + for (const auto& it : + EventServiceManager::getInstance().subscriptionsMap) diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Switched-bmcweb-to-use-new-telemetry-service-API.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Switched-bmcweb-to-use-new-telemetry-service-API.patch index 20bcbabfa..5dd2f51bc 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Switched-bmcweb-to-use-new-telemetry-service-API.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0003-Switched-bmcweb-to-use-new-telemetry-service-API.patch @@ -1,4 +1,4 @@ -From fca6f5b951a363916a83a25f6578f95a6cf32a3e Mon Sep 17 00:00:00 2001 +From 8ba1bcc3503cafb33b1a06356d4f8f92ae23e39a Mon Sep 17 00:00:00 2001 From: Krzysztof Grobelny Date: Thu, 17 Jun 2021 13:37:57 +0000 Subject: [PATCH] Switched bmcweb to use new telemetry service API diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-MetricDefinition-property-in-MetricReport.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-MetricDefinition-property-in-MetricReport.patch index 3d60ae293..bf5a09d9d 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-MetricDefinition-property-in-MetricReport.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0004-Add-support-for-MetricDefinition-property-in-MetricReport.patch @@ -1,6 +1,6 @@ -From 79b3d35b864a2b545b4c9b2ac9390ea5dec169f5 Mon Sep 17 00:00:00 2001 -From: Szymon Dompke -Date: Mon, 28 Jun 2021 11:10:23 +0200 +From dab3c96f9e39a89d7c359e22655650c7c16952ec Mon Sep 17 00:00:00 2001 +From: Krzysztof Grobelny +Date: Tue, 12 Oct 2021 08:06:13 +0000 Subject: [PATCH] Add support for MetricDefinition property in MetricReport Added MetricDefinition as part of MetricValues array returned by @@ -73,19 +73,19 @@ Signed-off-by: Szymon Dompke 4 files changed, 95 insertions(+), 15 deletions(-) diff --git a/meson.build b/meson.build -index f6a66f1..6b5d9af 100644 +index 6b6a8ab..218ea49 100644 --- a/meson.build +++ b/meson.build -@@ -355,6 +355,8 @@ srcfiles_unittest = ['include/ut/dbus_utility_test.cpp', - 'redfish-core/ut/time_utils_test.cpp', - 'http/ut/utility_test.cpp'] +@@ -377,6 +377,8 @@ srcfiles_unittest = [ + 'http/ut/utility_test.cpp' + ] -+srcfiles_unittest_dependencies = ['redfish-core/src/error_messages.cpp'] ++srcfiles_unittest_dependencies = ['redfish-core/src/error_messages.cpp', 'src/boost_url.cpp'] + # Gather the Configuration data conf_data = configuration_data() -@@ -412,7 +414,7 @@ executable('bmcweb',srcfiles_bmcweb, +@@ -434,7 +436,7 @@ executable('bmcweb',srcfiles_bmcweb, if(get_option('tests').enabled()) foreach src_test : srcfiles_unittest testname = src_test.split('/')[-1].split('.')[0] @@ -251,7 +251,7 @@ index 7fe281d..13bf792 100644 } } // namespace telemetry diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp -index cb7ea15..44c2129 100644 +index 7405e5a..9850b24 100644 --- a/redfish-core/lib/sensors.hpp +++ b/redfish-core/lib/sensors.hpp @@ -21,6 +21,8 @@ @@ -265,3 +265,4 @@ index cb7ea15..44c2129 100644 -- 2.25.1 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0006-Revert-Remove-LogService-from-TelemetryService.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0006-Revert-Remove-LogService-from-TelemetryService.patch index 987a43b4c..a80ac61c7 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0006-Revert-Remove-LogService-from-TelemetryService.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0006-Revert-Remove-LogService-from-TelemetryService.patch @@ -1,6 +1,6 @@ -From 472ac5f15a19917042852b243e8b668b3ab49e32 Mon Sep 17 00:00:00 2001 +From da575aaf0bdcb15be261d58314cf7bbbcd92dd74 Mon Sep 17 00:00:00 2001 From: Krzysztof Grobelny -Date: Tue, 22 Jun 2021 13:59:48 +0000 +Date: Tue, 12 Oct 2021 08:08:06 +0000 Subject: [PATCH] Revert "Remove LogService from TelemetryService" This reverts commit 2b3da45876aac57a36d3093379a992d699e7e396. @@ -9,18 +9,18 @@ This reverts commit 2b3da45876aac57a36d3093379a992d699e7e396. 1 file changed, 2 insertions(+) diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp -index 37221c3..f3a1efb 100644 +index 027b51b..49471fe 100644 --- a/redfish-core/lib/telemetry_service.hpp +++ b/redfish-core/lib/telemetry_service.hpp -@@ -30,6 +30,8 @@ inline void requestRoutesTelemetryService(App& app) - "/redfish/v1/TelemetryService/MetricReports"; - asyncResp->res.jsonValue["MetricDefinitions"]["@odata.id"] = - "/redfish/v1/TelemetryService/MetricDefinitions"; -+ asyncResp->res.jsonValue["LogService"]["@odata.id"] = -+ "/redfish/v1/Managers/bmc/LogServices/Journal"; +@@ -24,6 +24,8 @@ inline void handleTelemetryServiceGet( + "/redfish/v1/TelemetryService/MetricReports"; + asyncResp->res.jsonValue["MetricDefinitions"]["@odata.id"] = + "/redfish/v1/TelemetryService/MetricDefinitions"; ++ asyncResp->res.jsonValue["LogService"]["@odata.id"] = ++ "/redfish/v1/Managers/bmc/LogServices/Journal"; - crow::connections::systemBus->async_method_call( - [asyncResp]( + crow::connections::systemBus->async_method_call( + [asyncResp](const boost::system::error_code ec, -- 2.25.1 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0008-Generalize-ReadingType-in-MetricDefinition.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0008-Generalize-ReadingType-in-MetricDefinition.patch deleted file mode 100644 index bd6e64346..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/0008-Generalize-ReadingType-in-MetricDefinition.patch +++ /dev/null @@ -1,93 +0,0 @@ -From d9baec3ccdff5ed4d1620f374a252c769de5b45b Mon Sep 17 00:00:00 2001 -From: Krzysztof Grobelny -Date: Thu, 19 Aug 2021 10:55:38 +0000 -Subject: [PATCH] Generalize ReadingType in MetricDefinition - -Recent addition of PMT required adding new type of sensor 'count', which -doesnt comply with any of Redfish-defined Sensor.ReadingType values. - -To support property of this kind MetricDefinition implementation was -altered to support sensor types not covered by Redfish types by -a 'fallback' to direct usage of sensor type. Populating 'Units' was also -modified, so it won't be shown if value does not have any units mapped. - -Testing: -- PMT counters are shown properly in MetricDefinitions/Count -- Redfish Validator passes ---- - redfish-core/lib/metric_definition.hpp | 25 ++++++++++++++++++------- - 1 file changed, 18 insertions(+), 7 deletions(-) - -diff --git a/redfish-core/lib/metric_definition.hpp b/redfish-core/lib/metric_definition.hpp -index 019168b..df29b65 100644 ---- a/redfish-core/lib/metric_definition.hpp -+++ b/redfish-core/lib/metric_definition.hpp -@@ -33,6 +33,18 @@ bool containsOdata(const nlohmann::json& json, const std::string& odataId) - return it != json.end(); - } - -+std::string groupName(const std::string& sensorType) -+{ -+ std::string group = sensors::toReadingType(sensorType); -+ if (group.empty()) -+ { -+ // Fallback for types not covered by standard Redfish Sensor.ReadingType -+ group = sensorType; -+ group[0] = static_cast(std::toupper(group[0])); -+ } -+ return group; -+} -+ - void addMembers(crow::Response& res, - const boost::container::flat_map& el) - { -@@ -52,8 +64,7 @@ void addMembers(crow::Response& res, - nlohmann::json& members = res.jsonValue["Members"]; - - const std::string odataId = -- std::string(telemetry::metricDefinitionUri) + -- sensors::toReadingType(type); -+ std::string(telemetry::metricDefinitionUri) + groupName(type); - - if (!containsOdata(members, odataId)) - { -@@ -149,15 +160,15 @@ inline void requestRoutesMetricDefinitionCollection(App& app) - namespace telemetry - { - --bool isSensorIdSupported(std::string_view readingType) -+bool isSensorIdSupported(std::string_view group) - { - for (const std::pair>& - typeToPaths : sensors::dbus::paths) - { - for (const char* supportedPath : typeToPaths.second) - { -- if (readingType == -- sensors::toReadingType( -+ if (group == -+ groupName( - sdbusplus::message::object_path(supportedPath).filename())) - { - return true; -@@ -168,7 +179,7 @@ bool isSensorIdSupported(std::string_view readingType) - } - - void addMetricProperty( -- bmcweb::AsyncResp& asyncResp, const std::string& readingType, -+ bmcweb::AsyncResp& asyncResp, const std::string& group, - const boost::container::flat_map& el) - { - nlohmann::json& metricProperties = -@@ -179,7 +190,7 @@ void addMetricProperty( - std::string sensorId; - if (dbus::utility::getNthStringFromPath(dbusSensor, 3, sensorId)) - { -- if (sensors::toReadingType(sensorId) == readingType) -+ if (groupName(sensorId) == group) - { - metricProperties.push_back(redfishSensor); - } --- -2.25.1 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README index fd88e9e18..90916ecec 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/telemetry/README @@ -3,16 +3,16 @@ Until change is integrated they will be manually merged here to enable feature i Current revisions: - Add support for MetricDefinition scheme - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/33363/93 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/33363/102 - Sync Telmetry service with EventService - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/38798/40 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/38798/53 - Switched bmcweb to use new telemetry service API - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/44270/5 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/44270/19 - Add support for MetricDefinition property in MetricReport - https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/44512/9 + https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/44512/24 - Add GET method for TriggerCollection file://telemetry/0005-Add-GET-method-for-TriggerCollection.patch diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/vm/0001-Revert-Disable-nbd-proxy-from-the-build.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/vm/0001-Revert-Disable-nbd-proxy-from-the-build.patch index d41383836..de316c4fa 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/vm/0001-Revert-Disable-nbd-proxy-from-the-build.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/vm/0001-Revert-Disable-nbd-proxy-from-the-build.patch @@ -1,4 +1,4 @@ -From 3ee7fe58b2acec0a6ae4eabad91a9dd609268870 Mon Sep 17 00:00:00 2001 +From b6863f9a0c1c36705eba0c3181541f67cd1a202a Mon Sep 17 00:00:00 2001 From: Krzysztof Grobelny Date: Wed, 14 Jul 2021 09:04:42 +0000 Subject: [PATCH] Revert "Disable nbd proxy from the build" @@ -15,21 +15,21 @@ Change-Id: I19a88b30c1074dd376f2df8f5668245b638b881f 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/meson.build b/meson.build -index bdc514b..19364a8 100644 +index 650a5ec..5738b10 100644 --- a/meson.build +++ b/meson.build -@@ -78,7 +78,8 @@ feature_map = { - 'rest' : '-DBMCWEB_ENABLE_DBUS_REST', - 'static-hosting' : '-DBMCWEB_ENABLE_STATIC_HOSTING', - 'insecure-tftp-update' : '-DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE', --#'vm-nbdproxy' : '-DBMCWEB_ENABLE_VM_NBDPROXY', -+'validate-unsecure-feature' : '-DBMCWEB_ENABLE_VALIDATION_UNSECURE_FEATURE', -+'vm-nbdproxy' : '-DBMCWEB_ENABLE_VM_NBDPROXY', - 'vm-websocket' : '-DBMCWEB_ENABLE_VM_WEBSOCKET', +@@ -83,7 +83,8 @@ feature_map = { + 'rest' : '-DBMCWEB_ENABLE_DBUS_REST', + 'static-hosting' : '-DBMCWEB_ENABLE_STATIC_HOSTING', + 'insecure-tftp-update' : '-DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE', +- #'vm-nbdproxy' : '-DBMCWEB_ENABLE_VM_NBDPROXY', ++ 'validate-unsecure-feature' : '-DBMCWEB_ENABLE_VALIDATION_UNSECURE_FEATURE', ++ 'vm-nbdproxy' : '-DBMCWEB_ENABLE_VM_NBDPROXY', + 'vm-websocket' : '-DBMCWEB_ENABLE_VM_WEBSOCKET', } diff --git a/meson_options.txt b/meson_options.txt -index 0ab31b8..ea0f2fc 100644 +index ff5b887..645f224 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -3,14 +3,7 @@ option('yocto-deps', type: 'feature', value: 'disabled', description : 'Use YOCT @@ -48,7 +48,7 @@ index 0ab31b8..ea0f2fc 100644 option('rest', type : 'feature', value : 'enabled', description : '''Enable Phosphor REST (D-Bus) APIs. Paths directly map Phosphor D-Bus object paths, for example, \'/xyz/openbmc_project/logging/entry/enumerate\'. See https://github.com/openbmc/docs/blob/master/rest-api.md.''') option('redfish', type : 'feature',value : 'enabled', description: 'Enable Redfish APIs. Paths are under \'/redfish/v1/\'. See https://github.com/openbmc/bmcweb/blob/master/DEVELOPING.md#redfish.') option('host-serial-socket', type : 'feature', value : 'enabled', description : 'Enable host serial console WebSocket. Path is \'/console0\'. See https://github.com/openbmc/docs/blob/master/console.md.') -@@ -37,6 +30,7 @@ option ('https_port', type : 'integer', min : 1, max : 65535, value : 443, descr +@@ -39,6 +32,7 @@ option ('https_port', type : 'integer', min : 1, max : 65535, value : 443, descr # the implications of doing so.In general, enabling these options will cause security # problems of varying degrees @@ -57,5 +57,5 @@ index 0ab31b8..ea0f2fc 100644 option ('insecure-disable-ssl', type : 'feature', value : 'disabled', description : 'Disable SSL ports. Should be set to false for production systems.') option ('insecure-disable-auth', type : 'feature', value : 'disabled', description : 'Disable authentication on all ports. Should be set to false for production systems') -- -2.25.1 +2.17.1 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/vm/0003-Add-ConnectedVia-property-to-virtual-media-item-temp.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/vm/0003-Add-ConnectedVia-property-to-virtual-media-item-temp.patch index 41c1c9836..c8af3a659 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/vm/0003-Add-ConnectedVia-property-to-virtual-media-item-temp.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/vm/0003-Add-ConnectedVia-property-to-virtual-media-item-temp.patch @@ -1,4 +1,4 @@ -From d303bfdd6778c43096401ff78fab70f9041cd4cf Mon Sep 17 00:00:00 2001 +From 1abf9a1d336eed835472fe933210d3be7ad5ba7a Mon Sep 17 00:00:00 2001 From: Karol Wachowski Date: Thu, 11 Feb 2021 08:35:41 +0000 Subject: [PATCH] Add ConnectedVia property to virtual media item template @@ -12,12 +12,12 @@ Signed-off-by: Karol Wachowski 1 file changed, 1 insertion(+) diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp -index c45fed2..aa7c639 100644 +index 57c2bd2..de1cc94 100644 --- a/redfish-core/lib/virtual_media.hpp +++ b/redfish-core/lib/virtual_media.hpp -@@ -193,6 +193,7 @@ static nlohmann::json vmItemTemplate(const std::string& name, - item["@odata.id"] = - "/redfish/v1/Managers/" + name + "/VirtualMedia/" + resName; +@@ -200,6 +200,7 @@ inline nlohmann::json vmItemTemplate(const std::string& name, + item["@odata.id"] = std::move(id); + item["@odata.type"] = "#VirtualMedia.v1_3_0.VirtualMedia"; + item["ConnectedVia"] = "NotConnected"; item["Name"] = "Virtual Removable Media"; diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend index 7806b5481..a716e612d 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb_%.bbappend @@ -1,8 +1,7 @@ SRC_URI = "git://github.com/openbmc/bmcweb.git" -SRCREV = "abb93cdd0a49be03bf2fe95f07823686b289ecd5" +SRCREV = "b7ff344535c42af074c60bfb272ef66a2ba157b4" DEPENDS += "boost-url" -RDEPENDS:${PN} += "phosphor-nslcd-authority-cert-config" FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:" @@ -25,9 +24,9 @@ SRC_URI += "file://0001-Firmware-update-configuration-changes.patch \ file://0018-bmcweb-Add-BMC-Time-update-log-to-the-registry.patch \ file://0019-Add-generic-message-PropertySizeExceeded.patch \ file://0020-Redfish-Deny-set-AccountLockDuration-to-zero.patch \ - file://0021-Add-message-registry-entry-for-FirmwareResiliencyErr.patch \ file://0023-Add-get-IPMI-session-id-s-to-Redfish.patch \ file://0024-Add-count-sensor-type.patch \ + file://0025-Add-Model-CoreCount-to-ProcessorSummary.patch \ " # OOB Bios Config: @@ -50,7 +49,7 @@ SRC_URI += "file://vm/0001-Revert-Disable-nbd-proxy-from-the-build.patch \ " # EventService: Temporary pulled to downstream. See eventservice\README for details -SRC_URI += "file://eventservice/0001-EventService-Fix-retry-handling-for-http-client.patch \ +SRC_URI += "file://eventservice/0001-Add-unmerged-changes-for-http-retry-support.patch \ file://eventservice/0002-EventService-https-client-support.patch \ file://eventservice/0004-Add-Server-Sent-Events-support.patch \ file://eventservice/0005-Add-SSE-style-subscription-support-to-eventservice.patch \ @@ -59,6 +58,7 @@ SRC_URI += "file://eventservice/0001-EventService-Fix-retry-handling-for-http-cl file://eventservice/0008-Add-checks-on-Event-Subscription-input-parameters.patch \ file://eventservice/0009-Restructure-Redifsh-EventLog-Transmit-code-flow.patch \ file://eventservice/0010-Remove-Terminated-Event-Subscriptions.patch \ + file://eventservice/0011-Fix-bmcweb-crash-while-deleting-terminated-subscriptions.patch \ " # Temporary downstream mirror of upstream patches, see telemetry\README for details @@ -69,20 +69,23 @@ SRC_URI += " file://telemetry/0001-Add-support-for-MetricDefinition-scheme.patch file://telemetry/0005-Add-GET-method-for-TriggerCollection.patch \ file://telemetry/0006-Revert-Remove-LogService-from-TelemetryService.patch \ file://telemetry/0007-event-service-fix-added-Context-field-to-response.patch \ - file://telemetry/0008-Generalize-ReadingType-in-MetricDefinition.patch \ file://telemetry/0009-Add-support-for-deleting-terminated-subscriptions.patch \ " +# Temporary downstream patch for routing and privilege changes +SRC_URI += " file://http_routing/0001-Add-asyncResp-support-during-handleUpgrade.patch \ + file://http_routing/0002-Move-privileges-to-separate-entity.patch \ + file://http_routing/0003-Add-Support-for-privilege-check-in-handleUpgrade.patch \ + file://http_routing/0004-Add-Privileges-to-Websockets.patch \ + file://http_routing/0005-Add-Privileges-to-SseSockets.patch \ +" + # Temporary fix: Move it to service file do_install:append() { install -d ${D}/var/lib/bmcweb install -d ${D}/etc/ssl/certs/authority } -# Temporary fix:Enable new power and thermal subsystem -EXTRA_OEMESON += " -Dredfish-new-powersubsystem-thermalsubsystem=enabled" -EXTRA_OEMESON += " -Dredfish-allow-deprecated-power-thermal=disabled" - # Enable PFR support EXTRA_OEMESON += "${@bb.utils.contains('IMAGE_FSTYPES', 'intel-pfr', '-Dredfish-provisioning-feature=enabled', '', d)}" -- cgit v1.2.3