1*01123b2aSPatrick Venture #pragma once 2*01123b2aSPatrick Venture 3*01123b2aSPatrick Venture #include "interface.hpp" 4*01123b2aSPatrick Venture 5*01123b2aSPatrick Venture #include <ipmiblob/blob_interface.hpp> 6*01123b2aSPatrick Venture #include <string> 7*01123b2aSPatrick Venture 8*01123b2aSPatrick Venture namespace host_tool 9*01123b2aSPatrick Venture { 10*01123b2aSPatrick Venture 11*01123b2aSPatrick Venture class UpdateHandlerInterface 12*01123b2aSPatrick Venture { 13*01123b2aSPatrick Venture public: 14*01123b2aSPatrick Venture virtual ~UpdateHandlerInterface() = default; 15*01123b2aSPatrick Venture 16*01123b2aSPatrick Venture /** 17*01123b2aSPatrick Venture * Check if the goal firmware is listed in the blob_list and that the 18*01123b2aSPatrick Venture * handler's supported data type is available. 19*01123b2aSPatrick Venture * 20*01123b2aSPatrick Venture * @param[in] goalFirmware - the firmware to check /flash/image 21*01123b2aSPatrick Venture * /flash/tarball, etc. 22*01123b2aSPatrick Venture */ 23*01123b2aSPatrick Venture virtual bool checkAvailable(const std::string& goalFirmware) = 0; 24*01123b2aSPatrick Venture 25*01123b2aSPatrick Venture /** 26*01123b2aSPatrick Venture * Send the file contents at path to the blob id, target. 27*01123b2aSPatrick Venture * 28*01123b2aSPatrick Venture * @param[in] target - the blob id 29*01123b2aSPatrick Venture * @param[in] path - the source file path 30*01123b2aSPatrick Venture */ 31*01123b2aSPatrick Venture virtual void sendFile(const std::string& target, 32*01123b2aSPatrick Venture const std::string& path) = 0; 33*01123b2aSPatrick Venture 34*01123b2aSPatrick Venture /** 35*01123b2aSPatrick Venture * Trigger verification. 36*01123b2aSPatrick Venture * 37*01123b2aSPatrick Venture * @param[in] target - the verification blob id (may support multiple in the 38*01123b2aSPatrick Venture * future. 39*01123b2aSPatrick Venture * @return true if verified, false if verification errors. 40*01123b2aSPatrick Venture */ 41*01123b2aSPatrick Venture virtual bool verifyFile(const std::string& target) = 0; 42*01123b2aSPatrick Venture 43*01123b2aSPatrick Venture /** 44*01123b2aSPatrick Venture * Cleanup the artifacts by triggering this action. 45*01123b2aSPatrick Venture */ 46*01123b2aSPatrick Venture virtual void cleanArtifacts() = 0; 47*01123b2aSPatrick Venture }; 48*01123b2aSPatrick Venture 49*01123b2aSPatrick Venture /** Object that actually handles the update itself. */ 50*01123b2aSPatrick Venture class UpdateHandler : public UpdateHandlerInterface 51*01123b2aSPatrick Venture { 52*01123b2aSPatrick Venture public: 53*01123b2aSPatrick Venture UpdateHandler(ipmiblob::BlobInterface* blob, DataInterface* handler) : 54*01123b2aSPatrick Venture blob(blob), handler(handler) 55*01123b2aSPatrick Venture { 56*01123b2aSPatrick Venture } 57*01123b2aSPatrick Venture 58*01123b2aSPatrick Venture ~UpdateHandler() = default; 59*01123b2aSPatrick Venture 60*01123b2aSPatrick Venture bool checkAvailable(const std::string& goalFirmware) override; 61*01123b2aSPatrick Venture 62*01123b2aSPatrick Venture /** 63*01123b2aSPatrick Venture * @throw ToolException on failure. 64*01123b2aSPatrick Venture */ 65*01123b2aSPatrick Venture void sendFile(const std::string& target, const std::string& path) override; 66*01123b2aSPatrick Venture 67*01123b2aSPatrick Venture /** 68*01123b2aSPatrick Venture * @throw ToolException on failure (TODO: throw on timeout.) 69*01123b2aSPatrick Venture */ 70*01123b2aSPatrick Venture bool verifyFile(const std::string& target) override; 71*01123b2aSPatrick Venture 72*01123b2aSPatrick Venture void cleanArtifacts() override; 73*01123b2aSPatrick Venture 74*01123b2aSPatrick Venture private: 75*01123b2aSPatrick Venture ipmiblob::BlobInterface* blob; 76*01123b2aSPatrick Venture DataInterface* handler; 77*01123b2aSPatrick Venture }; 78*01123b2aSPatrick Venture 79*01123b2aSPatrick Venture } // namespace host_tool 80