Move Active BMC version object to item_updater.
- There needs to be only one version class for both
BMC and PNOR images. Thus removing the BMCVERSION
class and moving the functionality to MANAGER class.
Change-Id: I6dda818960588cfd9ed345fe93068531efc7a877
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
diff --git a/version.cpp b/version.cpp
index 4260a89..24f201c 100644
--- a/version.cpp
+++ b/version.cpp
@@ -72,6 +72,35 @@
return hexId.str();
}
+std::string Version::getBMCVersion()
+{
+ std::string versionKey = "VERSION_ID=";
+ std::string version{};
+ std::ifstream efile;
+ std::string line;
+ efile.open("/etc/os-release");
+
+ while (getline(efile, line))
+ {
+ if (line.substr(0, versionKey.size()).find(versionKey) !=
+ std::string::npos)
+ {
+ std::size_t pos = line.find_first_of('"') + 1;
+ version = line.substr(pos, line.find_last_of('"') - pos);
+ break;
+ }
+ }
+ efile.close();
+
+ if (version.empty())
+ {
+ log<level::ERR>("Error BMC current version is empty");
+ throw std::runtime_error("BMC current version is empty");
+ }
+
+ return version;
+}
+
} // namespace manager
} // namespace software
} // namepsace phosphor