blob: ac4b11a347c148105e5221c03f2e1cb80142a7c8 [file] [log] [blame]
Patrick Venturebf58cd62018-12-11 09:05:46 -08001#pragma once
2
Patrick Venturea6586362018-12-11 18:47:13 -08003#include "interface.hpp"
Patrick Venture00887592018-12-11 10:57:06 -08004
Patrick Venture664c5bc2019-03-07 08:09:45 -08005#include <ipmiblob/blob_interface.hpp>
Patrick Venturebf58cd62018-12-11 09:05:46 -08006#include <string>
7
Patrick Venture9b534f02018-12-13 16:10:02 -08008namespace host_tool
9{
10
Patrick Venture55646de2019-05-16 10:06:26 -070011/** Object that actually handles the update itself. */
12class UpdateHandler
13{
14 public:
15 UpdateHandler(ipmiblob::BlobInterface* blob, DataInterface* handler) :
16 blob(blob), handler(handler)
17 {
18 }
19
20 virtual ~UpdateHandler() = default;
21
22 /**
23 * Check if the goal firmware is listed in the blob_list and that the
24 * handler's supported data type is available.
25 *
26 * @param[in] goalFirmware - the firmware to check /flash/image
27 * /flash/tarball, etc.
28 */
29 virtual bool checkAvailable(const std::string& goalFirmware);
30
31 /**
32 * Send the file contents at path to the blob id, target.
33 *
34 * @param[in] target - the blob id
35 * @param[in] path - the source file path
36 * @throw ToolException on failure.
37 */
38 virtual void sendFile(const std::string& target, const std::string& path);
39
40 /**
41 * Trigger verification.
42 *
43 * @param[in] target - the verification blob id (may support multiple in the
44 * future.
45 * @return true if verified, false if verification errors.
46 * @throw ToolException on failure (TODO: throw on timeout.)
47 */
48 virtual bool verifyFile(const std::string& target);
49
50 private:
51 ipmiblob::BlobInterface* blob;
52 DataInterface* handler;
53};
54
Patrick Venturebf58cd62018-12-11 09:05:46 -080055/**
Patrick Ventured61b0ff2019-05-15 15:58:06 -070056 * Poll an open verification session.
57 *
58 * @param[in] session - the open verification session
59 * @param[in] blob - pointer to blob interface implementation object.
60 * @return true if the verification was successul.
61 */
Patrick Venture14713be2019-06-05 13:42:28 -070062bool pollStatus(std::uint16_t session, ipmiblob::BlobInterface* blob);
Patrick Ventured61b0ff2019-05-15 15:58:06 -070063
64/**
Patrick Venturebf58cd62018-12-11 09:05:46 -080065 * Attempt to update the BMC's firmware using the interface provided.
66 *
Patrick Venture55646de2019-05-16 10:06:26 -070067 * @param[in] updater - update handler object.
Patrick Venturebf58cd62018-12-11 09:05:46 -080068 * @param[in] imagePath - the path to the image file.
69 * @param[in] signaturePath - the path to the signature file.
Patrick Venture2bc23fe2018-12-13 10:16:36 -080070 * @throws ToolException on failures.
Patrick Venturebf58cd62018-12-11 09:05:46 -080071 */
Patrick Venture55646de2019-05-16 10:06:26 -070072void updaterMain(UpdateHandler* updater, const std::string& imagePath,
Patrick Venture2bc23fe2018-12-13 10:16:36 -080073 const std::string& signaturePath);
Patrick Venture9b534f02018-12-13 16:10:02 -080074
75} // namespace host_tool