summaryrefslogtreecommitdiff
path: root/redfish-core/lib/update_service.hpp
diff options
context:
space:
mode:
authorJames Feist <james.feist@linux.intel.com>2020-03-11 02:16:52 +0300
committerJames Feist <james.feist@linux.intel.com>2020-03-12 19:03:48 +0300
commit32898cea816973f50f1db1f415c73bb4791d1ef0 (patch)
treee14b573d93c4be50d68a3f3102d3edabd8584b55 /redfish-core/lib/update_service.hpp
parent8f52ee52148edea2fbd8d538e6fc93985fb04d36 (diff)
downloadbmcweb-32898cea816973f50f1db1f415c73bb4791d1ef0.tar.xz
task: add fwupdate support
This adds firmware update task service support. It adds a match and updates the task value when the interface changes. Tested: On successful fwupdate task was created and updated correctly. On failed fwupdate the status went to failed. Change-Id: Id12cc5d5270e8e45498b665e78601c5c30775323 Signed-off-by: James Feist <james.feist@linux.intel.com>
Diffstat (limited to 'redfish-core/lib/update_service.hpp')
-rw-r--r--redfish-core/lib/update_service.hpp72
1 files changed, 71 insertions, 1 deletions
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index a47aca2c10..3ca7721cbd 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -117,7 +117,77 @@ static void softwareInterfaceAdded(std::shared_ptr<AsyncResp> asyncResp,
activateImage(objPath.str, objInfo[0].first);
if (asyncResp)
{
- redfish::messages::success(asyncResp->res);
+ std::shared_ptr<task::TaskData> task =
+ task::TaskData::createTask(
+ [](boost::system::error_code ec,
+ sdbusplus::message::message &msg,
+ const std::shared_ptr<task::TaskData>
+ &taskData) {
+ if (ec)
+ {
+ return task::completed;
+ }
+
+ std::string iface;
+ boost::container::flat_map<
+ std::string, std::variant<std::string>>
+ values;
+ msg.read(iface, values);
+ auto findActivation =
+ values.find("Activation");
+ if (findActivation == values.end())
+ {
+ return !task::completed;
+ }
+ std::string *state =
+ std::get_if<std::string>(
+ &(findActivation->second));
+
+ if (state == nullptr)
+ {
+ taskData->messages.emplace_back(
+ messages::internalError());
+ return task::completed;
+ }
+
+ if (boost::ends_with(*state, "Invalid") ||
+ boost::ends_with(*state, "Failed"))
+ {
+ taskData->state = "Exception";
+ taskData->status = "Warning";
+ taskData->messages.emplace_back(
+ messages::invalidObject(
+ "/redfish/v1/UpdateService/"));
+ return task::completed;
+ }
+
+ if (boost::ends_with(*state, "Staged"))
+ {
+ taskData->state = "Pending";
+ return !task::completed;
+ }
+
+ if (boost::ends_with(*state, "Active"))
+ {
+ taskData->messages.emplace_back(
+ messages::success());
+ taskData->state = "Completed";
+ return task::completed;
+ }
+
+ // as firmware update often results in a
+ // reboot, the task may never "complete"
+ // unless it is an error
+
+ return !task::completed;
+ },
+ "type='signal',interface='org.freedesktop.DBus."
+ "Properties',"
+ "member='PropertiesChanged',arg0='xyz.openbmc_"
+ "project.Software.Activation',path='" +
+ objPath.str + "'");
+ task->startTimer(std::chrono::minutes(5));
+ task->populateResp(asyncResp->res);
}
fwUpdateInProgress = false;
},