| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_STORE_STORE_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_STORE_STORE_H_ |
| |
| #include <memory> |
| #include <utility> |
| #include <vector> |
| |
| #include "absl/time/time.h" |
| #include "resource.pb.h" |
| #include "tlbmc/true_hitless_metrics.pb.h" |
| #include "router_interface.h" |
| #pragma GCC diagnostic push |
| #pragma GCC diagnostic warning "-Wconversion" |
| |
| #include <string> |
| |
| #include "absl/status/status.h" |
| #include "absl/status/statusor.h" |
| #include "absl/strings/string_view.h" |
| #include "nlohmann/json.hpp" |
| #include "tlbmc/collector/collector.h" |
| #include "power_control.pb.h" |
| #include "topology_config.pb.h" |
| #include "tlbmc/credentials/credential_manager.h" |
| #include "fru.pb.h" |
| #include "power_fault_log_entry.pb.h" |
| #include "software_metrics.pb.h" |
| #include "tlbmc/sensors/sensor.h" |
| #include "tlbmc/thermal/fan_pid_controller.h" |
| #include "tlbmc/thermal/pid_controller.h" |
| #include "tlbmc/thermal/stepwise_controller.h" |
| #include "tlbmc/thermal/zone_manager.h" |
| |
| namespace milotic_tlbmc { |
| |
| // Store is responsible for creating, owning and managing all the telemetry |
| // collectors and facilitating access to the data collected by collectors. |
| class Store { |
| public: |
| struct Metrics { |
| nlohmann::json ToJson() const { |
| nlohmann::json json; |
| json["ConfigParseDuration"] = absl::FormatDuration(config_parse_duration); |
| json["FruScanAndCollectorCreateDuration"] = |
| absl::FormatDuration(fru_scan_and_collector_create_duration); |
| json["TopologyConfigLoadDuration"] = |
| absl::FormatDuration(topology_config_load_duration); |
| json["SensorCollectorCreateDuration"] = |
| absl::FormatDuration(sensor_collector_create_duration); |
| json["TimeToReady"] = absl::FormatDuration(time_to_ready); |
| return json; |
| } |
| |
| // Key Time based metrics which would be tracked to catch any performance |
| // regressions. |
| absl::Duration config_parse_duration = absl::InfiniteDuration(); |
| absl::Duration fru_scan_and_collector_create_duration = |
| absl::InfiniteDuration(); |
| absl::Duration topology_config_load_duration = absl::InfiniteDuration(); |
| absl::Duration sensor_collector_create_duration = absl::InfiniteDuration(); |
| absl::Duration time_to_ready = absl::InfiniteDuration(); |
| |
| // TODO(rahulkpr): Add runtime correctable and uncorrectable errors. |
| }; |
| |
| virtual ~Store() = default; |
| |
| // Configures the tlbmc collectors. |
| // A key usage of this method is to configure the sampling interval of the |
| // data. |
| virtual absl::Status ConfigureCollection(const Collector::Config& config, |
| Collector::Type type) const = 0; |
| |
| // Returns the sorted list of sensor names contained by the given config key. |
| virtual std::vector<std::string> GetAllSensorKeysByConfigKey( |
| const std::string& board_config_key) const = 0; |
| |
| // Returns all the sensors sorted by sensor name. |
| virtual std::vector<std::shared_ptr<const Sensor>> GetAllSensors() const = 0; |
| |
| // Returns all the sensors sorted by sensor name. |
| virtual std::vector<std::string> GetAllSharedMemorySensorKeys() const = 0; |
| |
| // Returns the sensor for the given sensor key. |
| virtual std::shared_ptr<const Sensor> GetSensorBySensorKey( |
| const std::string& sensor_key) const = 0; |
| |
| // Returns the sensor for the given board config key and given sensor |
| // key. |
| virtual std::shared_ptr<const Sensor> GetSensorByConfigKeyAndSensorKey( |
| const std::string& board_config_key, |
| const std::string& sensor_key) const = 0; |
| |
| virtual absl::Status WriteToSensor(const std::string& sensor_key, |
| const SensorValue& value) = 0; |
| |
| // Returns the sensor devpath for the given sensor object. |
| virtual absl::StatusOr<const std::string&> GetDevpathFromSensor( |
| std::shared_ptr<const Sensor> sensor) const = 0; |
| |
| // FRU accessors. |
| virtual absl::StatusOr<const Fru*> GetFru(absl::string_view key) const = 0; |
| virtual absl::StatusOr<const FruTable*> GetAllFrus() const = 0; |
| virtual absl::StatusOr<const TopologyConfigNode*> GetFruTopology( |
| absl::string_view config_key) const = 0; |
| // Returns the topology config of all configs. |
| virtual absl::StatusOr<const TopologyConfig*> GetTopologyConfig() const = 0; |
| // Returns all the config keys. |
| virtual absl::StatusOr<std::vector<std::string>> GetAllConfigKeys() const = 0; |
| // Returns true if tlBMC for the given config key owns all the sensors. |
| // In this case, tlBMC will own the SensorCollection. |
| virtual bool IsConfigKeyOwningAllSensors( |
| absl::string_view config_key) const = 0; |
| // Returns the config key of the given FRU key. |
| virtual absl::StatusOr<std::string> GetConfigKeyByFruKey( |
| absl::string_view fru_key) const = 0; |
| virtual absl::StatusOr<std::string> GetFruKeyByConfigKey( |
| absl::string_view config_key) const = 0; |
| // Returns the fan info of the given config key. (fan_id, fan_key) |
| // fan_id: the name of the fan. |
| // fan_key: the FRU key of the fan. |
| virtual absl::StatusOr<std::vector<std::pair<std::string, std::string>>> |
| GetFanInfoByConfigKey(absl::string_view config_key) const = 0; |
| // Converts the store to a JSON object. |
| virtual nlohmann::json ToJson() const = 0; |
| // Returns the scheduler stats for the store. |
| virtual nlohmann::json GetSchedulerStats() const = 0; |
| // Returns the metrics for the store. |
| virtual Metrics GetMetrics() const = 0; |
| // Set Smart Router to let it know of any updates to store. |
| virtual void SetSmartRouter(::crow::RouterInterface* smart_router) = 0; |
| // Converts the store to a string. |
| virtual std::string ToString() const = 0; |
| |
| // Thermal control info. |
| // Returns all the thermal zones. |
| virtual absl::StatusOr<std::vector<const thermal::ZoneManager*>> |
| GetAllThermalZones() const = 0; |
| // Returns all the PID controllers. |
| virtual absl::StatusOr<std::vector<const thermal::PidController*>> |
| GetAllPidControllers() const = 0; |
| // Returns all the stepwise controllers. |
| virtual absl::StatusOr<std::vector<const thermal::StepwiseController*>> |
| GetAllStepwiseControllers() const = 0; |
| // Returns all the fan PID controllers. |
| virtual absl::StatusOr<std::vector<const thermal::FanPidController*>> |
| GetAllFanPidControllers() const = 0; |
| |
| virtual SoftwareMetricsValue GetMetricValues() const = 0; |
| |
| virtual SocketStatStates GetMetricSocketStatValues() const = 0; |
| |
| virtual NetFilterStates GetMetricNetFilterValues() const = 0; |
| |
| virtual std::string GetBmcUuid() const = 0; |
| |
| virtual std::string GetBmcFirmwareVersion() const = 0; |
| |
| virtual std::string GetBmcFirmwareVersionId() const = 0; |
| |
| virtual absl::StatusOr<std::string> GenerateCsr( |
| const CredentialManager::CsrParams& csr_params) const = 0; |
| virtual absl::Status InstallServerCert( |
| const std::string& certificate) const = 0; |
| |
| // Returns the true hitless metrics for the store. |
| virtual TrueHitlessMetrics GetTrueHitlessMetrics() const = 0; |
| |
| virtual absl::Time GetCurrentTime() const = 0; |
| |
| virtual absl::Time GetLastResetTime() const = 0; |
| |
| // Set GPIO value. Passing into gpio collector to set the value. |
| virtual absl::Status SetGpio(absl::string_view gpio_name, bool value) = 0; |
| // Set GPIO to active state. This is only used for hotswap. |
| virtual absl::Status SetGpioActive(absl::string_view gpio_name) = 0; |
| // Press GPIO for a given duration. |
| virtual absl::Status SetGpioActiveForDuration(absl::string_view gpio_name, |
| absl::Duration duration) = 0; |
| // Get GPIO value. |
| virtual absl::StatusOr<bool> GetGpio(absl::string_view gpio_name) = 0; |
| virtual absl::Status SendSystemResetRequest(absl::string_view system_id, |
| SystemResetType reset_type, |
| absl::Duration delay) = 0; |
| // Get hotswap GPIO name for AC power cycle. |
| virtual absl::StatusOr<std::string> GetHotswapGpioName() = 0; |
| |
| // Get power fault log entries. |
| virtual PowerFaultLogEntries GetPowerFaultLogEntries() const = 0; |
| |
| // Get power fault log file content. |
| virtual absl::StatusOr<std::string> GetPowerFaultLogFileContent( |
| absl::string_view folder_name, absl::string_view file_name) const = 0; |
| }; |
| |
| } // namespace milotic_tlbmc |
| |
| #pragma GCC diagnostic pop |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_TLBMC_STORE_STORE_H_ |