bmc: require at least one action pack configuration
In the event the phosphor-ipmi-flash package is added to an image with
only a default configuration, it should not register itself as a blob
handler. The default installation does not include any json
configuration files. Therefore, this lack of a configuration can be
checked at load time.
Added validation that the firmware image list contains at least two
handlers, and one is always the hash blob handler.
Added validation that the action map contains at least one action pack
configuration.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I0b2f6cded78121869e8a01290d29e420c555a16d
diff --git a/bmc/firmware_handler.cpp b/bmc/firmware_handler.cpp
index d58825e..4d06b58 100644
--- a/bmc/firmware_handler.cpp
+++ b/bmc/firmware_handler.cpp
@@ -42,16 +42,20 @@
std::vector<HandlerPack>&& firmwares,
const std::vector<DataHandlerPack>& transports, ActionMap&& actionPacks)
{
- /* There must be at least one. */
- if (!firmwares.size())
+ /* There must be at least one in addition to the hash blob handler. */
+ if (firmwares.size() < 2)
{
- log<level::ERR>("Must provide at least one firmware handler.");
+ log<level::ERR>("Must provide at least two firmware handlers.");
return nullptr;
}
if (!transports.size())
{
return nullptr;
}
+ if (actionPacks.empty())
+ {
+ return nullptr;
+ }
std::vector<std::string> blobs;
for (const auto& item : firmwares)