diff options
author | Andrew Geissler <geissonator@yahoo.com> | 2019-07-01 19:00:35 +0300 |
---|---|---|
committer | Andrew Geissler <geissonator@yahoo.com> | 2019-07-03 17:45:06 +0300 |
commit | 6913228d184308c9e848a5cf60ce9b8d2cb44aee (patch) | |
tree | 081b7c4ca6e706c96807217fe73edf71055096ed /redfish-core | |
parent | e0dd805760c55acb6fd161026b4b6d444b641eae (diff) | |
download | bmcweb-6913228d184308c9e848a5cf60ce9b8d2cb44aee.tar.xz |
Return error on invalid swId
Tested:
Before:
curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/UpdateService/FirmwareInventory/invalidSwId
{
"@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory",
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/invalidSwId",
"@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory",
"Name": "Software Inventory",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
},
"Updateable": false
}
After:
curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/UpdateService/FirmwareInventory/invalidSwId
{
"@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory",
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/invalidSwId",
"@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory",
"Name": "Software Inventory",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
},
"Updateable": false,
"error": {
"@Message.ExtendedInfo": [
{
"@odata.type": "/redfish/v1/$metadata#Message.v1_0_0.Message",
"Message": "The resource at the URI /redfish/v1/UpdateService/FirmwareInventory/invalidSwId was not found.",
"MessageArgs": [
"/redfish/v1/UpdateService/FirmwareInventory/invalidSwId"
],
"MessageId": "Base.1.4.0.ResourceMissingAtURI",
"Resolution": "Place a valid resource at the URI or correct the URI and resubmit the request.",
"Severity": "Critical"
}
],
"code": "Base.1.4.0.ResourceMissingAtURI",
"message": "The resource at the URI /redfish/v1/UpdateService/FirmwareInventory/invalidSwId was not found."
}
}
Change-Id: I4dbf535301d55ffff8f2a652d112e08db040d1b1
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'redfish-core')
-rw-r--r-- | redfish-core/lib/update_service.hpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp index 413e39ce4a..7220b43dbe 100644 --- a/redfish-core/lib/update_service.hpp +++ b/redfish-core/lib/update_service.hpp @@ -601,6 +601,8 @@ class SoftwareInventory : public Node return; } + // Ensure we find our input swId, otherwise return an error + bool found = false; for (const std::pair< std::string, std::vector< @@ -617,6 +619,7 @@ class SoftwareInventory : public Node continue; } + found = true; fw_util::getFwStatus(asyncResp, swId, obj.second[0].first); crow::connections::systemBus->async_method_call( @@ -706,6 +709,14 @@ class SoftwareInventory : public Node "org.freedesktop.DBus.Properties", "GetAll", "xyz.openbmc_project.Software.Version"); } + if (!found) + { + BMCWEB_LOG_ERROR << "Input swID " + *swId + " not found!"; + messages::resourceMissingAtURI( + asyncResp->res, + "/redfish/v1/UpdateService/FirmwareInventory/" + *swId); + return; + } }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", |