blob: 34ae6924602765117889a3cf8b45897d4f239edc [file] [log] [blame]
#ifndef PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_BMC_STATE_MONITOR_BMC_H_
#define PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_BMC_STATE_MONITOR_BMC_H_
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include "bmc/remote_state_ping.h"
#include "safepower_agent.pb.h"
#include "safepower_agent_config.pb.h"
#include "state_updater.h"
#include "static_state.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
namespace safepower_agent {
class StateMonitorBMC {
public:
explicit StateMonitorBMC(
std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>
reactor);
~StateMonitorBMC() = default;
absl::Status BuildFromConfig(
const safepower_agent_config::GpowerdConfig& config);
private:
absl::Status CreateRedfishUpdatePowerState(std::string state_name,
std::string uri,
std::string json_key,
int collection_interval,
std::string node_entity_tag);
absl::Status CreateDbusStateMonitor(std::string state_name,
std::string dbus_path,
std::string dbus_method,
std::string dbus_interface,
std::string dbus_value,
int collection_interval);
absl::Status CreateIMCPingMonitor();
void InsertPingStateMonitor(std::string node_entity_tag,
absl::StatusOr<std::string> ip_address);
safepower_agent_proto::PowerStateSpecifier ConvertStatePowerStringToEnum(
absl::string_view state_str);
absl::Status InitializeBootnumLoader(
const safepower_agent_config::GpowerdConfig& config);
std::optional<StaticStateLoader> bootnum_loader_;
std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>> reactor_;
std::vector<PingStateMonitor> ping_state_monitors_;
};
} // namespace safepower_agent
#endif // PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_BMC_STATE_MONITOR_BMC_H_