| #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 <string> |
| |
| #include "absl/base/thread_annotations.h" |
| #include "absl/container/flat_hash_map.h" |
| #include "absl/container/flat_hash_set.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_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 Devpath { |
| std::string part_location_context; |
| std::string service_label; |
| |
| Devpath() = default; |
| |
| Devpath(absl::string_view part_location_context, |
| absl::string_view service_label) |
| : part_location_context(part_location_context), |
| service_label(service_label) {} |
| }; |
| |
| struct PartLocationContextToServiceLabelSet { |
| absl::Mutex mutex; |
| absl::flat_hash_map<std::string, absl::flat_hash_set<std::string>> |
| part_location_context_to_service_label_set ABSL_GUARDED_BY(mutex); |
| }; |
| |
| 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_ |