summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/interfaces/bmcweb/0003-bmcweb-changes-for-setting-ApplyOptions-ClearCfg.patch
blob: 704031fe168100ad888b452bc7930cf9f5084293 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
From e883ea9d43a84998641428448d7220c0f5be72c0 Mon Sep 17 00:00:00 2001
From: Vikram Bodireddy <vikram.bodireddy@intel.com>
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 <vikram.bodireddy@intel.com>
---
 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<bool> applyOption) {
+                if (ec)
+                {
+                    BMCWEB_LOG_DEBUG << "DBUS response error " << ec;
+                    messages::internalError(aResp->res);
+                    return;
+                }
+
+                const bool* b = std::get_if<bool>(&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<nlohmann::json> pushUriOptions;
         std::optional<std::vector<std::string>> imgTargets;
         std::optional<bool> imgTargetBusy;
+        std::optional<nlohmann::json> 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<nlohmann::json> applyOptions;
+
+            if (!json_util::readJson(*oemProps, res, "ApplyOptions",
+                                     applyOptions))
+            {
+                return;
+            }
+
+            if (applyOptions)
+            {
+                std::optional<bool> 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<bool>{*clearConfig});
+                }
+            }
+        }
+
         if (pushUriOptions)
         {
             std::optional<nlohmann::json> 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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
+    <edmx:Reference Uri="http://docs.oasis-open.org/odata/odata/v4.0/errata03/csd01/complete/vocabularies/Org.OData.Core.V1.xml">
+        <edmx:Include Namespace="Org.OData.Core.V1" Alias="OData" />
+    </edmx:Reference>
+    <edmx:Reference Uri="http://redfish.dmtf.org/schemas/v1/RedfishExtensions_v1.xml">
+        <edmx:Include Namespace="Validation.v1_0_0" Alias="Validation"/>
+        <edmx:Include Namespace="RedfishExtensions.v1_0_0" Alias="Redfish"/>
+    </edmx:Reference>
+    <edmx:Reference Uri="http://redfish.dmtf.org/schemas/v1/UpdateService_v1.xml">
+        <edmx:Include Namespace="UpdateService"/>
+        <edmx:Include Namespace="UpdateService.v1_4_0"/>
+    </edmx:Reference>
+    <edmx:Reference Uri="http://redfish.dmtf.org/schemas/v1/Resource_v1.xml">
+        <edmx:Include Namespace="Resource"/>
+        <edmx:Include Namespace="Resource.v1_0_0"/>
+    </edmx:Reference>
+
+    <edmx:DataServices>
+        <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="OemUpdateService">
+            <ComplexType Name="Oem" BaseType="Resource.OemObject">
+                <Annotation Term="OData.AdditionalProperties" Bool="true" />
+                <Annotation Term="OData.Description" String="OemUpdateService Oem properties." />
+                <Annotation Term="OData.AutoExpand"/>
+                <Property Name="ApplyOptions" Type="OemUpdateService.ApplyOptions"/>
+            </ComplexType>
+
+            <ComplexType Name="ApplyOptions" BaseType="Resource.OemObject">
+                <Annotation Term="OData.AdditionalProperties" Bool="false" />
+                <Annotation Term="OData.Description" String="An indication by boolean value whether to update firmware configuration along with firmware image update." />
+                <Property Name="ClearConfig" Type="Edm.Boolean">
+                    <Annotation Term="OData.Permissions" EnumMember="OData.Permission/ReadWrite"/>
+                    <Annotation Term="OData.Description" String="This indicates whether to update firmware configuration or not."/>
+                    <Annotation Term="OData.LongDescription" String="The value of this property is used to indicate the firmware configuration update."/>
+                </Property>
+            </ComplexType>
+
+        </Schema>
+    </edmx:DataServices>
+</edmx:Edmx>
-- 
2.17.1