blob: 90eee6ca60d1ad9483e444d659f8de44f320761a [file] [log] [blame] [edit]
#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_monitor.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;
// best effort to build the state monitor from the config.
void BuildFromConfig(
const safepower_agent_config::GpowerdConfig& config);
private:
absl::Status CreateRedfishUpdatePowerState(
const safepower_agent_config::StateMonitorConfig& config);
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 CreateIMCMonitors();
void InsertStateMonitors(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<std::unique_ptr<RemoteStateMonitor>> state_monitors_;
};
} // namespace safepower_agent
#endif // PRODUCTION_BORG_MGMT_NODE_PROXY_SAFEPOWER_SAFEPOWER_AGENT_BMC_STATE_MONITOR_BMC_H_