diff options
author | Andrew Geissler <geissonator@yahoo.com> | 2022-01-06 22:59:39 +0300 |
---|---|---|
committer | Andrew Geissler <geissonator@yahoo.com> | 2022-01-07 18:06:07 +0300 |
commit | e43914b3572faac8ea20d684a9c8eb04e8496a57 (patch) | |
tree | cad20f90792fe09fd0c3dfb519dcc2c38c2bb167 | |
parent | 9ec65efb0614ebc29aa9a666d6fc478b822349f8 (diff) | |
download | bmcweb-e43914b3572faac8ea20d684a9c8eb04e8496a57.tar.xz |
boot-progress: move dbus-to-redfish logic to function
This logic has grown enough to deserve its own function.
Tested:
- Validated BootProgress returned as expected via Redfish API
- Redfish validator passed
Change-Id: I798841a79b40b0fb60fdd21b95430958e20c2a03
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
-rw-r--r-- | redfish-core/lib/systems.hpp | 153 |
1 files changed, 83 insertions, 70 deletions
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp index abe8b02e4b..f15c1941f8 100644 --- a/redfish-core/lib/systems.hpp +++ b/redfish-core/lib/systems.hpp @@ -682,6 +682,87 @@ inline std::string dbusToRfBootMode(const std::string& dbusMode) } /** + * @brief Translates boot progress DBUS property value to redfish. + * + * @param[in] dbusBootProgress The boot progress in DBUS speak. + * + * @return Returns as a string, the boot progress in Redfish terms. If + * translation cannot be done, returns "None". + */ +inline std::string dbusToRfBootProgress(const std::string& dbusBootProgress) +{ + // Now convert the D-Bus BootProgress to the appropriate Redfish + // enum + std::string rfBpLastState = "None"; + if (dbusBootProgress == "xyz.openbmc_project.State.Boot.Progress." + "ProgressStages.Unspecified") + { + rfBpLastState = "None"; + } + else if (dbusBootProgress == + "xyz.openbmc_project.State.Boot.Progress.ProgressStages." + "PrimaryProcInit") + { + rfBpLastState = "PrimaryProcessorInitializationStarted"; + } + else if (dbusBootProgress == + "xyz.openbmc_project.State.Boot.Progress.ProgressStages." + "BusInit") + { + rfBpLastState = "BusInitializationStarted"; + } + else if (dbusBootProgress == + "xyz.openbmc_project.State.Boot.Progress.ProgressStages." + "MemoryInit") + { + rfBpLastState = "MemoryInitializationStarted"; + } + else if (dbusBootProgress == + "xyz.openbmc_project.State.Boot.Progress.ProgressStages." + "SecondaryProcInit") + { + rfBpLastState = "SecondaryProcessorInitializationStarted"; + } + else if (dbusBootProgress == + "xyz.openbmc_project.State.Boot.Progress.ProgressStages." + "PCIInit") + { + rfBpLastState = "PCIResourceConfigStarted"; + } + else if (dbusBootProgress == + "xyz.openbmc_project.State.Boot.Progress.ProgressStages." + "SystemSetup") + { + rfBpLastState = "SetupEntered"; + } + else if (dbusBootProgress == + "xyz.openbmc_project.State.Boot.Progress.ProgressStages." + "SystemInitComplete") + { + rfBpLastState = "SystemHardwareInitializationComplete"; + } + else if (dbusBootProgress == + "xyz.openbmc_project.State.Boot.Progress.ProgressStages." + "OSStart") + { + rfBpLastState = "OSBootStarted"; + } + else if (dbusBootProgress == + "xyz.openbmc_project.State.Boot.Progress.ProgressStages." + "OSRunning") + { + rfBpLastState = "OSRunning"; + } + else + { + BMCWEB_LOG_DEBUG << "Unsupported D-Bus BootProgress " + << dbusBootProgress; + // Just return the default + } + return rfBpLastState; +} + +/** * @brief Translates boot source from Redfish to the DBus boot paths. * * @param[in] rfSource The boot source in Redfish. @@ -763,76 +844,8 @@ inline void getBootProgress(const std::shared_ptr<bmcweb::AsyncResp>& aResp) BMCWEB_LOG_DEBUG << "Boot Progress: " << bootProgressStr; - // Now convert the D-Bus BootProgress to the appropriate Redfish - // enum - std::string rfBpLastState = "None"; - if (bootProgressStr == - "xyz.openbmc_project.State.Boot.Progress.ProgressStages.Unspecified") - { - rfBpLastState = "None"; - } - else if ( - bootProgressStr == - "xyz.openbmc_project.State.Boot.Progress.ProgressStages.PrimaryProcInit") - { - rfBpLastState = "PrimaryProcessorInitializationStarted"; - } - else if ( - bootProgressStr == - "xyz.openbmc_project.State.Boot.Progress.ProgressStages.BusInit") - { - rfBpLastState = "BusInitializationStarted"; - } - else if ( - bootProgressStr == - "xyz.openbmc_project.State.Boot.Progress.ProgressStages.MemoryInit") - { - rfBpLastState = "MemoryInitializationStarted"; - } - else if ( - bootProgressStr == - "xyz.openbmc_project.State.Boot.Progress.ProgressStages.SecondaryProcInit") - { - rfBpLastState = "SecondaryProcessorInitializationStarted"; - } - else if ( - bootProgressStr == - "xyz.openbmc_project.State.Boot.Progress.ProgressStages.PCIInit") - { - rfBpLastState = "PCIResourceConfigStarted"; - } - else if ( - bootProgressStr == - "xyz.openbmc_project.State.Boot.Progress.ProgressStages.SystemSetup") - { - rfBpLastState = "SetupEntered"; - } - else if ( - bootProgressStr == - "xyz.openbmc_project.State.Boot.Progress.ProgressStages.SystemInitComplete") - { - rfBpLastState = "SystemHardwareInitializationComplete"; - } - else if ( - bootProgressStr == - "xyz.openbmc_project.State.Boot.Progress.ProgressStages.OSStart") - { - rfBpLastState = "OSBootStarted"; - } - else if ( - bootProgressStr == - "xyz.openbmc_project.State.Boot.Progress.ProgressStages.OSRunning") - { - rfBpLastState = "OSRunning"; - } - else - { - BMCWEB_LOG_DEBUG << "Unsupported D-Bus BootProgress " - << bootProgressStr; - // Just return the default - } - - aResp->res.jsonValue["BootProgress"]["LastState"] = rfBpLastState; + aResp->res.jsonValue["BootProgress"]["LastState"] = + dbusToRfBootProgress(bootProgressStr); }); } |