Instantiate real SubscriptionManager in bmcweb server
This change builds the real hft backend and hooks with bmcweb server to allow full integration of hft service with bmcweb.
Tested:
blaze build and milotic tool
#tlbmc
#tlbmc-hft
PiperOrigin-RevId: 770392156
Change-Id: Id1eeba578204c05124b2121ee3582aa8346bd455
diff --git a/g3/server.cc b/g3/server.cc
index 68619c9..0a8de77 100644
--- a/g3/server.cc
+++ b/g3/server.cc
@@ -9,8 +9,10 @@
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "tlbmc/service/fru_service.h"
+#include "tlbmc/adapter/data_source.h"
#include "tlbmc/subscription/manager.h"
#include "tlbmc/subscription/manager_fake.h"
+#include "tlbmc/subscription/manager_impl.h"
#include "payload.pb.h"
#include "sensor_identifier.pb.h"
#include "sensor_payload.pb.h"
@@ -77,6 +79,7 @@
#include "tlbmc/redfish/app.h"
#include "tlbmc/redfish/request.h"
#include "tlbmc/redfish/response.h"
+#include "tlbmc/store/store_hft_adapter.h"
#include "tlbmc/trace/tracer.h"
#include "bmcweb_authorizer_singleton.h"
#include "app.hpp"
@@ -974,6 +977,8 @@
using ::milotic_hft::Payload;
using ::milotic_hft::SubscriptionManager;
using ::milotic_hft::SubscriptionManagerFake;
+ using ::milotic_hft::SubscriptionManagerImpl;
+ using ::milotic_tlbmc::StoreHftAdapter;
LOG(WARNING) << "Start gRPC server...";
LOG(WARNING) << "Initialize authorization layer...";
@@ -1032,6 +1037,25 @@
timestamped_reading->set_float_reading(1.23456789f);
fake_manager->SetFakeData(std::move(payload));
subscription_manager = std::move(fake_manager);
+ } else if (tlbmc_app != nullptr) {
+ absl::StatusOr<std::unique_ptr<milotic_hft::DataSource>> data_source =
+ milotic_tlbmc::StoreHftAdapter::Create(tlbmc_app->GetStore());
+ if (data_source.ok()) {
+ subscription_manager =
+ milotic_hft::SubscriptionManagerImpl::Create(std::move(*data_source));
+ } else {
+ LOG(ERROR) << "Failed to create hft source adapter: "
+ << data_source.status();
+ }
+ }
+
+ if (subscription_manager != nullptr && config_.enable_hft) {
+ hft_service_ = std::make_unique<milotic_hft::HftServiceImpl>(
+ milotic_hft::HftServiceOptions{
+ .cert_provider = cert_provider_.get(),
+ },
+ std::move(subscription_manager));
+ builder.RegisterService(hft_service_.get());
}
if (config_.enable_fast_sanity) {
@@ -1044,17 +1068,7 @@
LOG(WARNING) << "Fast-Sanity is enabled.";
}
- hft_service_ = std::make_unique<milotic_hft::HftServiceImpl>(
- milotic_hft::HftServiceOptions{
- .cert_provider = cert_provider_.get(),
- },
- std::move(subscription_manager));
builder.RegisterService(service_.get());
-
- if (config_.enable_hft) {
- builder.RegisterService(hft_service_.get());
- }
-
server_ = builder.BuildAndStart();
}