Expose Get/Set BootSourceOverrideTarget via SystemRegistry Expose BootSourceOverrideTarget getter and setter in tlbmc SystemRegistry HAL to support Redfish out-of-band boot configuration. Similar to BootNext, BootSourceOverrideTarget maps to gbmc-settings backed storage for out-of-band boot configuration. - Add GetBootSourceOverrideTarget and SetBootSourceOverrideTarget to SystemRegistry interface. - Implement methods in SystemRegistryImpl delegating to SettingsManager. - Add mock methods in MockSystemRegistry. - Add unit tests in system_registry_impl_test covering default, update, and invalid ID handling. Google-Bug-Id:539553711 PiperOrigin-RevId: 982171562 Change-Id: I7eb62bdcd37c9aeae738636f0e35ba3fb88d5e6b
diff --git a/tlbmc/hal/system_registry.h b/tlbmc/hal/system_registry.h index 80ab56f..e58cff4 100644 --- a/tlbmc/hal/system_registry.h +++ b/tlbmc/hal/system_registry.h
@@ -5,6 +5,7 @@ #include <string> #include <string_view> +#include "gbmc_settings/bios_settings.pb.h" #include "absl/status/status.h" #include "absl/status/statusor.h" @@ -63,6 +64,28 @@ std::string_view boot_next) = 0; /** + * @brief Retrieves the BootSourceOverrideTarget setting for a given Redfish + * system ID. + * @param redfish_system_id The Redfish system ID, e.g. "system" or "system1" + * @return The BootSourceOverrideTarget value as an enum, or an error status + * (e.g. kNotFound). + */ + virtual absl::StatusOr<::gbmc::settings::BootSourceOverrideTarget> + GetBootSourceOverrideTarget(std::string_view redfish_system_id) = 0; + + /** + * @brief Sets the BootSourceOverrideTarget setting for a given Redfish system + * ID. + * @param redfish_system_id The Redfish system ID, e.g. "system" or "system1" + * @param boot_source_override_target The boot source override target to set. + * @return absl::OkStatus() on success, or an error status on failure. + */ + virtual absl::Status SetBootSourceOverrideTarget( + std::string_view redfish_system_id, + ::gbmc::settings::BootSourceOverrideTarget + boot_source_override_target) = 0; + + /** * @brief Retrieves the Memory Capacity (in GiB) for a given Redfish system * ID. * @param redfish_system_id The Redfish system ID, e.g. "system" or "system1"
diff --git a/tlbmc/hal/system_registry_impl.cc b/tlbmc/hal/system_registry_impl.cc index b189b72..b487daf 100644 --- a/tlbmc/hal/system_registry_impl.cc +++ b/tlbmc/hal/system_registry_impl.cc
@@ -25,6 +25,7 @@ namespace milotic_tlbmc { +using ::gbmc::settings::BootSourceOverrideTarget; using ::gbmc::settings::GbmcSettings; using ::gbmc::settings::SystemId; using ::platforms::gbmc::hal::BiosConfigRegistry; @@ -274,6 +275,23 @@ return settings_manager_->SetBiosSettingsBootNext(system_id, boot_next); } +absl::StatusOr<BootSourceOverrideTarget> +SystemRegistryImpl::GetBootSourceOverrideTarget( + std::string_view redfish_system_id) { + ECCLESIA_ASSIGN_OR_RETURN(SystemId system_id, + RedfishSystemIdToSystemId(redfish_system_id)); + return settings_manager_->GetBiosSettingsBootSourceOverrideTarget(system_id); +} + +absl::Status SystemRegistryImpl::SetBootSourceOverrideTarget( + std::string_view redfish_system_id, + BootSourceOverrideTarget boot_source_override_target) { + ECCLESIA_ASSIGN_OR_RETURN(SystemId system_id, + RedfishSystemIdToSystemId(redfish_system_id)); + return settings_manager_->SetBiosSettingsBootSourceOverrideTarget( + system_id, boot_source_override_target); +} + absl::StatusOr<uint32_t> SystemRegistryImpl::GetMemoryCapacityGib( std::string_view redfish_system_id) { if (all_registries_.bios_config == nullptr) {
diff --git a/tlbmc/hal/system_registry_impl.h b/tlbmc/hal/system_registry_impl.h index 6260a27..ab315c7 100644 --- a/tlbmc/hal/system_registry_impl.h +++ b/tlbmc/hal/system_registry_impl.h
@@ -71,6 +71,14 @@ absl::Status SetBootNext(std::string_view redfish_system_id, std::string_view boot_next) override; + absl::StatusOr<::gbmc::settings::BootSourceOverrideTarget> + GetBootSourceOverrideTarget(std::string_view redfish_system_id) override; + + absl::Status SetBootSourceOverrideTarget( + std::string_view redfish_system_id, + ::gbmc::settings::BootSourceOverrideTarget boot_source_override_target) + override; + absl::StatusOr<uint32_t> GetMemoryCapacityGib( std::string_view redfish_system_id) override;
diff --git a/tlbmc/hal/system_registry_mock.h b/tlbmc/hal/system_registry_mock.h index f536e39..64c58ee 100644 --- a/tlbmc/hal/system_registry_mock.h +++ b/tlbmc/hal/system_registry_mock.h
@@ -5,6 +5,7 @@ #include <string> #include <string_view> +#include "gbmc_settings/bios_settings.pb.h" #include <gmock/gmock.h> #include "absl/status/status.h" #include "absl/status/statusor.h" @@ -28,6 +29,11 @@ (override)); MOCK_METHOD(absl::Status, SetBootNext, (std::string_view, std::string_view), (override)); + MOCK_METHOD(absl::StatusOr<::gbmc::settings::BootSourceOverrideTarget>, + GetBootSourceOverrideTarget, (std::string_view), (override)); + MOCK_METHOD(absl::Status, SetBootSourceOverrideTarget, + (std::string_view, ::gbmc::settings::BootSourceOverrideTarget), + (override)); MOCK_METHOD(absl::StatusOr<uint32_t>, GetMemoryCapacityGib, (std::string_view), (override)); MOCK_METHOD(absl::Status, SetMemoryCapacityGib, (std::string_view, uint32_t),