summaryrefslogtreecommitdiffstats
path: root/item_updater.cpp
diff options
context:
space:
mode:
authorSaqib Khan <khansa@us.ibm.com>2017-06-18 23:33:46 -0500
committerSaqib Khan <khansa@us.ibm.com>2017-07-16 19:04:28 -0500
commit167601b5dc570be6e987f2a476a44c6138eb542f (patch)
tree0c7aba722cc1df3c8e70a4450aa4a13e45e030a3 /item_updater.cpp
parent1e4a7f29458b75b9750b8a0d936855c56ed152ec (diff)
downloadopenpower-pnor-code-mgmt-167601b5dc570be6e987f2a476a44c6138eb542f.tar.gz
openpower-pnor-code-mgmt-167601b5dc570be6e987f2a476a44c6138eb542f.zip
Create Version and Activation objects for current PNOR image
On BMC boot, create the Software version and activation that points to the current PNOR version by reading: /var/lib/phosphor-software-manager/pnor/ro Resolves openbmc/openbmc#1762 Change-Id: I46ddb37491a1a230699da9f3acbd3fcff23dc538 Signed-off-by: Saqib Khan <khansa@us.ibm.com>
Diffstat (limited to 'item_updater.cpp')
-rwxr-xr-xitem_updater.cpp72
1 files changed, 38 insertions, 34 deletions
diff --git a/item_updater.cpp b/item_updater.cpp
index 3edfb0c01..7a56775d1 100755
--- a/item_updater.cpp
+++ b/item_updater.cpp
@@ -3,6 +3,7 @@
#include <fstream>
#include <phosphor-logging/log.hpp>
#include <xyz/openbmc_project/Software/Version/server.hpp>
+#include "version.hpp"
#include "config.h"
#include "item_updater.hpp"
#include "activation.hpp"
@@ -101,7 +102,9 @@ void ItemUpdater::createActivation(sdbusplus::message::message& m)
fs::path manifestPath(filePath);
manifestPath /= MANIFEST_FILE;
- auto extendedVersion = ItemUpdater::getExtendedVersion(manifestPath);
+ std::string extendedVersion = (Version::getValue(manifestPath.string(),
+ std::map<std::string, std::string>
+ {{"extended_version", ""}})).begin()->second;
activations.insert(std::make_pair(
versionId,
std::make_unique<Activation>(
@@ -123,43 +126,44 @@ void ItemUpdater::createActivation(sdbusplus::message::message& m)
return;
}
-std::string ItemUpdater::getExtendedVersion(const std::string& manifestFilePath)
+void ItemUpdater::processPNORImage()
{
- constexpr auto extendedVersionKey = "extended_version=";
- constexpr auto extendedVersionKeySize = strlen(extendedVersionKey);
- if (manifestFilePath.empty())
+ fs::path pnorTOC(PNOR_RO_ACTIVE_PATH);
+ pnorTOC /= PNOR_TOC_FILE;
+ std::ifstream efile(pnorTOC.c_str());
+ if (efile.good() != 1)
{
- log<level::ERR>("Error MANIFESTFilePath is empty");
- throw std::runtime_error("MANIFESTFilePath is empty");
- }
-
- std::string extendedVersion{};
- std::ifstream efile;
- std::string line;
- efile.exceptions(std::ifstream::failbit
- | std::ifstream::badbit
- | std::ifstream::eofbit);
-
- try
- {
- efile.open(manifestFilePath);
- while (getline(efile, line))
- {
- if (line.compare(0, extendedVersionKeySize,
- extendedVersionKey) == 0)
- {
- extendedVersion = line.substr(extendedVersionKeySize);
- break;
- }
- }
- efile.close();
- }
- catch (const std::exception& e)
- {
- log<level::ERR>("Error in reading Host MANIFEST file");
+ log<level::INFO>("Error PNOR current version is empty");
+ return;
}
- return extendedVersion;
+ auto keyValues = Version::getValue(pnorTOC.string(),
+ std::map<std::string, std::string> {{"version", ""},
+ {"extended_version", ""}});
+ std::string version = keyValues.at("version");
+ std::string extendedVersion = keyValues.at("extended_version");
+ auto id = Version::getId(version);
+ auto purpose = server::Version::VersionPurpose::Host;
+ auto path = std::string{SOFTWARE_OBJPATH} + '/' + id;
+ auto activationState = server::Activation::Activations::Active;
+ activations.insert(std::make_pair(
+ id,
+ std::make_unique<Activation>(
+ bus,
+ path,
+ *this,
+ id,
+ extendedVersion,
+ activationState)));
+ versions.insert(std::make_pair(
+ id,
+ std::make_unique<Version>(
+ bus,
+ path,
+ version,
+ purpose,
+ "")));
+ return;
}
int ItemUpdater::validateSquashFSImage(const std::string& filePath)
OpenPOWER on IntegriCloud