From e883ea9d43a84998641428448d7220c0f5be72c0 Mon Sep 17 00:00:00 2001 From: Vikram Bodireddy Date: Tue, 30 Jun 2020 22:09:10 +0530 Subject: [PATCH] bmcweb changes for setting ApplyOptions-ClearCfg ApplyOptions are used to specify firmware update specific options such as ClearConfig which is used while activating the updated firmware. This setting is maintained in a local static variable when set using PATCH method. Its used in activate image as input parameter. This attribute is added as Oem as the default UpdateService interface doesn't specify any relevant or appropriate attribute for this. Tested: Tested setting ClearConfig to true or false using PATCH method. Ran Redfish-Service-Validator and no new issues found. Signed-off-by: Vikram Bodireddy --- redfish-core/lib/update_service.hpp | 69 ++++++++++++++++++- .../JsonSchemas/OemUpdateService/index.json | 69 +++++++++++++++++++ .../redfish/v1/schema/OemUpdateService_v1.xml | 40 +++++++++++ 3 files changed, 177 insertions(+), 1 deletion(-) 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 86ddd8a..291acec 100644 --- a/redfish-core/lib/update_service.hpp +++ b/redfish-core/lib/update_service.hpp @@ -691,6 +691,29 @@ class UpdateService : public Node "/xyz/openbmc_project/software/apply_time", "org.freedesktop.DBus.Properties", "Get", "xyz.openbmc_project.Software.ApplyTime", "RequestedApplyTime"); + + // Get the ApplyOptions value + crow::connections::systemBus->async_method_call( + [aResp](const boost::system::error_code ec, + const std::variant applyOption) { + if (ec) + { + BMCWEB_LOG_DEBUG << "DBUS response error " << ec; + messages::internalError(aResp->res); + return; + } + + const bool* b = std::get_if(&applyOption); + + if (b) + { + aResp->res.jsonValue["Oem"]["ApplyOptions"]["ClearConfig"] = + *b; + } + }, + "xyz.openbmc_project.Software.BMC.Updater", + "/xyz/openbmc_project/software", "org.freedesktop.DBus.Properties", + "Get", "xyz.openbmc_project.Software.ApplyOptions", "ClearConfig"); } void doPatch(crow::Response& res, const crow::Request& req, @@ -703,15 +726,59 @@ class UpdateService : public Node std::optional pushUriOptions; std::optional> imgTargets; std::optional imgTargetBusy; + std::optional oemProps; if (!json_util::readJson(req, res, "HttpPushUriOptions", pushUriOptions, "HttpPushUriTargets", imgTargets, - "HttpPushUriTargetsBusy", imgTargetBusy)) + "HttpPushUriTargetsBusy", imgTargetBusy, "Oem", + oemProps)) { BMCWEB_LOG_DEBUG << "UpdateService doPatch: Invalid request body"; return; } + if (oemProps) + { + std::optional applyOptions; + + if (!json_util::readJson(*oemProps, res, "ApplyOptions", + applyOptions)) + { + return; + } + + if (applyOptions) + { + std::optional clearConfig; + if (!json_util::readJson(*applyOptions, res, "ClearConfig", + clearConfig)) + { + return; + } + + if (clearConfig) + { + // Set the requested image apply time value + crow::connections::systemBus->async_method_call( + [asyncResp](const boost::system::error_code ec) { + if (ec) + { + BMCWEB_LOG_ERROR << "D-Bus responses error: " + << ec; + messages::internalError(asyncResp->res); + return; + } + messages::success(asyncResp->res); + }, + "xyz.openbmc_project.Software.BMC.Updater", + "/xyz/openbmc_project/software", + "org.freedesktop.DBus.Properties", "Set", + "xyz.openbmc_project.Software.ApplyOptions", + "ClearConfig", std::variant{*clearConfig}); + } + } + } + if (pushUriOptions) { std::optional pushUriApplyTime; diff --git a/static/redfish/v1/JsonSchemas/OemUpdateService/index.json b/static/redfish/v1/JsonSchemas/OemUpdateService/index.json new file mode 100644 index 0000000..74e39cd --- /dev/null +++ b/static/redfish/v1/JsonSchemas/OemUpdateService/index.json @@ -0,0 +1,69 @@ +{ + "$id": "http://redfish.dmtf.org/schemas/v1/OemUpdateService.json", + "$schema": "http://redfish.dmtf.org/schemas/v1/redfish-schema-v1.json", + "copyright": "Copyright 2014-2019 DMTF. For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright", + "definitions": { + "ApplyOptions": { + "additionalProperties": false, + "description": "An indication by boolean value whether to update firmware configuration along with firmware image update.", + "patternProperties": { + "^([a-zA-Z_][a-zA-Z0-9_]*)?@(odata|Redfish|Message)\\.[a-zA-Z_][a-zA-Z0-9_]*$": { + "description": "This property shall specify a valid odata or Redfish property.", + "type": [ + "array", + "boolean", + "integer", + "number", + "null", + "object", + "string" + ] + } + }, + "properties": { + "ClearConfig": { + "description": "This indicates whether to update firmware configuration or not.", + "longDescription": "The value of this property is used to indicate the firmware configuration update.", + "readonly": false, + "type": [ + "boolean", + "null" + ] + } + }, + "type": "object" + }, + "Oem": { + "additionalProperties": true, + "description": "OemUpdateService Oem properties.", + "patternProperties": { + "^([a-zA-Z_][a-zA-Z0-9_]*)?@(odata|Redfish|Message)\\.[a-zA-Z_][a-zA-Z0-9_]*$": { + "description": "This property shall specify a valid odata or Redfish property.", + "type": [ + "array", + "boolean", + "integer", + "number", + "null", + "object", + "string" + ] + } + }, + "properties": { + "ApplyOptions": { + "anyOf": [ + { + "$ref": "#/definitions/ApplyOptions" + }, + { + "type": "null" + } + ] + } + }, + "type": "object" + } + }, + "title": "#OemUpdateService" +} diff --git a/static/redfish/v1/schema/OemUpdateService_v1.xml b/static/redfish/v1/schema/OemUpdateService_v1.xml new file mode 100644 index 0000000..cbb7aa4 --- /dev/null +++ b/static/redfish/v1/schema/OemUpdateService_v1.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.17.1