diff options
author | Patrick Venture <venture@google.com> | 2019-06-20 13:49:06 -0700 |
---|---|---|
committer | Patrick Venture <venture@google.com> | 2019-06-20 19:44:21 -0700 |
commit | 01123b2a5030b643210d7ae4f66c7ca2f0d211f7 (patch) | |
tree | 0de399e1e5b569c1996ff781d3e6a1103f68b9d7 /tools/updater.hpp | |
parent | 03db87e481fc09f3e5ab84e8207f72a11d3ab1ea (diff) | |
download | phosphor-ipmi-flash-01123b2a5030b643210d7ae4f66c7ca2f0d211f7.tar.gz phosphor-ipmi-flash-01123b2a5030b643210d7ae4f66c7ca2f0d211f7.zip |
tools: split out the update handler
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I367ea961c98ec822d3200d101c4f5977d77e7402
Diffstat (limited to 'tools/updater.hpp')
-rw-r--r-- | tools/updater.hpp | 79 |
1 files changed, 1 insertions, 78 deletions
diff --git a/tools/updater.hpp b/tools/updater.hpp index 4352c82..b3ab947 100644 --- a/tools/updater.hpp +++ b/tools/updater.hpp @@ -1,6 +1,6 @@ #pragma once -#include "interface.hpp" +#include "handler.hpp" #include <ipmiblob/blob_interface.hpp> #include <string> @@ -8,83 +8,6 @@ namespace host_tool { -class UpdateHandlerInterface -{ - public: - virtual ~UpdateHandlerInterface() = default; - - /** - * Check if the goal firmware is listed in the blob_list and that the - * handler's supported data type is available. - * - * @param[in] goalFirmware - the firmware to check /flash/image - * /flash/tarball, etc. - */ - virtual bool checkAvailable(const std::string& goalFirmware) = 0; - - /** - * Send the file contents at path to the blob id, target. - * - * @param[in] target - the blob id - * @param[in] path - the source file path - */ - virtual void sendFile(const std::string& target, - const std::string& path) = 0; - - /** - * Trigger verification. - * - * @param[in] target - the verification blob id (may support multiple in the - * future. - * @return true if verified, false if verification errors. - */ - virtual bool verifyFile(const std::string& target) = 0; - - /** - * Cleanup the artifacts by triggering this action. - */ - virtual void cleanArtifacts() = 0; -}; - -/** Object that actually handles the update itself. */ -class UpdateHandler : public UpdateHandlerInterface -{ - public: - UpdateHandler(ipmiblob::BlobInterface* blob, DataInterface* handler) : - blob(blob), handler(handler) - { - } - - ~UpdateHandler() = default; - - bool checkAvailable(const std::string& goalFirmware) override; - - /** - * @throw ToolException on failure. - */ - void sendFile(const std::string& target, const std::string& path) override; - - /** - * @throw ToolException on failure (TODO: throw on timeout.) - */ - bool verifyFile(const std::string& target) override; - - void cleanArtifacts() override; - - private: - ipmiblob::BlobInterface* blob; - DataInterface* handler; -}; - -/** - * Poll an open verification session. - * - * @param[in] session - the open verification session - * @param[in] blob - pointer to blob interface implementation object. - * @return true if the verification was successul. - */ -bool pollStatus(std::uint16_t session, ipmiblob::BlobInterface* blob); - /** * Attempt to update the BMC's firmware using the interface provided. * |