diff options
| author | Patrick Venture <venture@google.com> | 2019-07-19 14:46:08 -0700 |
|---|---|---|
| committer | Patrick Venture <venture@google.com> | 2019-07-19 14:56:34 -0700 |
| commit | 1871fe94afce02af08ef06e5c452784ff2f052c2 (patch) | |
| tree | 733a7fe4247925bb4f78c33ad10ae488ac4ad257 /bmc | |
| parent | a6b4abde923cc6803823b4496b2ec4a2bdadf0f9 (diff) | |
| download | phosphor-ipmi-flash-1871fe94afce02af08ef06e5c452784ff2f052c2.tar.gz phosphor-ipmi-flash-1871fe94afce02af08ef06e5c452784ff2f052c2.zip | |
bmc: use json for configuration
Use a json file for configuration of the flash image.
Tested: Verified that /flash/image worked as expected.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I205978203360140870f0e68208912a894e00a6fc
Diffstat (limited to 'bmc')
| -rw-r--r-- | bmc/main.cpp | 89 |
1 files changed, 10 insertions, 79 deletions
diff --git a/bmc/main.cpp b/bmc/main.cpp index 2120107..b988ab2 100644 --- a/bmc/main.cpp +++ b/bmc/main.cpp @@ -103,93 +103,24 @@ std::unique_ptr<blobs::GenericBlobInterface> createHandler(); std::unique_ptr<blobs::GenericBlobInterface> createHandler() { - /* NOTE: This is unused presently. */ - { - std::vector<ipmi_flash::HandlerConfig> configsFromJson = - ipmi_flash::BuildHandlerConfigs(ipmi_flash::jsonConfigurationPath); - - for (const auto& config : configsFromJson) - { - std::fprintf(stderr, "config loaded: %s\n", config.blobId.c_str()); - } - } - ipmi_flash::ActionMap actionPacks = {}; - { - auto bmcPack = std::make_unique<ipmi_flash::ActionPack>(); - -#ifdef ENABLE_REBOOT_UPDATE - static constexpr auto rebootTarget = "reboot.target"; - static constexpr auto rebootMode = "replace-irreversibly"; - - bmcPack->update = - ipmi_flash::SystemdUpdateMechanism::CreateSystemdUpdate( - sdbusplus::bus::new_default(), rebootTarget, rebootMode); -#else - bmcPack->update = - ipmi_flash::SystemdUpdateMechanism::CreateSystemdUpdate( - sdbusplus::bus::new_default(), UPDATE_DBUS_SERVICE); -#endif - - bmcPack->preparation = - ipmi_flash::SystemdPreparation::CreatePreparation( - sdbusplus::bus::new_default(), PREPARATION_DBUS_SERVICE); - - bmcPack->verification = - ipmi_flash::SystemdVerification::CreateVerification( - sdbusplus::bus::new_default(), VERIFY_STATUS_FILENAME, - VERIFY_DBUS_SERVICE); - - std::string bmcName; -#ifdef ENABLE_STATIC_LAYOUT - bmcName = ipmi_flash::staticLayoutBlobId; -#endif -#ifdef ENABLE_TARBALL_UBI - bmcName = ipmi_flash::ubiTarballBlobId; -#endif - - actionPacks[bmcName] = std::move(bmcPack); - } - -#ifdef ENABLE_HOST_BIOS - { - auto biosPack = std::make_unique<ipmi_flash::ActionPack>(); - - biosPack->preparation = - ipmi_flash::SystemdPreparation::CreatePreparation( - sdbusplus::bus::new_default(), PREPARATION_BIOS_TARGET); - - biosPack->verification = - ipmi_flash::SystemdVerification::CreateVerification( - sdbusplus::bus::new_default(), BIOS_VERIFY_STATUS_FILENAME, - VERIFY_BIOS_TARGET); - - biosPack->update = - ipmi_flash::SystemdUpdateMechanism::CreateSystemdUpdate( - sdbusplus::bus::new_default(), UPDATE_BIOS_TARGET); - - actionPacks[ipmi_flash::biosBlobId] = std::move(biosPack); - } -#endif + std::vector<ipmi_flash::HandlerConfig> configsFromJson = + ipmi_flash::BuildHandlerConfigs(ipmi_flash::jsonConfigurationPath); std::vector<ipmi_flash::HandlerPack> supportedFirmware; supportedFirmware.push_back(std::move(ipmi_flash::CreateFileHandlerPack( ipmi_flash::hashBlobId, HASH_FILENAME))); -#ifdef ENABLE_STATIC_LAYOUT - supportedFirmware.push_back(std::move(ipmi_flash::CreateFileHandlerPack( - ipmi_flash::staticLayoutBlobId, STATIC_HANDLER_STAGED_NAME))); -#endif -#ifdef ENABLE_TARBALL_UBI - supportedFirmware.push_back(std::move(ipmi_flash::CreateFileHandlerPack( - ipmi_flash::ubiTarballBlobId, TARBALL_STAGED_NAME))); -#endif -#ifdef ENABLE_HOST_BIOS - supportedFirmware.push_back(std::move(ipmi_flash::CreateFileHandlerPack( - ipmi_flash::biosBlobId, BIOS_STAGED_NAME))); -#endif + for (auto& config : configsFromJson) + { + supportedFirmware.push_back(std::move( + ipmi_flash::HandlerPack(config.blobId, std::move(config.handler)))); + actionPacks[config.blobId] = std::move(config.actions); + + std::fprintf(stderr, "config loaded: %s\n", config.blobId.c_str()); + } auto handler = ipmi_flash::FirmwareBlobHandler::CreateFirmwareBlobHandler( std::move(supportedFirmware), ipmi_flash::supportedTransports, |

