diff options
| author | Andrew Geissler <geissonator@yahoo.com> | 2019-06-18 16:05:10 -0500 |
|---|---|---|
| committer | Ed Tanous <ed.tanous@intel.com> | 2019-07-02 18:00:02 +0000 |
| commit | e0dd805760c55acb6fd161026b4b6d444b641eae (patch) | |
| tree | 91b8a00cb9a2adb23d8e9da3045865cfc8520156 /redfish-core/include/utils | |
| parent | c074230b45ef902f203e8931e6f058d7e030240e (diff) | |
| download | bmcweb-e0dd805760c55acb6fd161026b4b6d444b641eae.tar.gz bmcweb-e0dd805760c55acb6fd161026b4b6d444b641eae.zip | |
fwstatus: Enhance state of firmware inventory
Currently there is no mechanism for a user to know the status of their
firmware update over redfish.
The primary focus of this commit is to provide status of a firmware
update. There is still some ongoing discussion on using the Health field
to better explain error conditions. A forum post with DMTF has been
opened for clarification in this area but this commit does get things
going in the right direction. It provides a user with the status of
their update and gives them a simple Enabled/Disabled to know if it
worked.
Tested:
- Firmware update in progress
curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/UpdateService/FirmwareInventory/92e57fc7
{
"@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory",
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/92e57fc7",
"@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory",
"Description": "BMC update",
"Id": "92e57fc7",
"Members@odata.count": 1,
"Name": "Software Inventory",
"RelatedItem": [
{
"@odata.id": "/redfish/v1/Managers/bmc"
}
],
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Updating"
},
"Updateable": false,
"Version": "2.7.0-dev-926-g79ca37b3d"
}
- Firmware update complete
curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/UpdateService/FirmwareInventory/92e57fc7
{
"@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory",
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/92e57fc7",
"@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory",
"Description": "BMC update",
"Id": "92e57fc7",
"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.7.0-dev-926-g79ca37b3d"
}
- Firmware update failed
(xyz.openbmc_project.Software.Activation.Activations.Failed)
curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/UpdateService/FirmwareInventory/3d02a163
{
"@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory",
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/3d02a163",
"@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory",
"Description": "BMC update",
"Id": "3d02a163",
"Members@odata.count": 1,
"Name": "Software Inventory",
"RelatedItem": [
{
"@odata.id": "/redfish/v1/Managers/bmc"
}
],
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Disabled"
},
"Updateable": false,
"Version": "2.7.0-dev-940-geb79ec582"
}
- Firmware update status of Host
curl -k -H "X-Auth-Token: $TOKEN" -X GET https://${BMC_IP}/redfish/v1/UpdateService/FirmwareInventory/9a8028ec
{
"@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory",
"@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/9a8028ec",
"@odata.type": "#SoftwareInventory.v1_1_0.SoftwareInventory",
"Description": "Host update",
"Id": "9a8028ec",
"Name": "Software Inventory",
"Status": {
"Health": "OK",
"HealthRollup": "OK",
"State": "Enabled"
},
"Updateable": false,
"Version": "IBM-witherspoon-OP9-v2.0.14-2.6"
}
Redfish validator had no additional errors
Change-Id: I26273227448cab1a20a20a7edd9d85d223727bb8
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Diffstat (limited to 'redfish-core/include/utils')
| -rw-r--r-- | redfish-core/include/utils/fw_utils.hpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/redfish-core/include/utils/fw_utils.hpp b/redfish-core/include/utils/fw_utils.hpp index 18773ae..2341e8a 100644 --- a/redfish-core/include/utils/fw_utils.hpp +++ b/redfish-core/include/utils/fw_utils.hpp @@ -186,5 +186,89 @@ void getActiveFwVersion(std::shared_ptr<AsyncResp> aResp, return; } + +/** + * @brief Translate input fwState to Redfish state + * + * This function will return the corresponding Redfish state + * + * @param[i] fwState The OpenBMC firmware state + * + * @return The corresponding Redfish state + */ +std::string getRedfishFWState(const std::string &fwState) +{ + if (fwState == "xyz.openbmc_project.Software.Activation.Activations.Active") + { + return "Enabled"; + } + else if (fwState == + "xyz.openbmc_project.Software.Activation.Activations.Activating") + { + return "Updating"; + } + else + { + BMCWEB_LOG_DEBUG << "Default fw state " << fwState << " to Disabled"; + return "Disabled"; + } +} + +/** + * @brief Put status of input swId into json response + * + * This function will put the appropriate Redfish state of the input + * firmware id to ["Status"]["State"] within the json response + * + * @param[i,o] aResp Async response object + * @param[i] swId The software ID to get status for + * @param[i] dbusSvc The dbus service implementing the software object + * + * @return void + */ +void getFwStatus(std::shared_ptr<AsyncResp> asyncResp, + const std::shared_ptr<std::string> swId, + const std::string &dbusSvc) +{ + BMCWEB_LOG_DEBUG << "getFwStatus: swId " << *swId << " svc " << dbusSvc; + + crow::connections::systemBus->async_method_call( + [asyncResp, + swId](const boost::system::error_code error_code, + const boost::container::flat_map<std::string, VariantType> + &propertiesList) { + if (error_code) + { + messages::internalError(asyncResp->res); + BMCWEB_LOG_ERROR + << "getFwStatus: Error trying to get Activation for " + << *swId; + return; + } + boost::container::flat_map<std::string, VariantType>::const_iterator + it = propertiesList.find("Activation"); + if (it == propertiesList.end()) + { + BMCWEB_LOG_DEBUG << "Can't find property \"Activation\"!"; + messages::propertyMissing(asyncResp->res, "Activation"); + return; + } + const std::string *swInvActivation = + std::get_if<std::string>(&it->second); + if (swInvActivation == nullptr) + { + BMCWEB_LOG_DEBUG << "wrong types for property\"Activation\"!"; + messages::propertyValueTypeError(asyncResp->res, "", + "Activation"); + return; + } + BMCWEB_LOG_DEBUG << "getFwStatus: Activation " << *swInvActivation; + asyncResp->res.jsonValue["Status"]["State"] = + getRedfishFWState(*swInvActivation); + }, + dbusSvc, "/xyz/openbmc_project/software/" + *swId, + "org.freedesktop.DBus.Properties", "GetAll", + "xyz.openbmc_project.Software.Activation"); +} } // namespace fw_util } // namespace redfish |

