| #include "daemon_context.h" |
| |
| #include "one/node_entities_api.pb.h" |
| #include "one/offline_node_entities.pb.h" |
| #include "one/resolved_entities.pb.h" |
| #include "absl/base/nullability.h" |
| #include "absl/log/check.h" |
| #include "absl/log/log.h" |
| |
| namespace safepower_agent { |
| |
| void LogCondensedNodeEntities( |
| const production_msv::node_entities_proto::OfflineNodeEntityInformation& |
| info) { |
| LOG(INFO) << "offline_node_entities (condensed): " |
| << "machine_name: \"" << info.resolved_config().machine_name() |
| << "\" entity_configuration_tag: \"" |
| << info.resolved_config().entity_configuration_tag() |
| << "\" entity_tag: \"" << info.entity_tag() << "\""; |
| |
| for (const auto& [node, entity] : info.resolved_config().entities()) { |
| LOG(INFO) << "node: \"" << node << "\" hostname: \"" << entity.hostname() |
| << "\" tag: \"" << entity.tag() << "\" is_control: " |
| << (entity.node_type_info().is_control() ? "true" : "false") |
| << " os_type: " |
| << net_model_unm::proto::NodeOperatingSystemType_Name( |
| entity.node_type_info().os_type()); |
| } |
| } |
| |
| DaemonContext* DaemonContext::instance_ = nullptr; |
| |
| DaemonContext::DaemonContext() { |
| if (instance_ != nullptr) { |
| LOG(DFATAL) << "Daemon context already initialized"; |
| return; |
| } |
| instance_ = this; |
| } |
| |
| DaemonContext::~DaemonContext() { instance_ = nullptr; } |
| |
| DaemonContext& DaemonContext::Get() { |
| DCHECK(instance_ != nullptr); |
| return *instance_; |
| } |
| |
| } // namespace safepower_agent |