summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--log_manager.cpp25
-rw-r--r--log_manager.hpp12
3 files changed, 37 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 9e40b41..2e4cdd1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -75,6 +75,7 @@ AC_DEFINE(OBJ_ENTRY, "/xyz/openbmc_project/logging/entry", [The log entry DBus o
AC_DEFINE(INVENTORY_ROOT, "/xyz/openbmc_project/inventory", [The inventory root.])
AC_DEFINE(CALLOUT_FWD_ASSOCIATION, "callout", [The name of the callout's forward association.])
AC_DEFINE(CALLOUT_REV_ASSOCIATION, "fault", [The name of the callout's reverse association.])
+AC_DEFINE(BMC_VERSION_FILE, "/etc/os-release", [The file that contains the BMC firmware version])
AC_ARG_VAR(YAML_DIR_TEST, [The path to the test error yaml files.])
AS_IF([test "x$YAML_DIR_TEST" == "x"], \
diff --git a/log_manager.cpp b/log_manager.cpp
index 6717a7a..641ed7b 100644
--- a/log_manager.cpp
+++ b/log_manager.cpp
@@ -446,6 +446,31 @@ void Manager::journalSync()
return;
}
+std::string Manager::readFWVersion()
+{
+ std::string version;
+ std::ifstream versionFile{BMC_VERSION_FILE};
+ std::string line;
+ static constexpr auto VERSION_ID = "VERSION_ID=";
+
+ while (std::getline(versionFile, line))
+ {
+ if (line.find(VERSION_ID) != std::string::npos)
+ {
+ auto pos = line.find_first_of('"') + 1;
+ version = line.substr(pos, line.find_last_of('"') - pos);
+ break;
+ }
+ }
+
+ if (version.empty())
+ {
+ log<level::ERR>("Unable to read BMC firmware version");
+ }
+
+ return version;
+}
+
} // namespace internal
} // namespace logging
} // namepsace phosphor
diff --git a/log_manager.hpp b/log_manager.hpp
index d62a25e..d5ca4e9 100644
--- a/log_manager.hpp
+++ b/log_manager.hpp
@@ -54,7 +54,8 @@ class Manager : public details::ServerObject<details::ManagerIface>
Manager(sdbusplus::bus::bus& bus, const char* objPath) :
details::ServerObject<details::ManagerIface>(bus, objPath),
busLog(bus),
- entryId(0){};
+ entryId(0),
+ fwVersion(readFWVersion()) {};
/*
* @fn commit()
@@ -136,6 +137,12 @@ class Manager : public details::ServerObject<details::ManagerIface>
*/
void journalSync();
+ /** @brief Reads the BMC code level
+ *
+ * @return std::string - the version string
+ */
+ static std::string readFWVersion();
+
/** @brief Persistent sdbusplus DBus bus connection. */
sdbusplus::bus::bus& busLog;
@@ -150,6 +157,9 @@ class Manager : public details::ServerObject<details::ManagerIface>
/** @brief Id of last error log entry */
uint32_t entryId;
+
+ /** @brief The BMC firmware version */
+ const std::string fwVersion;
};
} //namespace internal
OpenPOWER on IntegriCloud