Try to fix the lambda formatting issue
clang-tidy has a setting, LambdaBodyIndentation, which it says:
"For callback-heavy code, it may improve readability to have the
signature indented two levels and to use OuterScope."
bmcweb is very callback heavy code. Try to enable it and see if that
improves things. There are many cases where the length of a lambda call
will change, and reindent the entire lambda function. This is really
bad for code reviews, as it's difficult to see the lines changed. This
commit should resolve it. This does have the downside of reindenting a
lot of functions, which is unfortunate, but probably worth it in the
long run.
All changes except for the .clang-format file were made by the robot.
Tested: Code compiles, whitespace changes only.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ib4aa2f1391fada981febd25b67dcdb9143827f43
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index cd9910e..87fcae9 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -55,15 +55,15 @@
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec) {
- // Use "Set" method to set the property value.
- if (ec)
- {
- BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec;
- messages::internalError(asyncResp->res);
- return;
- }
+ // Use "Set" method to set the property value.
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec;
+ messages::internalError(asyncResp->res);
+ return;
+ }
- messages::success(asyncResp->res);
+ messages::success(asyncResp->res);
},
processName, objectPath, "org.freedesktop.DBus.Properties", "Set",
interfaceName, destProperty, dbusPropertyValue);
@@ -84,15 +84,15 @@
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec) {
- // Use "Set" method to set the property value.
- if (ec)
- {
- BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec;
- messages::internalError(asyncResp->res);
- return;
- }
+ // Use "Set" method to set the property value.
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << "[Set] Bad D-Bus request error: " << ec;
+ messages::internalError(asyncResp->res);
+ return;
+ }
- messages::success(asyncResp->res);
+ messages::success(asyncResp->res);
},
processName, objectPath, "org.freedesktop.DBus.Properties", "Set",
interfaceName, destProperty, dbusPropertyValue);
@@ -115,39 +115,39 @@
.methods(boost::beast::http::verb::post)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
- {
- return;
- }
- BMCWEB_LOG_DEBUG << "Post Manager Reset.";
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+ BMCWEB_LOG_DEBUG << "Post Manager Reset.";
- std::string resetType;
+ std::string resetType;
- if (!json_util::readJsonAction(req, asyncResp->res, "ResetType",
- resetType))
- {
- return;
- }
+ if (!json_util::readJsonAction(req, asyncResp->res, "ResetType",
+ resetType))
+ {
+ return;
+ }
- if (resetType == "GracefulRestart")
- {
- BMCWEB_LOG_DEBUG << "Proceeding with " << resetType;
- doBMCGracefulRestart(asyncResp);
- return;
- }
- if (resetType == "ForceRestart")
- {
- BMCWEB_LOG_DEBUG << "Proceeding with " << resetType;
- doBMCForceRestart(asyncResp);
- return;
- }
- BMCWEB_LOG_DEBUG << "Invalid property value for ResetType: "
- << resetType;
- messages::actionParameterNotSupported(asyncResp->res, resetType,
- "ResetType");
+ if (resetType == "GracefulRestart")
+ {
+ BMCWEB_LOG_DEBUG << "Proceeding with " << resetType;
+ doBMCGracefulRestart(asyncResp);
+ return;
+ }
+ if (resetType == "ForceRestart")
+ {
+ BMCWEB_LOG_DEBUG << "Proceeding with " << resetType;
+ doBMCForceRestart(asyncResp);
+ return;
+ }
+ BMCWEB_LOG_DEBUG << "Invalid property value for ResetType: "
+ << resetType;
+ messages::actionParameterNotSupported(asyncResp->res, resetType,
+ "ResetType");
- return;
- });
+ return;
+ });
}
/**
@@ -175,52 +175,50 @@
.methods(boost::beast::http::verb::post)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
- {
- return;
- }
- BMCWEB_LOG_DEBUG << "Post ResetToDefaults.";
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+ BMCWEB_LOG_DEBUG << "Post ResetToDefaults.";
- std::string resetType;
+ std::string resetType;
- if (!json_util::readJsonAction(
- req, asyncResp->res, "ResetToDefaultsType", resetType))
- {
- BMCWEB_LOG_DEBUG << "Missing property ResetToDefaultsType.";
+ if (!json_util::readJsonAction(req, asyncResp->res,
+ "ResetToDefaultsType", resetType))
+ {
+ BMCWEB_LOG_DEBUG << "Missing property ResetToDefaultsType.";
- messages::actionParameterMissing(asyncResp->res,
- "ResetToDefaults",
- "ResetToDefaultsType");
- return;
- }
+ messages::actionParameterMissing(asyncResp->res, "ResetToDefaults",
+ "ResetToDefaultsType");
+ return;
+ }
- if (resetType != "ResetAll")
- {
- BMCWEB_LOG_DEBUG
- << "Invalid property value for ResetToDefaultsType: "
- << resetType;
- messages::actionParameterNotSupported(
- asyncResp->res, resetType, "ResetToDefaultsType");
- return;
- }
+ if (resetType != "ResetAll")
+ {
+ BMCWEB_LOG_DEBUG
+ << "Invalid property value for ResetToDefaultsType: "
+ << resetType;
+ messages::actionParameterNotSupported(asyncResp->res, resetType,
+ "ResetToDefaultsType");
+ return;
+ }
- crow::connections::systemBus->async_method_call(
- [asyncResp](const boost::system::error_code ec) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG << "Failed to ResetToDefaults: "
- << ec;
- messages::internalError(asyncResp->res);
- return;
- }
- // Factory Reset doesn't actually happen until a reboot
- // Can't erase what the BMC is running on
- doBMCGracefulRestart(asyncResp);
- },
- "xyz.openbmc_project.Software.BMC.Updater",
- "/xyz/openbmc_project/software",
- "xyz.openbmc_project.Common.FactoryReset", "Reset");
- });
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code ec) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << "Failed to ResetToDefaults: " << ec;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ // Factory Reset doesn't actually happen until a reboot
+ // Can't erase what the BMC is running on
+ doBMCGracefulRestart(asyncResp);
+ },
+ "xyz.openbmc_project.Software.BMC.Updater",
+ "/xyz/openbmc_project/software",
+ "xyz.openbmc_project.Common.FactoryReset", "Reset");
+ });
}
/**
@@ -238,32 +236,32 @@
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
- {
- return;
- }
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
- asyncResp->res.jsonValue["@odata.type"] =
- "#ActionInfo.v1_1_2.ActionInfo";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Managers/bmc/ResetActionInfo";
- asyncResp->res.jsonValue["Name"] = "Reset Action Info";
- asyncResp->res.jsonValue["Id"] = "ResetActionInfo";
- nlohmann::json::object_t parameter;
- parameter["Name"] = "ResetType";
- parameter["Required"] = true;
- parameter["DataType"] = "String";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ActionInfo.v1_1_2.ActionInfo";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Managers/bmc/ResetActionInfo";
+ asyncResp->res.jsonValue["Name"] = "Reset Action Info";
+ asyncResp->res.jsonValue["Id"] = "ResetActionInfo";
+ nlohmann::json::object_t parameter;
+ parameter["Name"] = "ResetType";
+ parameter["Required"] = true;
+ parameter["DataType"] = "String";
- nlohmann::json::array_t allowableValues;
- allowableValues.push_back("GracefulRestart");
- allowableValues.push_back("ForceRestart");
- parameter["AllowableValues"] = std::move(allowableValues);
+ nlohmann::json::array_t allowableValues;
+ allowableValues.push_back("GracefulRestart");
+ allowableValues.push_back("ForceRestart");
+ parameter["AllowableValues"] = std::move(allowableValues);
- nlohmann::json::array_t parameters;
- parameters.push_back(std::move(parameter));
+ nlohmann::json::array_t parameters;
+ parameters.push_back(std::move(parameter));
- asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
- });
+ asyncResp->res.jsonValue["Parameters"] = std::move(parameters);
+ });
}
static constexpr const char* objectManagerIface =
@@ -288,203 +286,256 @@
[asyncResp, currentProfile, supportedProfiles](
const boost::system::error_code ec,
const dbus::utility::ManagedObjectType& managedObj) {
- if (ec)
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << ec;
+ asyncResp->res.jsonValue.clear();
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ nlohmann::json& configRoot =
+ asyncResp->res.jsonValue["Oem"]["OpenBmc"]["Fan"];
+ nlohmann::json& fans = configRoot["FanControllers"];
+ fans["@odata.type"] = "#OemManager.FanControllers";
+ fans["@odata.id"] =
+ "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanControllers";
+
+ nlohmann::json& pids = configRoot["PidControllers"];
+ pids["@odata.type"] = "#OemManager.PidControllers";
+ pids["@odata.id"] =
+ "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/PidControllers";
+
+ nlohmann::json& stepwise = configRoot["StepwiseControllers"];
+ stepwise["@odata.type"] = "#OemManager.StepwiseControllers";
+ stepwise["@odata.id"] =
+ "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/StepwiseControllers";
+
+ nlohmann::json& zones = configRoot["FanZones"];
+ zones["@odata.id"] =
+ "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones";
+ zones["@odata.type"] = "#OemManager.FanZones";
+ configRoot["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan";
+ configRoot["@odata.type"] = "#OemManager.Fan";
+ configRoot["Profile@Redfish.AllowableValues"] = supportedProfiles;
+
+ if (!currentProfile.empty())
+ {
+ configRoot["Profile"] = currentProfile;
+ }
+ BMCWEB_LOG_ERROR << "profile = " << currentProfile << " !";
+
+ for (const auto& pathPair : managedObj)
+ {
+ for (const auto& intfPair : pathPair.second)
{
- BMCWEB_LOG_ERROR << ec;
- asyncResp->res.jsonValue.clear();
- messages::internalError(asyncResp->res);
- return;
- }
- nlohmann::json& configRoot =
- asyncResp->res.jsonValue["Oem"]["OpenBmc"]["Fan"];
- nlohmann::json& fans = configRoot["FanControllers"];
- fans["@odata.type"] = "#OemManager.FanControllers";
- fans["@odata.id"] =
- "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanControllers";
-
- nlohmann::json& pids = configRoot["PidControllers"];
- pids["@odata.type"] = "#OemManager.PidControllers";
- pids["@odata.id"] =
- "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/PidControllers";
-
- nlohmann::json& stepwise = configRoot["StepwiseControllers"];
- stepwise["@odata.type"] = "#OemManager.StepwiseControllers";
- stepwise["@odata.id"] =
- "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/StepwiseControllers";
-
- nlohmann::json& zones = configRoot["FanZones"];
- zones["@odata.id"] =
- "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones";
- zones["@odata.type"] = "#OemManager.FanZones";
- configRoot["@odata.id"] =
- "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan";
- configRoot["@odata.type"] = "#OemManager.Fan";
- configRoot["Profile@Redfish.AllowableValues"] = supportedProfiles;
-
- if (!currentProfile.empty())
- {
- configRoot["Profile"] = currentProfile;
- }
- BMCWEB_LOG_ERROR << "profile = " << currentProfile << " !";
-
- for (const auto& pathPair : managedObj)
- {
- for (const auto& intfPair : pathPair.second)
+ if (intfPair.first != pidConfigurationIface &&
+ intfPair.first != pidZoneConfigurationIface &&
+ intfPair.first != stepwiseConfigurationIface)
{
- if (intfPair.first != pidConfigurationIface &&
- intfPair.first != pidZoneConfigurationIface &&
- intfPair.first != stepwiseConfigurationIface)
- {
- continue;
- }
+ continue;
+ }
- std::string name;
+ std::string name;
- for (const std::pair<std::string,
- dbus::utility::DbusVariantType>&
- propPair : intfPair.second)
+ for (const std::pair<std::string,
+ dbus::utility::DbusVariantType>& propPair :
+ intfPair.second)
+ {
+ if (propPair.first == "Name")
{
- if (propPair.first == "Name")
+ const std::string* namePtr =
+ std::get_if<std::string>(&propPair.second);
+ if (namePtr == nullptr)
{
- const std::string* namePtr =
- std::get_if<std::string>(&propPair.second);
- if (namePtr == nullptr)
- {
- BMCWEB_LOG_ERROR << "Pid Name Field illegal";
- messages::internalError(asyncResp->res);
- return;
- }
- name = *namePtr;
- dbus::utility::escapePathForDbus(name);
- }
- else if (propPair.first == "Profiles")
- {
- const std::vector<std::string>* profiles =
- std::get_if<std::vector<std::string>>(
- &propPair.second);
- if (profiles == nullptr)
- {
- BMCWEB_LOG_ERROR
- << "Pid Profiles Field illegal";
- messages::internalError(asyncResp->res);
- return;
- }
- if (std::find(profiles->begin(), profiles->end(),
- currentProfile) == profiles->end())
- {
- BMCWEB_LOG_INFO
- << name
- << " not supported in current profile";
- continue;
- }
- }
- }
- nlohmann::json* config = nullptr;
- const std::string* classPtr = nullptr;
-
- for (const std::pair<std::string,
- dbus::utility::DbusVariantType>&
- propPair : intfPair.second)
- {
- if (propPair.first == "Class")
- {
- classPtr =
- std::get_if<std::string>(&propPair.second);
- }
- }
-
- if (intfPair.first == pidZoneConfigurationIface)
- {
- std::string chassis;
- if (!dbus::utility::getNthStringFromPath(
- pathPair.first.str, 5, chassis))
- {
- chassis = "#IllegalValue";
- }
- nlohmann::json& zone = zones[name];
- zone["Chassis"] = {
- {"@odata.id", "/redfish/v1/Chassis/" + chassis}};
- zone["@odata.id"] =
- "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/" +
- name;
- zone["@odata.type"] = "#OemManager.FanZone";
- config = &zone;
- }
-
- else if (intfPair.first == stepwiseConfigurationIface)
- {
- if (classPtr == nullptr)
- {
- BMCWEB_LOG_ERROR << "Pid Class Field illegal";
+ BMCWEB_LOG_ERROR << "Pid Name Field illegal";
messages::internalError(asyncResp->res);
return;
}
-
- nlohmann::json& controller = stepwise[name];
- config = &controller;
-
- controller["@odata.id"] =
- "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/StepwiseControllers/" +
- name;
- controller["@odata.type"] =
- "#OemManager.StepwiseController";
-
- controller["Direction"] = *classPtr;
+ name = *namePtr;
+ dbus::utility::escapePathForDbus(name);
}
-
- // pid and fans are off the same configuration
- else if (intfPair.first == pidConfigurationIface)
+ else if (propPair.first == "Profiles")
{
-
- if (classPtr == nullptr)
+ const std::vector<std::string>* profiles =
+ std::get_if<std::vector<std::string>>(
+ &propPair.second);
+ if (profiles == nullptr)
{
- BMCWEB_LOG_ERROR << "Pid Class Field illegal";
+ BMCWEB_LOG_ERROR << "Pid Profiles Field illegal";
messages::internalError(asyncResp->res);
return;
}
- bool isFan = *classPtr == "fan";
- nlohmann::json& element =
- isFan ? fans[name] : pids[name];
- config = &element;
- if (isFan)
+ if (std::find(profiles->begin(), profiles->end(),
+ currentProfile) == profiles->end())
{
- element["@odata.id"] =
- "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanControllers/" +
- name;
- element["@odata.type"] =
- "#OemManager.FanController";
- }
- else
- {
- element["@odata.id"] =
- "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/PidControllers/" +
- name;
- element["@odata.type"] =
- "#OemManager.PidController";
+ BMCWEB_LOG_INFO
+ << name << " not supported in current profile";
+ continue;
}
}
- else
+ }
+ nlohmann::json* config = nullptr;
+ const std::string* classPtr = nullptr;
+
+ for (const std::pair<std::string,
+ dbus::utility::DbusVariantType>& propPair :
+ intfPair.second)
+ {
+ if (propPair.first == "Class")
{
- BMCWEB_LOG_ERROR << "Unexpected configuration";
+ classPtr = std::get_if<std::string>(&propPair.second);
+ }
+ }
+
+ if (intfPair.first == pidZoneConfigurationIface)
+ {
+ std::string chassis;
+ if (!dbus::utility::getNthStringFromPath(pathPair.first.str,
+ 5, chassis))
+ {
+ chassis = "#IllegalValue";
+ }
+ nlohmann::json& zone = zones[name];
+ zone["Chassis"] = {
+ {"@odata.id", "/redfish/v1/Chassis/" + chassis}};
+ zone["@odata.id"] =
+ "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/" +
+ name;
+ zone["@odata.type"] = "#OemManager.FanZone";
+ config = &zone;
+ }
+
+ else if (intfPair.first == stepwiseConfigurationIface)
+ {
+ if (classPtr == nullptr)
+ {
+ BMCWEB_LOG_ERROR << "Pid Class Field illegal";
messages::internalError(asyncResp->res);
return;
}
- // used for making maps out of 2 vectors
- const std::vector<double>* keys = nullptr;
- const std::vector<double>* values = nullptr;
+ nlohmann::json& controller = stepwise[name];
+ config = &controller;
- for (const auto& propertyPair : intfPair.second)
+ controller["@odata.id"] =
+ "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/StepwiseControllers/" +
+ name;
+ controller["@odata.type"] =
+ "#OemManager.StepwiseController";
+
+ controller["Direction"] = *classPtr;
+ }
+
+ // pid and fans are off the same configuration
+ else if (intfPair.first == pidConfigurationIface)
+ {
+
+ if (classPtr == nullptr)
{
- if (propertyPair.first == "Type" ||
- propertyPair.first == "Class" ||
- propertyPair.first == "Name")
- {
- continue;
- }
+ BMCWEB_LOG_ERROR << "Pid Class Field illegal";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ bool isFan = *classPtr == "fan";
+ nlohmann::json& element = isFan ? fans[name] : pids[name];
+ config = &element;
+ if (isFan)
+ {
+ element["@odata.id"] =
+ "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanControllers/" +
+ name;
+ element["@odata.type"] = "#OemManager.FanController";
+ }
+ else
+ {
+ element["@odata.id"] =
+ "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/PidControllers/" +
+ name;
+ element["@odata.type"] = "#OemManager.PidController";
+ }
+ }
+ else
+ {
+ BMCWEB_LOG_ERROR << "Unexpected configuration";
+ messages::internalError(asyncResp->res);
+ return;
+ }
- // zones
- if (intfPair.first == pidZoneConfigurationIface)
+ // used for making maps out of 2 vectors
+ const std::vector<double>* keys = nullptr;
+ const std::vector<double>* values = nullptr;
+
+ for (const auto& propertyPair : intfPair.second)
+ {
+ if (propertyPair.first == "Type" ||
+ propertyPair.first == "Class" ||
+ propertyPair.first == "Name")
+ {
+ continue;
+ }
+
+ // zones
+ if (intfPair.first == pidZoneConfigurationIface)
+ {
+ const double* ptr =
+ std::get_if<double>(&propertyPair.second);
+ if (ptr == nullptr)
+ {
+ BMCWEB_LOG_ERROR << "Field Illegal "
+ << propertyPair.first;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ (*config)[propertyPair.first] = *ptr;
+ }
+
+ if (intfPair.first == stepwiseConfigurationIface)
+ {
+ if (propertyPair.first == "Reading" ||
+ propertyPair.first == "Output")
+ {
+ const std::vector<double>* ptr =
+ std::get_if<std::vector<double>>(
+ &propertyPair.second);
+
+ if (ptr == nullptr)
+ {
+ BMCWEB_LOG_ERROR << "Field Illegal "
+ << propertyPair.first;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+
+ if (propertyPair.first == "Reading")
+ {
+ keys = ptr;
+ }
+ else
+ {
+ values = ptr;
+ }
+ if (keys != nullptr && values != nullptr)
+ {
+ if (keys->size() != values->size())
+ {
+ BMCWEB_LOG_ERROR
+ << "Reading and Output size don't match ";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ nlohmann::json& steps = (*config)["Steps"];
+ steps = nlohmann::json::array();
+ for (size_t ii = 0; ii < keys->size(); ii++)
+ {
+ nlohmann::json::object_t step;
+ step["Target"] = (*keys)[ii];
+ step["Output"] = (*values)[ii];
+ steps.push_back(std::move(step));
+ }
+ }
+ }
+ if (propertyPair.first == "NegativeHysteresis" ||
+ propertyPair.first == "PositiveHysteresis")
{
const double* ptr =
std::get_if<double>(&propertyPair.second);
@@ -497,197 +548,131 @@
}
(*config)[propertyPair.first] = *ptr;
}
+ }
- if (intfPair.first == stepwiseConfigurationIface)
+ // pid and fans are off the same configuration
+ if (intfPair.first == pidConfigurationIface ||
+ intfPair.first == stepwiseConfigurationIface)
+ {
+
+ if (propertyPair.first == "Zones")
{
- if (propertyPair.first == "Reading" ||
- propertyPair.first == "Output")
+ const std::vector<std::string>* inputs =
+ std::get_if<std::vector<std::string>>(
+ &propertyPair.second);
+
+ if (inputs == nullptr)
{
- const std::vector<double>* ptr =
- std::get_if<std::vector<double>>(
- &propertyPair.second);
-
- if (ptr == nullptr)
- {
- BMCWEB_LOG_ERROR << "Field Illegal "
- << propertyPair.first;
- messages::internalError(asyncResp->res);
- return;
- }
-
- if (propertyPair.first == "Reading")
- {
- keys = ptr;
- }
- else
- {
- values = ptr;
- }
- if (keys != nullptr && values != nullptr)
- {
- if (keys->size() != values->size())
- {
- BMCWEB_LOG_ERROR
- << "Reading and Output size don't match ";
- messages::internalError(asyncResp->res);
- return;
- }
- nlohmann::json& steps = (*config)["Steps"];
- steps = nlohmann::json::array();
- for (size_t ii = 0; ii < keys->size(); ii++)
- {
- nlohmann::json::object_t step;
- step["Target"] = (*keys)[ii];
- step["Output"] = (*values)[ii];
- steps.push_back(std::move(step));
- }
- }
+ BMCWEB_LOG_ERROR << "Zones Pid Field Illegal";
+ messages::internalError(asyncResp->res);
+ return;
}
- if (propertyPair.first == "NegativeHysteresis" ||
- propertyPair.first == "PositiveHysteresis")
+ auto& data = (*config)[propertyPair.first];
+ data = nlohmann::json::array();
+ for (std::string itemCopy : *inputs)
{
- const double* ptr =
- std::get_if<double>(&propertyPair.second);
- if (ptr == nullptr)
- {
- BMCWEB_LOG_ERROR << "Field Illegal "
- << propertyPair.first;
- messages::internalError(asyncResp->res);
- return;
- }
- (*config)[propertyPair.first] = *ptr;
+ dbus::utility::escapePathForDbus(itemCopy);
+ nlohmann::json::object_t input;
+ input["@odata.id"] =
+ "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/" +
+ itemCopy;
+ data.push_back(std::move(input));
}
}
+ // todo(james): may never happen, but this
+ // assumes configuration data referenced in the
+ // PID config is provided by the same daemon, we
+ // could add another loop to cover all cases,
+ // but I'm okay kicking this can down the road a
+ // bit
- // pid and fans are off the same configuration
- if (intfPair.first == pidConfigurationIface ||
- intfPair.first == stepwiseConfigurationIface)
+ else if (propertyPair.first == "Inputs" ||
+ propertyPair.first == "Outputs")
{
+ auto& data = (*config)[propertyPair.first];
+ const std::vector<std::string>* inputs =
+ std::get_if<std::vector<std::string>>(
+ &propertyPair.second);
- if (propertyPair.first == "Zones")
+ if (inputs == nullptr)
{
- const std::vector<std::string>* inputs =
- std::get_if<std::vector<std::string>>(
- &propertyPair.second);
-
- if (inputs == nullptr)
- {
- BMCWEB_LOG_ERROR
- << "Zones Pid Field Illegal";
- messages::internalError(asyncResp->res);
- return;
- }
- auto& data = (*config)[propertyPair.first];
- data = nlohmann::json::array();
- for (std::string itemCopy : *inputs)
- {
- dbus::utility::escapePathForDbus(itemCopy);
- nlohmann::json::object_t input;
- input["@odata.id"] =
- "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/" +
- itemCopy;
- data.push_back(std::move(input));
- }
+ BMCWEB_LOG_ERROR << "Field Illegal "
+ << propertyPair.first;
+ messages::internalError(asyncResp->res);
+ return;
}
- // todo(james): may never happen, but this
- // assumes configuration data referenced in the
- // PID config is provided by the same daemon, we
- // could add another loop to cover all cases,
- // but I'm okay kicking this can down the road a
- // bit
+ data = *inputs;
+ }
+ else if (propertyPair.first == "SetPointOffset")
+ {
+ const std::string* ptr =
+ std::get_if<std::string>(&propertyPair.second);
- else if (propertyPair.first == "Inputs" ||
- propertyPair.first == "Outputs")
+ if (ptr == nullptr)
{
- auto& data = (*config)[propertyPair.first];
- const std::vector<std::string>* inputs =
- std::get_if<std::vector<std::string>>(
- &propertyPair.second);
-
- if (inputs == nullptr)
- {
- BMCWEB_LOG_ERROR << "Field Illegal "
- << propertyPair.first;
- messages::internalError(asyncResp->res);
- return;
- }
- data = *inputs;
+ BMCWEB_LOG_ERROR << "Field Illegal "
+ << propertyPair.first;
+ messages::internalError(asyncResp->res);
+ return;
}
- else if (propertyPair.first == "SetPointOffset")
+ // translate from dbus to redfish
+ if (*ptr == "WarningHigh")
{
- const std::string* ptr =
- std::get_if<std::string>(
- &propertyPair.second);
-
- if (ptr == nullptr)
- {
- BMCWEB_LOG_ERROR << "Field Illegal "
- << propertyPair.first;
- messages::internalError(asyncResp->res);
- return;
- }
- // translate from dbus to redfish
- if (*ptr == "WarningHigh")
- {
- (*config)["SetPointOffset"] =
- "UpperThresholdNonCritical";
- }
- else if (*ptr == "WarningLow")
- {
- (*config)["SetPointOffset"] =
- "LowerThresholdNonCritical";
- }
- else if (*ptr == "CriticalHigh")
- {
- (*config)["SetPointOffset"] =
- "UpperThresholdCritical";
- }
- else if (*ptr == "CriticalLow")
- {
- (*config)["SetPointOffset"] =
- "LowerThresholdCritical";
- }
- else
- {
- BMCWEB_LOG_ERROR << "Value Illegal "
- << *ptr;
- messages::internalError(asyncResp->res);
- return;
- }
+ (*config)["SetPointOffset"] =
+ "UpperThresholdNonCritical";
}
- // doubles
- else if (propertyPair.first ==
- "FFGainCoefficient" ||
- propertyPair.first == "FFOffCoefficient" ||
- propertyPair.first == "ICoefficient" ||
- propertyPair.first == "ILimitMax" ||
- propertyPair.first == "ILimitMin" ||
- propertyPair.first ==
- "PositiveHysteresis" ||
- propertyPair.first ==
- "NegativeHysteresis" ||
- propertyPair.first == "OutLimitMax" ||
- propertyPair.first == "OutLimitMin" ||
- propertyPair.first == "PCoefficient" ||
- propertyPair.first == "SetPoint" ||
- propertyPair.first == "SlewNeg" ||
- propertyPair.first == "SlewPos")
+ else if (*ptr == "WarningLow")
{
- const double* ptr =
- std::get_if<double>(&propertyPair.second);
- if (ptr == nullptr)
- {
- BMCWEB_LOG_ERROR << "Field Illegal "
- << propertyPair.first;
- messages::internalError(asyncResp->res);
- return;
- }
- (*config)[propertyPair.first] = *ptr;
+ (*config)["SetPointOffset"] =
+ "LowerThresholdNonCritical";
}
+ else if (*ptr == "CriticalHigh")
+ {
+ (*config)["SetPointOffset"] =
+ "UpperThresholdCritical";
+ }
+ else if (*ptr == "CriticalLow")
+ {
+ (*config)["SetPointOffset"] =
+ "LowerThresholdCritical";
+ }
+ else
+ {
+ BMCWEB_LOG_ERROR << "Value Illegal " << *ptr;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ }
+ // doubles
+ else if (propertyPair.first == "FFGainCoefficient" ||
+ propertyPair.first == "FFOffCoefficient" ||
+ propertyPair.first == "ICoefficient" ||
+ propertyPair.first == "ILimitMax" ||
+ propertyPair.first == "ILimitMin" ||
+ propertyPair.first == "PositiveHysteresis" ||
+ propertyPair.first == "NegativeHysteresis" ||
+ propertyPair.first == "OutLimitMax" ||
+ propertyPair.first == "OutLimitMin" ||
+ propertyPair.first == "PCoefficient" ||
+ propertyPair.first == "SetPoint" ||
+ propertyPair.first == "SlewNeg" ||
+ propertyPair.first == "SlewPos")
+ {
+ const double* ptr =
+ std::get_if<double>(&propertyPair.second);
+ if (ptr == nullptr)
+ {
+ BMCWEB_LOG_ERROR << "Field Illegal "
+ << propertyPair.first;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ (*config)[propertyPair.first] = *ptr;
}
}
}
}
+ }
},
connection, path, objectManagerIface, "GetManagedObjects");
}
@@ -745,15 +730,15 @@
std::string escaped = boost::replace_all_copy(value, " ", "_");
escaped = "/" + escaped;
- auto it = std::find_if(
- managedObj.begin(), managedObj.end(), [&escaped](const auto& obj) {
- if (boost::algorithm::ends_with(obj.first.str, escaped))
- {
- BMCWEB_LOG_DEBUG << "Matched " << obj.first.str << "\n";
- return true;
- }
- return false;
- });
+ auto it = std::find_if(managedObj.begin(), managedObj.end(),
+ [&escaped](const auto& obj) {
+ if (boost::algorithm::ends_with(obj.first.str, escaped))
+ {
+ BMCWEB_LOG_DEBUG << "Matched " << obj.first.str << "\n";
+ return true;
+ }
+ return false;
+ });
if (it == managedObj.end())
{
@@ -804,13 +789,13 @@
// delete interface
crow::connections::systemBus->async_method_call(
[response, path](const boost::system::error_code ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Error patching " << path << ": " << ec;
- messages::internalError(response->res);
- return;
- }
- messages::success(response->res);
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "Error patching " << path << ": " << ec;
+ messages::internalError(response->res);
+ return;
+ }
+ messages::success(response->res);
},
"xyz.openbmc_project.EntityManager", path, iface, "Delete");
return CreatePIDRet::del;
@@ -1197,13 +1182,13 @@
[self](
const boost::system::error_code ec,
const dbus::utility::MapperGetSubTreeResponse& subtreeLocal) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << ec;
- messages::internalError(self->asyncResp->res);
- return;
- }
- self->subtree = subtreeLocal;
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << ec;
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+ self->subtree = subtreeLocal;
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
@@ -1217,66 +1202,39 @@
[self](
const boost::system::error_code ec,
const dbus::utility::MapperGetSubTreeResponse& subtreeLocal) {
- if (ec || subtreeLocal.empty())
+ if (ec || subtreeLocal.empty())
+ {
+ return;
+ }
+ if (subtreeLocal[0].second.size() != 1)
+ {
+ // invalid mapper response, should never happen
+ BMCWEB_LOG_ERROR << "GetPIDValues: Mapper Error";
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+
+ const std::string& path = subtreeLocal[0].first;
+ const std::string& owner = subtreeLocal[0].second[0].first;
+ crow::connections::systemBus->async_method_call(
+ [path, owner,
+ self](const boost::system::error_code ec2,
+ const dbus::utility::DBusPropertiesMap& resp) {
+ if (ec2)
{
- return;
- }
- if (subtreeLocal[0].second.size() != 1)
- {
- // invalid mapper response, should never happen
- BMCWEB_LOG_ERROR << "GetPIDValues: Mapper Error";
+ BMCWEB_LOG_ERROR
+ << "GetPIDValues: Can't get thermalModeIface " << path;
messages::internalError(self->asyncResp->res);
return;
}
-
- const std::string& path = subtreeLocal[0].first;
- const std::string& owner = subtreeLocal[0].second[0].first;
- crow::connections::systemBus->async_method_call(
- [path, owner,
- self](const boost::system::error_code ec2,
- const dbus::utility::DBusPropertiesMap& resp) {
- if (ec2)
- {
- BMCWEB_LOG_ERROR
- << "GetPIDValues: Can't get thermalModeIface "
- << path;
- messages::internalError(self->asyncResp->res);
- return;
- }
- const std::string* current = nullptr;
- const std::vector<std::string>* supported = nullptr;
- for (const auto& [key, value] : resp)
- {
- if (key == "Current")
- {
- current = std::get_if<std::string>(&value);
- if (current == nullptr)
- {
- BMCWEB_LOG_ERROR
- << "GetPIDValues: thermal mode iface invalid "
- << path;
- messages::internalError(
- self->asyncResp->res);
- return;
- }
- }
- if (key == "Supported")
- {
- supported =
- std::get_if<std::vector<std::string>>(
- &value);
- if (supported == nullptr)
- {
- BMCWEB_LOG_ERROR
- << "GetPIDValues: thermal mode iface invalid"
- << path;
- messages::internalError(
- self->asyncResp->res);
- return;
- }
- }
- }
- if (current == nullptr || supported == nullptr)
+ const std::string* current = nullptr;
+ const std::vector<std::string>* supported = nullptr;
+ for (const auto& [key, value] : resp)
+ {
+ if (key == "Current")
+ {
+ current = std::get_if<std::string>(&value);
+ if (current == nullptr)
{
BMCWEB_LOG_ERROR
<< "GetPIDValues: thermal mode iface invalid "
@@ -1284,11 +1242,33 @@
messages::internalError(self->asyncResp->res);
return;
}
- self->currentProfile = *current;
- self->supportedProfiles = *supported;
- },
- owner, path, "org.freedesktop.DBus.Properties", "GetAll",
- thermalModeIface);
+ }
+ if (key == "Supported")
+ {
+ supported =
+ std::get_if<std::vector<std::string>>(&value);
+ if (supported == nullptr)
+ {
+ BMCWEB_LOG_ERROR
+ << "GetPIDValues: thermal mode iface invalid"
+ << path;
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+ }
+ }
+ if (current == nullptr || supported == nullptr)
+ {
+ BMCWEB_LOG_ERROR
+ << "GetPIDValues: thermal mode iface invalid " << path;
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+ self->currentProfile = *current;
+ self->supportedProfiles = *supported;
+ },
+ owner, path, "org.freedesktop.DBus.Properties", "GetAll",
+ thermalModeIface);
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
@@ -1409,30 +1389,29 @@
crow::connections::systemBus->async_method_call(
[self](const boost::system::error_code ec,
const dbus::utility::ManagedObjectType& mObj) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Error communicating to Entity Manager";
- messages::internalError(self->asyncResp->res);
- return;
- }
- const std::array<const char*, 3> configurations = {
- pidConfigurationIface, pidZoneConfigurationIface,
- stepwiseConfigurationIface};
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "Error communicating to Entity Manager";
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+ const std::array<const char*, 3> configurations = {
+ pidConfigurationIface, pidZoneConfigurationIface,
+ stepwiseConfigurationIface};
- for (const auto& [path, object] : mObj)
+ for (const auto& [path, object] : mObj)
+ {
+ for (const auto& [interface, _] : object)
{
- for (const auto& [interface, _] : object)
+ if (std::find(configurations.begin(), configurations.end(),
+ interface) != configurations.end())
{
- if (std::find(configurations.begin(),
- configurations.end(),
- interface) != configurations.end())
- {
- self->objectCount++;
- break;
- }
+ self->objectCount++;
+ break;
}
}
- self->managedObj = mObj;
+ }
+ self->managedObj = mObj;
},
"xyz.openbmc_project.EntityManager", "/", objectManagerIface,
"GetManagedObjects");
@@ -1441,66 +1420,38 @@
crow::connections::systemBus->async_method_call(
[self](const boost::system::error_code ec,
const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec || subtree.empty())
+ if (ec || subtree.empty())
+ {
+ return;
+ }
+ if (subtree[0].second.empty())
+ {
+ // invalid mapper response, should never happen
+ BMCWEB_LOG_ERROR << "SetPIDValues: Mapper Error";
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+
+ const std::string& path = subtree[0].first;
+ const std::string& owner = subtree[0].second[0].first;
+ crow::connections::systemBus->async_method_call(
+ [self, path, owner](const boost::system::error_code ec2,
+ const dbus::utility::DBusPropertiesMap& r) {
+ if (ec2)
{
- return;
- }
- if (subtree[0].second.empty())
- {
- // invalid mapper response, should never happen
- BMCWEB_LOG_ERROR << "SetPIDValues: Mapper Error";
+ BMCWEB_LOG_ERROR
+ << "SetPIDValues: Can't get thermalModeIface " << path;
messages::internalError(self->asyncResp->res);
return;
}
-
- const std::string& path = subtree[0].first;
- const std::string& owner = subtree[0].second[0].first;
- crow::connections::systemBus->async_method_call(
- [self, path,
- owner](const boost::system::error_code ec2,
- const dbus::utility::DBusPropertiesMap& r) {
- if (ec2)
- {
- BMCWEB_LOG_ERROR
- << "SetPIDValues: Can't get thermalModeIface "
- << path;
- messages::internalError(self->asyncResp->res);
- return;
- }
- const std::string* current = nullptr;
- const std::vector<std::string>* supported = nullptr;
- for (const auto& [key, value] : r)
- {
- if (key == "Current")
- {
- current = std::get_if<std::string>(&value);
- if (current == nullptr)
- {
- BMCWEB_LOG_ERROR
- << "SetPIDValues: thermal mode iface invalid "
- << path;
- messages::internalError(
- self->asyncResp->res);
- return;
- }
- }
- if (key == "Supported")
- {
- supported =
- std::get_if<std::vector<std::string>>(
- &value);
- if (supported == nullptr)
- {
- BMCWEB_LOG_ERROR
- << "SetPIDValues: thermal mode iface invalid"
- << path;
- messages::internalError(
- self->asyncResp->res);
- return;
- }
- }
- }
- if (current == nullptr || supported == nullptr)
+ const std::string* current = nullptr;
+ const std::vector<std::string>* supported = nullptr;
+ for (const auto& [key, value] : r)
+ {
+ if (key == "Current")
+ {
+ current = std::get_if<std::string>(&value);
+ if (current == nullptr)
{
BMCWEB_LOG_ERROR
<< "SetPIDValues: thermal mode iface invalid "
@@ -1508,13 +1459,35 @@
messages::internalError(self->asyncResp->res);
return;
}
- self->currentProfile = *current;
- self->supportedProfiles = *supported;
- self->profileConnection = owner;
- self->profilePath = path;
- },
- owner, path, "org.freedesktop.DBus.Properties", "GetAll",
- thermalModeIface);
+ }
+ if (key == "Supported")
+ {
+ supported =
+ std::get_if<std::vector<std::string>>(&value);
+ if (supported == nullptr)
+ {
+ BMCWEB_LOG_ERROR
+ << "SetPIDValues: thermal mode iface invalid"
+ << path;
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+ }
+ }
+ if (current == nullptr || supported == nullptr)
+ {
+ BMCWEB_LOG_ERROR
+ << "SetPIDValues: thermal mode iface invalid " << path;
+ messages::internalError(self->asyncResp->res);
+ return;
+ }
+ self->currentProfile = *current;
+ self->supportedProfiles = *supported;
+ self->profileConnection = owner;
+ self->profilePath = path;
+ },
+ owner, path, "org.freedesktop.DBus.Properties", "GetAll",
+ thermalModeIface);
},
"xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
@@ -1540,11 +1513,11 @@
currentProfile = *profile;
crow::connections::systemBus->async_method_call(
[response](const boost::system::error_code ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Error patching profile" << ec;
- messages::internalError(response->res);
- }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "Error patching profile" << ec;
+ messages::internalError(response->res);
+ }
},
profileConnection, profilePath,
"org.freedesktop.DBus.Properties", "Set", thermalModeIface,
@@ -1571,9 +1544,9 @@
auto pathItr =
std::find_if(managedObj.begin(), managedObj.end(),
[&name](const auto& obj) {
- return boost::algorithm::ends_with(
- obj.first.str, "/" + name);
- });
+ return boost::algorithm::ends_with(obj.first.str,
+ "/" + name);
+ });
dbus::utility::DBusPropertiesMap output;
output.reserve(16); // The pid interface length
@@ -1664,15 +1637,14 @@
[response,
propertyName{std::string(property.first)}](
const boost::system::error_code ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Error patching "
- << propertyName << ": "
- << ec;
- messages::internalError(response->res);
- return;
- }
- messages::success(response->res);
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "Error patching "
+ << propertyName << ": " << ec;
+ messages::internalError(response->res);
+ return;
+ }
+ messages::success(response->res);
},
"xyz.openbmc_project.EntityManager", path,
"org.freedesktop.DBus.Properties", "Set", iface,
@@ -1710,14 +1682,14 @@
crow::connections::systemBus->async_method_call(
[response](const boost::system::error_code ec) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Error Adding Pid Object "
- << ec;
- messages::internalError(response->res);
- return;
- }
- messages::success(response->res);
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "Error Adding Pid Object "
+ << ec;
+ messages::internalError(response->res);
+ return;
+ }
+ messages::success(response->res);
},
"xyz.openbmc_project.EntityManager", chassis,
"xyz.openbmc_project.AddObject", "AddObject", output);
@@ -1769,16 +1741,16 @@
"xyz.openbmc_project.Inventory.Decorator.LocationCode", "LocationCode",
[aResp](const boost::system::error_code ec,
const std::string& property) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG << "DBUS response error for "
- "Location";
- messages::internalError(aResp->res);
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << "DBUS response error for "
+ "Location";
+ messages::internalError(aResp->res);
+ return;
+ }
- aResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
- property;
+ aResp->res.jsonValue["Location"]["PartLocation"]["ServiceLabel"] =
+ property;
});
}
// avoid name collision systems.hpp
@@ -1793,19 +1765,19 @@
"LastRebootTime",
[aResp](const boost::system::error_code ec,
const uint64_t lastResetTime) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG << "D-BUS response error " << ec;
- return;
- }
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << "D-BUS response error " << ec;
+ return;
+ }
- // LastRebootTime is epoch time, in milliseconds
- // https://github.com/openbmc/phosphor-dbus-interfaces/blob/7f9a128eb9296e926422ddc312c148b625890bb6/xyz/openbmc_project/State/BMC.interface.yaml#L19
- uint64_t lastResetTimeStamp = lastResetTime / 1000;
+ // LastRebootTime is epoch time, in milliseconds
+ // https://github.com/openbmc/phosphor-dbus-interfaces/blob/7f9a128eb9296e926422ddc312c148b625890bb6/xyz/openbmc_project/State/BMC.interface.yaml#L19
+ uint64_t lastResetTimeStamp = lastResetTime / 1000;
- // Convert to ISO 8601 standard
- aResp->res.jsonValue["LastResetTime"] =
- crow::utility::getDateTimeUint(lastResetTimeStamp);
+ // Convert to ISO 8601 standard
+ aResp->res.jsonValue["LastResetTime"] =
+ crow::utility::getDateTimeUint(lastResetTimeStamp);
});
}
@@ -1845,75 +1817,75 @@
[aResp, firmwareId,
runningFirmwareTarget](const boost::system::error_code ec,
dbus::utility::ManagedObjectType& subtree) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << "D-Bus response error getting objects.";
+ messages::internalError(aResp->res);
+ return;
+ }
+
+ if (subtree.empty())
+ {
+ BMCWEB_LOG_DEBUG << "Can't find image!";
+ messages::internalError(aResp->res);
+ return;
+ }
+
+ bool foundImage = false;
+ for (auto& object : subtree)
+ {
+ const std::string& path =
+ static_cast<const std::string&>(object.first);
+ std::size_t idPos2 = path.rfind('/');
+
+ if (idPos2 == std::string::npos)
+ {
+ continue;
+ }
+
+ idPos2++;
+ if (idPos2 >= path.size())
+ {
+ continue;
+ }
+
+ if (path.substr(idPos2) == firmwareId)
+ {
+ foundImage = true;
+ break;
+ }
+ }
+
+ if (!foundImage)
+ {
+ messages::propertyValueNotInList(aResp->res, runningFirmwareTarget,
+ "@odata.id");
+ BMCWEB_LOG_DEBUG << "Invalid firmware ID.";
+ return;
+ }
+
+ BMCWEB_LOG_DEBUG << "Setting firmware version " << firmwareId
+ << " to priority 0.";
+
+ // Only support Immediate
+ // An addition could be a Redfish Setting like
+ // ActiveSoftwareImageApplyTime and support OnReset
+ crow::connections::systemBus->async_method_call(
+ [aResp](const boost::system::error_code ec) {
if (ec)
{
- BMCWEB_LOG_DEBUG << "D-Bus response error getting objects.";
+ BMCWEB_LOG_DEBUG << "D-Bus response error setting.";
messages::internalError(aResp->res);
return;
}
+ doBMCGracefulRestart(aResp);
+ },
- if (subtree.empty())
- {
- BMCWEB_LOG_DEBUG << "Can't find image!";
- messages::internalError(aResp->res);
- return;
- }
-
- bool foundImage = false;
- for (auto& object : subtree)
- {
- const std::string& path =
- static_cast<const std::string&>(object.first);
- std::size_t idPos2 = path.rfind('/');
-
- if (idPos2 == std::string::npos)
- {
- continue;
- }
-
- idPos2++;
- if (idPos2 >= path.size())
- {
- continue;
- }
-
- if (path.substr(idPos2) == firmwareId)
- {
- foundImage = true;
- break;
- }
- }
-
- if (!foundImage)
- {
- messages::propertyValueNotInList(
- aResp->res, runningFirmwareTarget, "@odata.id");
- BMCWEB_LOG_DEBUG << "Invalid firmware ID.";
- return;
- }
-
- BMCWEB_LOG_DEBUG << "Setting firmware version " << firmwareId
- << " to priority 0.";
-
- // Only support Immediate
- // An addition could be a Redfish Setting like
- // ActiveSoftwareImageApplyTime and support OnReset
- crow::connections::systemBus->async_method_call(
- [aResp](const boost::system::error_code ec) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG << "D-Bus response error setting.";
- messages::internalError(aResp->res);
- return;
- }
- doBMCGracefulRestart(aResp);
- },
-
- "xyz.openbmc_project.Software.BMC.Updater",
- "/xyz/openbmc_project/software/" + firmwareId,
- "org.freedesktop.DBus.Properties", "Set",
- "xyz.openbmc_project.Software.RedundancyPriority", "Priority",
- dbus::utility::DbusVariantType(static_cast<uint8_t>(0)));
+ "xyz.openbmc_project.Software.BMC.Updater",
+ "/xyz/openbmc_project/software/" + firmwareId,
+ "org.freedesktop.DBus.Properties", "Set",
+ "xyz.openbmc_project.Software.RedundancyPriority", "Priority",
+ dbus::utility::DbusVariantType(static_cast<uint8_t>(0)));
},
"xyz.openbmc_project.Software.BMC.Updater",
"/xyz/openbmc_project/software", "org.freedesktop.DBus.ObjectManager",
@@ -1945,15 +1917,15 @@
crow::connections::systemBus->async_method_call(
[aResp{std::move(aResp)}, datetime{std::move(datetime)}](
const boost::system::error_code ec) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG << "Failed to set elapsed time. "
- "DBUS response error "
- << ec;
- messages::internalError(aResp->res);
- return;
- }
- aResp->res.jsonValue["DateTime"] = datetime;
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG << "Failed to set elapsed time. "
+ "DBUS response error "
+ << ec;
+ messages::internalError(aResp->res);
+ return;
+ }
+ aResp->res.jsonValue["DateTime"] = datetime;
},
"xyz.openbmc_project.Time.Manager", "/xyz/openbmc_project/time/bmc",
"org.freedesktop.DBus.Properties", "Set",
@@ -1973,266 +1945,243 @@
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/")
.privileges(redfish::privileges::getManager)
- .methods(
- boost::beast::http::verb::
- get)([&app, uuid](
- const crow::Request& req,
+ .methods(boost::beast::http::verb::get)(
+ [&app, uuid](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
- {
- return;
- }
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers/bmc";
- asyncResp->res.jsonValue["@odata.type"] =
- "#Manager.v1_11_0.Manager";
- asyncResp->res.jsonValue["Id"] = "bmc";
- asyncResp->res.jsonValue["Name"] = "OpenBmc Manager";
- asyncResp->res.jsonValue["Description"] =
- "Baseboard Management Controller";
- asyncResp->res.jsonValue["PowerState"] = "On";
- asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
- asyncResp->res.jsonValue["Status"]["Health"] = "OK";
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers/bmc";
+ asyncResp->res.jsonValue["@odata.type"] = "#Manager.v1_11_0.Manager";
+ asyncResp->res.jsonValue["Id"] = "bmc";
+ asyncResp->res.jsonValue["Name"] = "OpenBmc Manager";
+ asyncResp->res.jsonValue["Description"] =
+ "Baseboard Management Controller";
+ asyncResp->res.jsonValue["PowerState"] = "On";
+ asyncResp->res.jsonValue["Status"]["State"] = "Enabled";
+ asyncResp->res.jsonValue["Status"]["Health"] = "OK";
- asyncResp->res.jsonValue["ManagerType"] = "BMC";
- asyncResp->res.jsonValue["UUID"] = systemd_utils::getUuid();
- asyncResp->res.jsonValue["ServiceEntryPointUUID"] = uuid;
- asyncResp->res.jsonValue["Model"] =
- "OpenBmc"; // TODO(ed), get model
+ asyncResp->res.jsonValue["ManagerType"] = "BMC";
+ asyncResp->res.jsonValue["UUID"] = systemd_utils::getUuid();
+ asyncResp->res.jsonValue["ServiceEntryPointUUID"] = uuid;
+ asyncResp->res.jsonValue["Model"] = "OpenBmc"; // TODO(ed), get model
- asyncResp->res.jsonValue["LogServices"]["@odata.id"] =
- "/redfish/v1/Managers/bmc/LogServices";
- asyncResp->res.jsonValue["NetworkProtocol"]["@odata.id"] =
- "/redfish/v1/Managers/bmc/NetworkProtocol";
- asyncResp->res.jsonValue["EthernetInterfaces"]["@odata.id"] =
- "/redfish/v1/Managers/bmc/EthernetInterfaces";
+ asyncResp->res.jsonValue["LogServices"]["@odata.id"] =
+ "/redfish/v1/Managers/bmc/LogServices";
+ asyncResp->res.jsonValue["NetworkProtocol"]["@odata.id"] =
+ "/redfish/v1/Managers/bmc/NetworkProtocol";
+ asyncResp->res.jsonValue["EthernetInterfaces"]["@odata.id"] =
+ "/redfish/v1/Managers/bmc/EthernetInterfaces";
#ifdef BMCWEB_ENABLE_VM_NBDPROXY
- asyncResp->res.jsonValue["VirtualMedia"]["@odata.id"] =
- "/redfish/v1/Managers/bmc/VirtualMedia";
+ asyncResp->res.jsonValue["VirtualMedia"]["@odata.id"] =
+ "/redfish/v1/Managers/bmc/VirtualMedia";
#endif // BMCWEB_ENABLE_VM_NBDPROXY
- // default oem data
- nlohmann::json& oem = asyncResp->res.jsonValue["Oem"];
- nlohmann::json& oemOpenbmc = oem["OpenBmc"];
- oem["@odata.type"] = "#OemManager.Oem";
- oem["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem";
- oemOpenbmc["@odata.type"] = "#OemManager.OpenBmc";
- oemOpenbmc["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem/OpenBmc";
+ // default oem data
+ nlohmann::json& oem = asyncResp->res.jsonValue["Oem"];
+ nlohmann::json& oemOpenbmc = oem["OpenBmc"];
+ oem["@odata.type"] = "#OemManager.Oem";
+ oem["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem";
+ oemOpenbmc["@odata.type"] = "#OemManager.OpenBmc";
+ oemOpenbmc["@odata.id"] = "/redfish/v1/Managers/bmc#/Oem/OpenBmc";
- nlohmann::json::object_t certificates;
- certificates["@odata.id"] =
- "/redfish/v1/Managers/bmc/Truststore/Certificates";
- oemOpenbmc["Certificates"] = std::move(certificates);
+ nlohmann::json::object_t certificates;
+ certificates["@odata.id"] =
+ "/redfish/v1/Managers/bmc/Truststore/Certificates";
+ oemOpenbmc["Certificates"] = std::move(certificates);
- // Manager.Reset (an action) can be many values, OpenBMC only
- // supports BMC reboot.
- nlohmann::json& managerReset =
- asyncResp->res.jsonValue["Actions"]["#Manager.Reset"];
- managerReset["target"] =
- "/redfish/v1/Managers/bmc/Actions/Manager.Reset";
- managerReset["@Redfish.ActionInfo"] =
- "/redfish/v1/Managers/bmc/ResetActionInfo";
+ // Manager.Reset (an action) can be many values, OpenBMC only
+ // supports BMC reboot.
+ nlohmann::json& managerReset =
+ asyncResp->res.jsonValue["Actions"]["#Manager.Reset"];
+ managerReset["target"] =
+ "/redfish/v1/Managers/bmc/Actions/Manager.Reset";
+ managerReset["@Redfish.ActionInfo"] =
+ "/redfish/v1/Managers/bmc/ResetActionInfo";
- // ResetToDefaults (Factory Reset) has values like
- // PreserveNetworkAndUsers and PreserveNetwork that aren't supported
- // on OpenBMC
- nlohmann::json& resetToDefaults =
- asyncResp->res.jsonValue["Actions"]["#Manager.ResetToDefaults"];
- resetToDefaults["target"] =
- "/redfish/v1/Managers/bmc/Actions/Manager.ResetToDefaults";
- resetToDefaults["ResetType@Redfish.AllowableValues"] = {"ResetAll"};
+ // ResetToDefaults (Factory Reset) has values like
+ // PreserveNetworkAndUsers and PreserveNetwork that aren't supported
+ // on OpenBMC
+ nlohmann::json& resetToDefaults =
+ asyncResp->res.jsonValue["Actions"]["#Manager.ResetToDefaults"];
+ resetToDefaults["target"] =
+ "/redfish/v1/Managers/bmc/Actions/Manager.ResetToDefaults";
+ resetToDefaults["ResetType@Redfish.AllowableValues"] = {"ResetAll"};
- std::pair<std::string, std::string> redfishDateTimeOffset =
- crow::utility::getDateTimeOffsetNow();
+ std::pair<std::string, std::string> redfishDateTimeOffset =
+ crow::utility::getDateTimeOffsetNow();
- asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
- asyncResp->res.jsonValue["DateTimeLocalOffset"] =
- redfishDateTimeOffset.second;
+ asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
+ asyncResp->res.jsonValue["DateTimeLocalOffset"] =
+ redfishDateTimeOffset.second;
- // TODO (Gunnar): Remove these one day since moved to ComputerSystem
- // Still used by OCP profiles
- // https://github.com/opencomputeproject/OCP-Profiles/issues/23
- // Fill in SerialConsole info
- asyncResp->res.jsonValue["SerialConsole"]["ServiceEnabled"] = true;
- asyncResp->res.jsonValue["SerialConsole"]["MaxConcurrentSessions"] =
- 15;
- asyncResp->res.jsonValue["SerialConsole"]["ConnectTypesSupported"] =
- {"IPMI", "SSH"};
+ // TODO (Gunnar): Remove these one day since moved to ComputerSystem
+ // Still used by OCP profiles
+ // https://github.com/opencomputeproject/OCP-Profiles/issues/23
+ // Fill in SerialConsole info
+ asyncResp->res.jsonValue["SerialConsole"]["ServiceEnabled"] = true;
+ asyncResp->res.jsonValue["SerialConsole"]["MaxConcurrentSessions"] = 15;
+ asyncResp->res.jsonValue["SerialConsole"]["ConnectTypesSupported"] = {
+ "IPMI", "SSH"};
#ifdef BMCWEB_ENABLE_KVM
- // Fill in GraphicalConsole info
- asyncResp->res.jsonValue["GraphicalConsole"]["ServiceEnabled"] =
- true;
- asyncResp->res
- .jsonValue["GraphicalConsole"]["MaxConcurrentSessions"] = 4;
- asyncResp->res.jsonValue["GraphicalConsole"]
- ["ConnectTypesSupported"] = {"KVMIP"};
+ // Fill in GraphicalConsole info
+ asyncResp->res.jsonValue["GraphicalConsole"]["ServiceEnabled"] = true;
+ asyncResp->res.jsonValue["GraphicalConsole"]["MaxConcurrentSessions"] =
+ 4;
+ asyncResp->res
+ .jsonValue["GraphicalConsole"]["ConnectTypesSupported"] = {"KVMIP"};
#endif // BMCWEB_ENABLE_KVM
- asyncResp->res.jsonValue["Links"]["ManagerForServers@odata.count"] =
- 1;
+ asyncResp->res.jsonValue["Links"]["ManagerForServers@odata.count"] = 1;
- nlohmann::json::array_t managerForServers;
+ nlohmann::json::array_t managerForServers;
+ nlohmann::json::object_t manager;
+ manager["@odata.id"] = "/redfish/v1/Systems/system";
+ managerForServers.push_back(std::move(manager));
+
+ asyncResp->res.jsonValue["Links"]["ManagerForServers"] =
+ std::move(managerForServers);
+
+ auto health = std::make_shared<HealthPopulate>(asyncResp);
+ health->isManagersHealth = true;
+ health->populate();
+
+ fw_util::populateFirmwareInformation(asyncResp, fw_util::bmcPurpose,
+ "FirmwareVersion", true);
+
+ managerGetLastResetTime(asyncResp);
+
+ auto pids = std::make_shared<GetPIDValues>(asyncResp);
+ pids->run();
+
+ getMainChassisId(asyncResp,
+ [](const std::string& chassisId,
+ const std::shared_ptr<bmcweb::AsyncResp>& aRsp) {
+ aRsp->res.jsonValue["Links"]["ManagerForChassis@odata.count"] = 1;
+ nlohmann::json::array_t managerForChassis;
nlohmann::json::object_t manager;
- manager["@odata.id"] = "/redfish/v1/Systems/system";
- managerForServers.push_back(std::move(manager));
+ manager["@odata.id"] = "/redfish/v1/Chassis/" + chassisId;
+ managerForChassis.push_back(std::move(manager));
+ aRsp->res.jsonValue["Links"]["ManagerForChassis"] =
+ std::move(managerForChassis);
+ aRsp->res.jsonValue["Links"]["ManagerInChassis"]["@odata.id"] =
+ "/redfish/v1/Chassis/" + chassisId;
+ });
- asyncResp->res.jsonValue["Links"]["ManagerForServers"] =
- std::move(managerForServers);
+ static bool started = false;
- auto health = std::make_shared<HealthPopulate>(asyncResp);
- health->isManagersHealth = true;
- health->populate();
+ if (!started)
+ {
+ sdbusplus::asio::getProperty<double>(
+ *crow::connections::systemBus, "org.freedesktop.systemd1",
+ "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager",
+ "Progress",
+ [asyncResp](const boost::system::error_code ec,
+ const double& val) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << "Error while getting progress";
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ if (val < 1.0)
+ {
+ asyncResp->res.jsonValue["Status"]["State"] = "Starting";
+ started = true;
+ }
+ });
+ }
- fw_util::populateFirmwareInformation(asyncResp, fw_util::bmcPurpose,
- "FirmwareVersion", true);
-
- managerGetLastResetTime(asyncResp);
-
- auto pids = std::make_shared<GetPIDValues>(asyncResp);
- pids->run();
-
- getMainChassisId(asyncResp, [](const std::string& chassisId,
- const std::shared_ptr<
- bmcweb::AsyncResp>& aRsp) {
- aRsp->res.jsonValue["Links"]["ManagerForChassis@odata.count"] =
- 1;
- nlohmann::json::array_t managerForChassis;
- nlohmann::json::object_t manager;
- manager["@odata.id"] = "/redfish/v1/Chassis/" + chassisId;
- managerForChassis.push_back(std::move(manager));
- aRsp->res.jsonValue["Links"]["ManagerForChassis"] =
- std::move(managerForChassis);
- aRsp->res.jsonValue["Links"]["ManagerInChassis"]["@odata.id"] =
- "/redfish/v1/Chassis/" + chassisId;
- });
-
- static bool started = false;
-
- if (!started)
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](
+ const boost::system::error_code ec,
+ const dbus::utility::MapperGetSubTreeResponse& subtree) {
+ if (ec)
{
- sdbusplus::asio::getProperty<double>(
- *crow::connections::systemBus, "org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- "org.freedesktop.systemd1.Manager", "Progress",
- [asyncResp](const boost::system::error_code ec,
- const double& val) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << "Error while getting progress";
- messages::internalError(asyncResp->res);
- return;
- }
- if (val < 1.0)
- {
- asyncResp->res.jsonValue["Status"]["State"] =
- "Starting";
- started = true;
- }
- });
+ BMCWEB_LOG_DEBUG << "D-Bus response error on GetSubTree " << ec;
+ return;
+ }
+ if (subtree.empty())
+ {
+ BMCWEB_LOG_DEBUG << "Can't find bmc D-Bus object!";
+ return;
+ }
+ // Assume only 1 bmc D-Bus object
+ // Throw an error if there is more than 1
+ if (subtree.size() > 1)
+ {
+ BMCWEB_LOG_DEBUG << "Found more than 1 bmc D-Bus object!";
+ messages::internalError(asyncResp->res);
+ return;
}
- crow::connections::systemBus->async_method_call(
- [asyncResp](
- const boost::system::error_code ec,
- const dbus::utility::MapperGetSubTreeResponse& subtree) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG
- << "D-Bus response error on GetSubTree " << ec;
- return;
- }
- if (subtree.empty())
- {
- BMCWEB_LOG_DEBUG << "Can't find bmc D-Bus object!";
- return;
- }
- // Assume only 1 bmc D-Bus object
- // Throw an error if there is more than 1
- if (subtree.size() > 1)
- {
- BMCWEB_LOG_DEBUG
- << "Found more than 1 bmc D-Bus object!";
- messages::internalError(asyncResp->res);
- return;
- }
+ if (subtree[0].first.empty() || subtree[0].second.size() != 1)
+ {
+ BMCWEB_LOG_DEBUG << "Error getting bmc D-Bus object!";
+ messages::internalError(asyncResp->res);
+ return;
+ }
- if (subtree[0].first.empty() ||
- subtree[0].second.size() != 1)
- {
- BMCWEB_LOG_DEBUG << "Error getting bmc D-Bus object!";
- messages::internalError(asyncResp->res);
- return;
- }
+ const std::string& path = subtree[0].first;
+ const std::string& connectionName = subtree[0].second[0].first;
- const std::string& path = subtree[0].first;
- const std::string& connectionName =
- subtree[0].second[0].first;
-
- for (const auto& interfaceName :
- subtree[0].second[0].second)
- {
- if (interfaceName ==
- "xyz.openbmc_project.Inventory.Decorator.Asset")
- {
- crow::connections::systemBus->async_method_call(
- [asyncResp](
- const boost::system::error_code ec,
+ for (const auto& interfaceName : subtree[0].second[0].second)
+ {
+ if (interfaceName ==
+ "xyz.openbmc_project.Inventory.Decorator.Asset")
+ {
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code ec,
const dbus::utility::DBusPropertiesMap&
propertiesList) {
- if (ec)
- {
- BMCWEB_LOG_DEBUG
- << "Can't get bmc asset!";
- return;
- }
- for (const std::pair<
- std::string,
- dbus::utility::DbusVariantType>&
- property : propertiesList)
- {
- const std::string& propertyName =
- property.first;
-
- if ((propertyName == "PartNumber") ||
- (propertyName == "SerialNumber") ||
- (propertyName == "Manufacturer") ||
- (propertyName == "Model") ||
- (propertyName == "SparePartNumber"))
- {
- const std::string* value =
- std::get_if<std::string>(
- &property.second);
- if (value == nullptr)
- {
- // illegal property
- messages::internalError(
- asyncResp->res);
- return;
- }
- asyncResp->res
- .jsonValue[propertyName] =
- *value;
- }
- }
- },
- connectionName, path,
- "org.freedesktop.DBus.Properties", "GetAll",
- "xyz.openbmc_project.Inventory.Decorator.Asset");
- }
- else if (
- interfaceName ==
- "xyz.openbmc_project.Inventory.Decorator.LocationCode")
+ if (ec)
{
- getLocation(asyncResp, connectionName, path);
+ BMCWEB_LOG_DEBUG << "Can't get bmc asset!";
+ return;
}
- }
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTree",
- "/xyz/openbmc_project/inventory", int32_t(0),
- std::array<const char*, 1>{
- "xyz.openbmc_project.Inventory.Item.Bmc"});
+ for (const std::pair<std::string,
+ dbus::utility::DbusVariantType>&
+ property : propertiesList)
+ {
+ const std::string& propertyName = property.first;
+
+ if ((propertyName == "PartNumber") ||
+ (propertyName == "SerialNumber") ||
+ (propertyName == "Manufacturer") ||
+ (propertyName == "Model") ||
+ (propertyName == "SparePartNumber"))
+ {
+ const std::string* value =
+ std::get_if<std::string>(&property.second);
+ if (value == nullptr)
+ {
+ // illegal property
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue[propertyName] = *value;
+ }
+ }
+ },
+ connectionName, path, "org.freedesktop.DBus.Properties",
+ "GetAll",
+ "xyz.openbmc_project.Inventory.Decorator.Asset");
+ }
+ else if (interfaceName ==
+ "xyz.openbmc_project.Inventory.Decorator.LocationCode")
+ {
+ getLocation(asyncResp, connectionName, path);
+ }
+ }
+ },
+ "xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetSubTree",
+ "/xyz/openbmc_project/inventory", int32_t(0),
+ std::array<const char*, 1>{
+ "xyz.openbmc_project.Inventory.Item.Bmc"});
});
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/")
@@ -2240,85 +2189,81 @@
.methods(boost::beast::http::verb::patch)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+ std::optional<nlohmann::json> oem;
+ std::optional<nlohmann::json> links;
+ std::optional<std::string> datetime;
+
+ if (!json_util::readJsonPatch(req, asyncResp->res, "Oem", oem,
+ "DateTime", datetime, "Links", links))
+ {
+ return;
+ }
+
+ if (oem)
+ {
+ std::optional<nlohmann::json> openbmc;
+ if (!redfish::json_util::readJson(*oem, asyncResp->res, "OpenBmc",
+ openbmc))
+ {
+ BMCWEB_LOG_ERROR
+ << "Illegal Property "
+ << oem->dump(2, ' ', true,
+ nlohmann::json::error_handler_t::replace);
+ return;
+ }
+ if (openbmc)
+ {
+ std::optional<nlohmann::json> fan;
+ if (!redfish::json_util::readJson(*openbmc, asyncResp->res,
+ "Fan", fan))
{
+ BMCWEB_LOG_ERROR
+ << "Illegal Property "
+ << openbmc->dump(
+ 2, ' ', true,
+ nlohmann::json::error_handler_t::replace);
return;
}
- std::optional<nlohmann::json> oem;
- std::optional<nlohmann::json> links;
- std::optional<std::string> datetime;
-
- if (!json_util::readJsonPatch(req, asyncResp->res, "Oem", oem,
- "DateTime", datetime, "Links",
- links))
+ if (fan)
+ {
+ auto pid = std::make_shared<SetPIDValues>(asyncResp, *fan);
+ pid->run();
+ }
+ }
+ }
+ if (links)
+ {
+ std::optional<nlohmann::json> activeSoftwareImage;
+ if (!redfish::json_util::readJson(*links, asyncResp->res,
+ "ActiveSoftwareImage",
+ activeSoftwareImage))
+ {
+ return;
+ }
+ if (activeSoftwareImage)
+ {
+ std::optional<std::string> odataId;
+ if (!json_util::readJson(*activeSoftwareImage, asyncResp->res,
+ "@odata.id", odataId))
{
return;
}
- if (oem)
+ if (odataId)
{
- std::optional<nlohmann::json> openbmc;
- if (!redfish::json_util::readJson(*oem, asyncResp->res,
- "OpenBmc", openbmc))
- {
- BMCWEB_LOG_ERROR
- << "Illegal Property "
- << oem->dump(
- 2, ' ', true,
- nlohmann::json::error_handler_t::replace);
- return;
- }
- if (openbmc)
- {
- std::optional<nlohmann::json> fan;
- if (!redfish::json_util::readJson(
- *openbmc, asyncResp->res, "Fan", fan))
- {
- BMCWEB_LOG_ERROR
- << "Illegal Property "
- << openbmc->dump(2, ' ', true,
- nlohmann::json::
- error_handler_t::replace);
- return;
- }
- if (fan)
- {
- auto pid =
- std::make_shared<SetPIDValues>(asyncResp, *fan);
- pid->run();
- }
- }
+ setActiveFirmwareImage(asyncResp, *odataId);
}
- if (links)
- {
- std::optional<nlohmann::json> activeSoftwareImage;
- if (!redfish::json_util::readJson(*links, asyncResp->res,
- "ActiveSoftwareImage",
- activeSoftwareImage))
- {
- return;
- }
- if (activeSoftwareImage)
- {
- std::optional<std::string> odataId;
- if (!json_util::readJson(*activeSoftwareImage,
- asyncResp->res, "@odata.id",
- odataId))
- {
- return;
- }
-
- if (odataId)
- {
- setActiveFirmwareImage(asyncResp, *odataId);
- }
- }
- }
- if (datetime)
- {
- setDateTime(asyncResp, std::move(*datetime));
- }
- });
+ }
+ }
+ if (datetime)
+ {
+ setDateTime(asyncResp, std::move(*datetime));
+ }
+ });
}
inline void requestRoutesManagerCollection(App& app)
@@ -2328,21 +2273,21 @@
.methods(boost::beast::http::verb::get)(
[&app](const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
- {
- return;
- }
- // Collections don't include the static data added by SubRoute
- // because it has a duplicate entry for members
- asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers";
- asyncResp->res.jsonValue["@odata.type"] =
- "#ManagerCollection.ManagerCollection";
- asyncResp->res.jsonValue["Name"] = "Manager Collection";
- asyncResp->res.jsonValue["Members@odata.count"] = 1;
- nlohmann::json::array_t members;
- nlohmann::json& bmc = members.emplace_back();
- bmc["@odata.id"] = "/redfish/v1/Managers/bmc";
- asyncResp->res.jsonValue["Members"] = std::move(members);
- });
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+ // Collections don't include the static data added by SubRoute
+ // because it has a duplicate entry for members
+ asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#ManagerCollection.ManagerCollection";
+ asyncResp->res.jsonValue["Name"] = "Manager Collection";
+ asyncResp->res.jsonValue["Members@odata.count"] = 1;
+ nlohmann::json::array_t members;
+ nlohmann::json& bmc = members.emplace_back();
+ bmc["@odata.id"] = "/redfish/v1/Managers/bmc";
+ asyncResp->res.jsonValue["Members"] = std::move(members);
+ });
}
} // namespace redfish