blob: e4f3e5941c2af8f0f7589b4627c93c0cdf488f8d [file] [log] [blame]
#include <exception>
#include <algorithm>
#include "defines.hpp"
#include "write.hpp"
#include "writefru.hpp"
namespace openpower
{
namespace vpd
{
namespace inventory
{
static const std::unordered_map<std::string, Fru> supportedFrus =
{
{"BMC", Fru::BMC},
{"ETHERNET", Fru::ETHERNET}
};
void write(const std::string& type,
const Store& vpdStore,
const std::string& path)
{
// Get the enum corresponding to type, and call
// appropriate write FRU method.
std::string fru = type;
std::transform(fru.begin(), fru.end(), fru.begin(),
[](unsigned char c) { return std::toupper(c); });
auto iterator = supportedFrus.find(fru);
if (supportedFrus.end() == iterator)
{
throw std::runtime_error("Unsupported FRU: " + std::move(fru));
}
else
{
switch (iterator->second)
{
case Fru::BMC:
{
writeFru<Fru::BMC>(vpdStore, path);
break;
}
case Fru::ETHERNET:
{
writeFru<Fru::ETHERNET>(vpdStore, path);
break;
}
default:
break;
}
}
}
} // inventory
} // namespace vpd
} // namespace openpower