summaryrefslogtreecommitdiff
path: root/redfish-core/lib/systems.hpp
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2020-05-17 02:49:33 +0300
committerGunnar Mills <gmills@us.ibm.com>2020-05-20 02:52:43 +0300
commit6bd5a8d2f6acb79a16c4d514ffd1da6b8c5b97d7 (patch)
tree6df8e232dcd8f3766f072e84aa13e7da4d21333e /redfish-core/lib/systems.hpp
parenta778c0261282b95e14ea3f4406959638b5edb040 (diff)
downloadbmcweb-6bd5a8d2f6acb79a16c4d514ffd1da6b8c5b97d7.tar.xz
Redfish: AutomaticRetry (AutoReboot)
A new feature of 2020.1. Three properties to represent this: AutomaticRetryConfig (Enum with three values): Disabled RetryAttempts: "Automatic retrying of booting is based on a specified retry count." RetryAlways AutomaticRetryAttempts: "The number of attempts the system will automatically retry booting." RemainingAutomaticRetryAttempts: "The number of remaining automatic retry boots." Only the "GET". A later commit will allow PATCHing of AutomaticRetryConfig. AutomaticRetryAttempts is not on D-Bus and is instead hardcoded to 3. Tested: Validator passed. "Boot": { "AutomaticRetryAttempts": 3, "AutomaticRetryConfig": "RetryAttempts", ... "RemainingAutomaticRetryAttempts": 3 }, Change-Id: I7a098270411eef2112c47d129aae39cd2b419825 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'redfish-core/lib/systems.hpp')
-rw-r--r--redfish-core/lib/systems.hpp87
1 files changed, 86 insertions, 1 deletions
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index c17e13537d..628c51a819 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -917,6 +917,90 @@ static void getBootProperties(std::shared_ptr<AsyncResp> aResp)
}
/**
+ * @brief Retrieves Automatic Retry properties. Known on D-Bus as AutoReboot.
+ *
+ * @param[in] aResp Shared pointer for generating response message.
+ *
+ * @return None.
+ */
+void getAutomaticRetry(std::shared_ptr<AsyncResp> aResp)
+{
+ BMCWEB_LOG_DEBUG << "Get Automatic Retry policy";
+
+ crow::connections::systemBus->async_method_call(
+ [aResp](const boost::system::error_code ec,
+ std::variant<bool> &autoRebootEnabled) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << "D-BUS response error " << ec;
+ return;
+ }
+
+ const bool *autoRebootEnabledPtr =
+ std::get_if<bool>(&autoRebootEnabled);
+
+ if (!autoRebootEnabledPtr)
+ {
+ messages::internalError(aResp->res);
+ return;
+ }
+
+ BMCWEB_LOG_DEBUG << "Auto Reboot: " << *autoRebootEnabledPtr;
+ if (*autoRebootEnabledPtr == true)
+ {
+ aResp->res.jsonValue["Boot"]["AutomaticRetryConfig"] =
+ "RetryAttempts";
+ // If AutomaticRetry (AutoReboot) is enabled see how many
+ // attempts are left
+ crow::connections::systemBus->async_method_call(
+ [aResp](const boost::system::error_code ec,
+ std::variant<uint32_t> &autoRebootAttemptsLeft) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << "D-BUS response error " << ec;
+ return;
+ }
+
+ const uint32_t *autoRebootAttemptsLeftPtr =
+ std::get_if<uint32_t>(&autoRebootAttemptsLeft);
+
+ if (!autoRebootAttemptsLeftPtr)
+ {
+ messages::internalError(aResp->res);
+ return;
+ }
+
+ BMCWEB_LOG_DEBUG << "Auto Reboot Attempts Left: "
+ << *autoRebootAttemptsLeftPtr;
+
+ aResp->res
+ .jsonValue["Boot"]
+ ["RemainingAutomaticRetryAttempts"] =
+ *autoRebootAttemptsLeftPtr;
+ },
+ "xyz.openbmc_project.State.Host",
+ "/xyz/openbmc_project/state/host0",
+ "org.freedesktop.DBus.Properties", "Get",
+ "xyz.openbmc_project.Control.Boot.RebootAttempts",
+ "AttemptsLeft");
+ }
+ else
+ {
+ aResp->res.jsonValue["Boot"]["AutomaticRetryConfig"] =
+ "Disabled";
+ }
+
+ // Not on D-Bus. Hardcoded here:
+ // https://github.com/openbmc/phosphor-state-manager/blob/1dbbef42675e94fb1f78edb87d6b11380260535a/meson_options.txt#L71
+ aResp->res.jsonValue["Boot"]["AutomaticRetryAttempts"] = 3;
+ },
+ "xyz.openbmc_project.Settings",
+ "/xyz/openbmc_project/control/host0/auto_reboot",
+ "org.freedesktop.DBus.Properties", "Get",
+ "xyz.openbmc_project.Control.Boot.RebootPolicy", "AutoReboot");
+}
+
+/**
* @brief Retrieves power restore policy over DBUS.
*
* @param[in] aResp Shared pointer for generating response message.
@@ -1693,7 +1777,7 @@ class Systems : public Node
void doGet(crow::Response &res, const crow::Request &req,
const std::vector<std::string> &params) override
{
- res.jsonValue["@odata.type"] = "#ComputerSystem.v1_6_0.ComputerSystem";
+ res.jsonValue["@odata.type"] = "#ComputerSystem.v1_11_0.ComputerSystem";
res.jsonValue["Name"] = "system";
res.jsonValue["Id"] = "system";
res.jsonValue["SystemType"] = "Physical";
@@ -1772,6 +1856,7 @@ class Systems : public Node
getPCIeDeviceList(asyncResp, "PCIeDevices");
getHostWatchdogTimer(asyncResp);
getPowerRestorePolicy(asyncResp);
+ getAutomaticRetry(asyncResp);
#ifdef BMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE
getProvisioningStatus(asyncResp);
#endif