summaryrefslogtreecommitdiff
path: root/redfish-core/lib/update_service.hpp
diff options
context:
space:
mode:
authorAndrew Geissler <geissonator@yahoo.com>2019-02-28 23:28:39 +0300
committerEd Tanous <ed.tanous@intel.com>2019-04-11 00:41:43 +0300
commit87d847298c57168b1af9bc8bbf201073ef3e76fe (patch)
tree63b1374d803108ff4ae67cc490402f7fc1bd3b3c /redfish-core/lib/update_service.hpp
parentaf5d605812b823fe4a03731dcf6d588bd5f5f181 (diff)
downloadbmcweb-87d847298c57168b1af9bc8bbf201073ef3e76fe.tar.xz
fw-inventory: Add RelatedItem to inventory
Added TODO reference for BIOS reference. This commit is required: https://gerrit.openbmc-project.xyz/#/c/openbmc/bmcweb/+/16775/ Tested: VERBO - SoftwareInventory.v1_1_0.SoftwareInventory:RelatedItem VERBO - value: [OrderedDict([('@odata.id', '/redfish/v1/Managers/bmc')])] <class 'list'> VERBO - has Type: Collection(Resource.Item) entity VERBO - is Optional VERBO - permission OData.Permission/Read VERBO - is Collection VERBO - Success curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/UpdateService/FirmwareInventory/969635f8 { "@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory", "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/969635f8", "@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory", "Description": "BMC update", "Id": "969635f8", "Members@odata.count": 1, "Name": "Software Inventory", "RelatedItem": [ { "@odata.id": "/redfish/v1/Managers/bmc" } ], "Status": { "Health": "OK", "HealthRollup": "OK", "State": "Enabled" }, "Updateable": false, "Version": "2.6.0-rc1-312-g8d6abcd6d" } With the TODO code un-commented, this is the output: curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/UpdateService/FirmwareInventory/ace821ef { "@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory", "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/ace821ef", "@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory", "Description": "Host update", "Id": "ace821ef", "Members@odata.count": 1, "Name": "Software Inventory", "RelatedItem": [ { "@odata.id": "/redfish/v1/Systems/system/BIOS" } ], "Status": { "Health": "OK", "HealthRollup": "OK", "State": "Enabled" }, "Updateable": false, "Version": "IBM-witherspoon-OP9-v2.0.10-2.22" } Change-Id: Iae563a938532c6f53f41c8fc5c758693155be1a0 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'redfish-core/lib/update_service.hpp')
-rw-r--r--redfish-core/lib/update_service.hpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index d3d30c2029..aaaf85baf4 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -18,6 +18,7 @@
#include "node.hpp"
#include <boost/container/flat_map.hpp>
+#include <utils/fw_utils.hpp>
#include <variant>
namespace redfish
@@ -320,6 +321,31 @@ class SoftwareInventory : public Node
}
private:
+ /* Fill related item links (i.e. bmc, bios) in for inventory */
+ static void getRelatedItems(std::shared_ptr<AsyncResp> aResp,
+ const std::string &purpose)
+ {
+ if (purpose == fw_util::bmcPurpose)
+ {
+ nlohmann::json &members = aResp->res.jsonValue["RelatedItem"];
+ members.push_back({{"@odata.id", "/redfish/v1/Managers/bmc"}});
+ aResp->res.jsonValue["Members@odata.count"] = members.size();
+ }
+ else if (purpose == fw_util::biosPurpose)
+ {
+ // TODO(geissonator) Need BIOS schema support added for this
+ // to be valid
+ // nlohmann::json &members = aResp->res.jsonValue["RelatedItem"];
+ // members.push_back(
+ // {{"@odata.id", "/redfish/v1/Systems/system/BIOS"}});
+ // aResp->res.jsonValue["Members@odata.count"] = members.size();
+ }
+ else
+ {
+ BMCWEB_LOG_ERROR << "Unknown software purpose " << purpose;
+ }
+ }
+
void doGet(crow::Response &res, const crow::Request &req,
const std::vector<std::string> &params) override
{
@@ -458,6 +484,7 @@ class SoftwareInventory : public Node
swInvPurpose->substr(endDesc);
asyncResp->res.jsonValue["Description"] =
formatDesc + " update";
+ getRelatedItems(asyncResp, *swInvPurpose);
},
obj.second[0].first, obj.first,
"org.freedesktop.DBus.Properties", "GetAll",