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>
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 9fd1499..a735567 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -505,6 +505,49 @@
     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 @@
     }
 
     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");
 }