blob: e625165db37b026270c86f3531a8bff1bf9a77eb [file] [log] [blame]
#ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_METRICS_BMC_STATIC_METRICS_H_
#define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_METRICS_BMC_STATIC_METRICS_H_
#include <memory>
#include <string>
#include <string_view>
#include "absl/status/statusor.h"
namespace milotic_tlbmc {
// This class defined all metrics that are constant for the lifetime of the BMC.
class BmcStaticMetrics {
public:
static absl::StatusOr<std::unique_ptr<BmcStaticMetrics>> Create(
std::string_view root_path = "/");
std::string GetBmcFirmwareVersion() const;
std::string GetBmcFirmwareVersionId() const;
protected:
BmcStaticMetrics() = default;
static absl::StatusOr<std::string> FetchBmcFirmwareVersion(
std::string_view root_path);
// This firmware version ID is the same as
// https://github.com/openbmc/phosphor-bmc-code-mgmt/blob/de331ae49afd6fe27271c4081ffa239746bda8b5/bmc/item_updater.cpp#L322
static absl::StatusOr<std::string> FetchBmcFirmwareVersionId(
std::string_view root_path, std::string_view bmc_firmware_version);
// BMC rofs flash id is under /run/media. There should only be one flash Id.
static absl::StatusOr<std::string> FetchBmcFirmwareFlashId(
std::string_view root_path);
private:
explicit BmcStaticMetrics(std::string_view bmc_firmware_version,
std::string_view bmc_firmware_version_id)
: bmc_firmware_version_(bmc_firmware_version),
bmc_firmware_version_id_(bmc_firmware_version_id) {}
std::string bmc_firmware_version_;
std::string bmc_firmware_version_id_;
};
} // namespace milotic_tlbmc
#endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_METRICS_BMC_STATIC_METRICS_H_