summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2016-11-28 06:06:50 -0600
committerDeepak Kodihalli <dkodihal@in.ibm.com>2016-12-08 12:40:07 -0600
commit82c1e5665fa3a741ad4f745e69b21125e8ccb519 (patch)
treead26e6e53587a1f55a58a5c1fe536de069db1301
parent8457f8218088954921dad41dcb94678141ec935f (diff)
downloadopenpower-vpd-parser-82c1e5665fa3a741ad4f745e69b21125e8ccb519.tar.gz
openpower-vpd-parser-82c1e5665fa3a741ad4f745e69b21125e8ccb519.zip
inventory : implement VPD write
Define and implement API to write parsed OpenPOWER VPD for a FRU to the inventory. The API needs as input the FRU type, FRU object path and parsed VPD. It makes use of the inventory manager to then create the desired FRU object, populated with the VPD. Change-Id: I97ec7e1f0cd7b28b5ccb5d8e7dbeb2cad2a7093e Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
-rw-r--r--defines.hpp12
-rw-r--r--write.cpp59
-rw-r--r--write.hpp25
3 files changed, 96 insertions, 0 deletions
diff --git a/defines.hpp b/defines.hpp
index 6b0ce45..e391879 100644
--- a/defines.hpp
+++ b/defines.hpp
@@ -117,5 +117,17 @@ constexpr const char* getKeyword<Keyword::MM>()
}
} // namespace record
+
+/** @brief FRUs whose VPD we're interested in
+ *
+ * BMC The VPD on the BMC planar, for eg
+ * ETHERNET The ethernet card on the BMC
+ */
+enum Fru
+{
+ BMC,
+ ETHERNET
+};
+
} // namespace vpd
} // namespace openpower
diff --git a/write.cpp b/write.cpp
new file mode 100644
index 0000000..e4f3e59
--- /dev/null
+++ b/write.cpp
@@ -0,0 +1,59 @@
+#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
diff --git a/write.hpp b/write.hpp
new file mode 100644
index 0000000..2e7fe33
--- /dev/null
+++ b/write.hpp
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <string>
+#include <store.hpp>
+
+namespace openpower
+{
+namespace vpd
+{
+namespace inventory
+{
+
+/** @brief API to write parsed VPD to inventory
+ *
+ * @param [in] type - FRU type
+ * @param [in] vpdStore - Store object containing parsed VPD
+ * @param [in] path - FRU object path
+ */
+void write(const std::string& type,
+ const Store& vpdStore,
+ const std::string& path);
+
+} // inventory
+} // namespace vpd
+} // namespace openpower
OpenPOWER on IntegriCloud