blob: da63b25622002d61cb92db46c58078080d2866a2 [file] [log] [blame]
#pragma once
#include "dump_entry.hpp"
#include "xyz/openbmc_project/Dump/Entry/BMC/server.hpp"
#include "xyz/openbmc_project/Dump/Entry/server.hpp"
#include "xyz/openbmc_project/Object/Delete/server.hpp"
#include "xyz/openbmc_project/Time/EpochTime/server.hpp"
#include <filesystem>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
namespace phosphor
{
namespace dump
{
namespace bmc
{
template <typename T>
using ServerObject = typename sdbusplus::server::object::object<T>;
using EntryIfaces = sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Dump::Entry::server::BMC>;
namespace fs = std::experimental::filesystem;
class Manager;
/** @class Entry
* @brief OpenBMC Dump Entry implementation.
* @details A concrete implementation for the
* xyz.openbmc_project.Dump.Entry DBus API
*/
class Entry : virtual public EntryIfaces, virtual public phosphor::dump::Entry
{
public:
Entry() = delete;
Entry(const Entry&) = delete;
Entry& operator=(const Entry&) = delete;
Entry(Entry&&) = delete;
Entry& operator=(Entry&&) = delete;
~Entry() = default;
/** @brief Constructor for the Dump Entry Object
* @param[in] bus - Bus to attach to.
* @param[in] objPath - Object path to attach to
* @param[in] dumpId - Dump id.
* @param[in] timeStamp - Dump creation timestamp
* since the epoch.
* @param[in] fileSize - Dump file size in bytes.
* @param[in] file - Name of dump file.
* @param[in] status - status of the dump.
* @param[in] parent - The dump entry's parent.
*/
Entry(sdbusplus::bus::bus& bus, const std::string& objPath, uint32_t dumpId,
uint64_t timeStamp, uint64_t fileSize, const fs::path& file,
phosphor::dump::OperationStatus status,
phosphor::dump::Manager& parent) :
EntryIfaces(bus, objPath.c_str(), true),
phosphor::dump::Entry(bus, objPath.c_str(), dumpId, timeStamp, fileSize,
status, parent),
file(file)
{
// Emit deferred signal.
this->phosphor::dump::bmc::EntryIfaces::emit_object_added();
}
/** @brief Delete this d-bus object.
*/
void delete_() override;
/** @brief Method to initiate the offload of dump
* @param[in] uri - URI to offload dump
*/
void initiateOffload(std::string uri) override;
/** @brief Method to update an existing dump entry, once the dump creation
* is completed this function will be used to update the entry which got
* created during the dump request.
* @param[in] timeStamp - Dump creation timestamp
* @param[in] fileSize - Dump file size in bytes.
* @param[in] file - Name of dump file.
*/
void update(uint64_t timeStamp, uint64_t fileSize, const fs::path& filePath)
{
elapsed(timeStamp);
size(fileSize);
// TODO: Handled dump failed case with #ibm-openbmc/2808
status(OperationStatus::Completed);
file = filePath;
// TODO: serialization of this property will be handled with
// #ibm-openbmc/2597
completedTime(timeStamp);
}
private:
/** @Dump file name */
fs::path file;
};
} // namespace bmc
} // namespace dump
} // namespace phosphor