summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2024-04-03 23:38:21 +0300
committerEd Tanous <ed@tanous.net>2024-04-17 20:44:22 +0300
commit6b0f66bdaa12ef09bf628f2610ea48ac14888b6f (patch)
tree1c2bbb9c40bd182272213ac75e1c771cc3379ea7 /redfish-core
parentf51393349eeb88f0d07a1800f1247f5b724b7049 (diff)
downloadbmcweb-6b0f66bdaa12ef09bf628f2610ea48ac14888b6f.tar.xz
Break out DoTftpUpdate
This refactor of code is in preparation for adding new SimpleUpdate types. Separating out TFTP helps to keep code organized. Tested: Need help here. TFTP isn't enabled a lot. Change-Id: Ifbdd4b73bb0f9c31092d729d1ec3d3f395f680b8 Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/lib/update_service.hpp78
1 files changed, 44 insertions, 34 deletions
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 9fd1499466..a735567c8e 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -505,6 +505,49 @@ inline std::optional<TftpUrl>
return TftpUrl{path, host};
}
+inline void doTftpUpdate(const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const TftpUrl& tftpUrl)
+{
+#ifndef BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE
+ messages::actionParameterNotSupported(asyncResp->res, "ImageURI",
+ tftpUrl.tftpServer);
+ return;
+#endif
+ BMCWEB_LOG_DEBUG("Server: {} File: {}", tftpUrl.tftpServer, tftpUrl.fwFile);
+
+ // Setup callback for when new software detected
+ // Give TFTP 10 minutes to complete
+ monitorForSoftwareAvailable(
+ asyncResp, req,
+ "/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate", 600);
+
+ // TFTP can take up to 10 minutes depending on image size and
+ // connection speed. Return to caller as soon as the TFTP operation
+ // has been started. The callback above will ensure the activate
+ // is started once the download has completed
+ redfish::messages::success(asyncResp->res);
+
+ // Call TFTP service
+ crow::connections::systemBus->async_method_call(
+ [](const boost::system::error_code& ec) {
+ if (ec)
+ {
+ // messages::internalError(asyncResp->res);
+ cleanUp();
+ BMCWEB_LOG_DEBUG("error_code = {}", ec);
+ BMCWEB_LOG_DEBUG("error msg = {}", ec.message());
+ }
+ else
+ {
+ BMCWEB_LOG_DEBUG("Call to DownloaViaTFTP Success");
+ }
+ },
+ "xyz.openbmc_project.Software.Download",
+ "/xyz/openbmc_project/software", "xyz.openbmc_project.Common.TFTP",
+ "DownloadViaTFTP", tftpUrl.fwFile, tftpUrl.tftpServer);
+}
+
inline void handleUpdateServiceSimpleUpdateAction(
crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
@@ -540,40 +583,7 @@ inline void handleUpdateServiceSimpleUpdateAction(
}
BMCWEB_LOG_DEBUG("Server: {} File: {}", ret->tftpServer, ret->fwFile);
-#ifndef BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE
- messages::actionParameterNotSupported(asyncResp->res, "ImageURI", imageURI);
- return;
-#endif
- // Setup callback for when new software detected
- // Give TFTP 10 minutes to complete
- monitorForSoftwareAvailable(
- asyncResp, req,
- "/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate", 600);
-
- // TFTP can take up to 10 minutes depending on image size and
- // connection speed. Return to caller as soon as the TFTP operation
- // has been started. The callback above will ensure the activate
- // is started once the download has completed
- redfish::messages::success(asyncResp->res);
-
- // Call TFTP service
- crow::connections::systemBus->async_method_call(
- [](const boost::system::error_code& ec) {
- if (ec)
- {
- // messages::internalError(asyncResp->res);
- cleanUp();
- BMCWEB_LOG_DEBUG("error_code = {}", ec);
- BMCWEB_LOG_DEBUG("error msg = {}", ec.message());
- }
- else
- {
- BMCWEB_LOG_DEBUG("Call to DownloaViaTFTP Success");
- }
- },
- "xyz.openbmc_project.Software.Download",
- "/xyz/openbmc_project/software", "xyz.openbmc_project.Common.TFTP",
- "DownloadViaTFTP", ret->fwFile, ret->tftpServer);
+ doTftpUpdate(req, asyncResp, *ret);
BMCWEB_LOG_DEBUG("Exit UpdateService.SimpleUpdate doPost");
}