blob: 4a2bdc5ca48bca875fa3d36cbb5c4e09c639569f [file] [log] [blame]
#ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_FAST_SANITY_SERVICE_FRU_SERVICE_H_
#define THIRD_PARTY_MILOTIC_EXTERNAL_CC_FAST_SANITY_SERVICE_FRU_SERVICE_H_
#include <cstdint>
#include <utility>
#include <vector>
#include "absl/base/thread_annotations.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/mutex.h"
#include "grpcpp/security/auth_context.h"
#include "grpcpp/server_context.h"
#include "grpcpp/support/server_callback.h"
#include "grpcpp/support/status.h"
#include "fru_component_model.pb.h"
#include "fru_service.grpc.pb.h"
#include "app.hpp"
#include "dbus_utility.hpp" // NOLINT
#include "async_resp.hpp" // NOLINT
#include "http_request.hpp" // NOLINT
#include "zatar/bmcweb_cert_provider.h"
namespace milotic_fast_sanity {
#ifdef INTERNAL_GRPC_GEN
using FruService = ::milotic_fast_sanity::grpc_gen::FruService;
#else
using FruService = ::milotic_fast_sanity::FruService;
#endif
struct FruComponents {
absl::Mutex mutex;
std::vector<FruComponent> fru_components ABSL_GUARDED_BY(mutex);
void AddFruComponent(FruComponent&& fru_component) {
absl::MutexLock lock(&mutex);
fru_components.push_back(std::move(fru_component));
}
};
struct FruServiceOptions {
bool enable_authorization = true;
::milotic::redfish::BmcWebCertProvider *cert_provider = nullptr;
};
struct OngoingDevpathExtractionRequestCount {
absl::Mutex mutex;
uint32_t ongoing_devpath_extraction_request_count ABSL_GUARDED_BY(mutex);
explicit OngoingDevpathExtractionRequestCount(
uint32_t ongoing_devpath_extraction_request_count)
: ongoing_devpath_extraction_request_count(
ongoing_devpath_extraction_request_count) {}
};
class FruServiceImpl final : public FruService::CallbackService {
public:
explicit FruServiceImpl(App *app, const FruServiceOptions &options);
::grpc::ServerUnaryReactor *GetAllFruInfo(
::grpc::CallbackServerContext *context,
const GetAllFruInfoRequest *request,
GetAllFruInfoResponse *response) override;
void GenerateMatchedDevpathsFromRedfishPaths(
::grpc::ServerUnaryReactor &reactor, const GetAllFruInfoRequest &request,
GetAllFruInfoResponse &response);
::grpc::Status RequestIsAuthenticated(
const ::grpc::AuthContext *auth_context) const;
protected:
void RequestRedfishAndExtractDevpaths(
::grpc::ServerUnaryReactor &reactor, const GetAllFruInfoRequest &request,
GetAllFruInfoResponse &response,
absl::string_view root_chassis_location_code);
App *app_;
const bool has_trust_bundle_ = false;
};
} // namespace milotic_fast_sanity
#endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_FAST_SANITY_SERVICE_FRU_SERVICE_H_