#pragma once #include "handler_config.hpp" #include "image_handler.hpp" #include "status.hpp" #include "util.hpp" #include #include #include #include #include #include #include #include #include #include namespace ipmi_flash { class VersionBlobHandler : public blobs::GenericBlobInterface { public: struct ActionPack { /** Only file operation action supported currently */ std::unique_ptr onOpen; }; /** * Create a VersionBlobHandler. * * @param[in] configs - list of blob configurations to support */ VersionBlobHandler(std::vector>&& configs); ~VersionBlobHandler() = default; VersionBlobHandler(const VersionBlobHandler&) = delete; VersionBlobHandler& operator=(const VersionBlobHandler&) = delete; VersionBlobHandler(VersionBlobHandler&&) = default; VersionBlobHandler& operator=(VersionBlobHandler&&) = default; bool canHandleBlob(const std::string& path) override; std::vector getBlobIds() override; bool deleteBlob(const std::string& path) override; bool stat(const std::string&, blobs::BlobMeta* meta) override; bool open(uint16_t session, uint16_t flags, const std::string& path) override; std::vector read(uint16_t session, uint32_t offset, uint32_t requestedSize) override; bool write(uint16_t, uint32_t, const std::vector&) override { return false; /* not supported */ }; bool writeMeta(uint16_t, uint32_t, const std::vector&) override { return false; /* not supported */ } bool commit(uint16_t, const std::vector&) override { return false; // not supported } bool close(uint16_t session) override; bool stat(uint16_t session, blobs::BlobMeta* meta) override; bool expire(uint16_t session) override; private: struct SessionInfo; struct BlobInfo { Pinned blobId; std::unique_ptr actions; std::unique_ptr handler; std::set sessionsToUpdate; }; struct SessionInfo { BlobInfo* blob; // A cached copy of the version data shared by all clients for a single // execution of the version retrieval action. This is is null until the // TriggerableAction has completed. If the action is an error, the // shared object is nullopt. Otherwise, contains a vector of the version // data when successfully read. std::shared_ptr>> data; }; std::unordered_map> blobInfoMap; std::unordered_map> sessionInfoMap; }; } // namespace ipmi_flash