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>
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index d3d30c2..aaaf85b 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 @@
}
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> ¶ms) override
{
@@ -458,6 +484,7 @@
swInvPurpose->substr(endDesc);
asyncResp->res.jsonValue["Description"] =
formatDesc + " update";
+ getRelatedItems(asyncResp, *swInvPurpose);
},
obj.second[0].first, obj.first,
"org.freedesktop.DBus.Properties", "GetAll",