summaryrefslogtreecommitdiffstats
path: root/settings.cpp
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2017-08-28 06:50:51 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-09-08 18:49:51 +0000
commit13791bd5519d2fe63a4b71f48db32e03c159369a (patch)
treeee57926ade592593fb1e83b486e411693109062d /settings.cpp
parente602709d4b95895a72d77f2cda1259c2ff9b8b1b (diff)
downloadphosphor-host-ipmid-13791bd5519d2fe63a4b71f48db32e03c159369a.tar.gz
phosphor-host-ipmid-13791bd5519d2fe63a4b71f48db32e03c159369a.zip
boot settings: use the new 'one time' setting
Resolves openbmc/openbmc#2008. Change-Id: Id79d1f61a3e627fef28b071e2a415e94de14634f Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'settings.cpp')
-rw-r--r--settings.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/settings.cpp b/settings.cpp
index 59f9f33..a1ca62c 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -2,6 +2,7 @@
#include <phosphor-logging/log.hpp>
#include "xyz/openbmc_project/Common/error.hpp"
#include "settings.hpp"
+#include "utils.hpp"
namespace settings
{
@@ -90,4 +91,56 @@ Service Objects::service(const Path& path, const Interface& interface) const
return result.begin()->first;
}
+namespace boot
+{
+
+std::tuple<Path, OneTimeEnabled> setting(const Objects& objects,
+ const Interface& iface)
+{
+ constexpr auto bootObjCount = 2;
+ constexpr auto oneTime = "one_time";
+ constexpr auto enabledIntf = "xyz.openbmc_project.Object.Enable";
+
+ const std::vector<Path>& paths = objects.map.at(iface);
+ auto count = paths.size();
+ if (count != bootObjCount)
+ {
+ log<level::ERR>("Exactly two objects expected",
+ entry("INTERFACE=%s", iface.c_str()),
+ entry("COUNT=%d", count));
+ elog<InternalFailure>();
+ }
+ size_t index = 0;
+ if (std::string::npos == paths[0].rfind(oneTime))
+ {
+ index = 1;
+ }
+ const Path& oneTimeSetting = paths[index];
+ const Path& regularSetting = paths[!index];
+
+ auto method =
+ objects.bus.new_method_call(
+ objects.service(oneTimeSetting, iface).c_str(),
+ oneTimeSetting.c_str(),
+ ipmi::PROP_INTF,
+ "Get");
+ method.append(enabledIntf, "Enabled");
+ auto reply = objects.bus.call(method);
+ if (reply.is_method_error())
+ {
+ log<level::ERR>("Error in getting Enabled property",
+ entry("OBJECT=%s", oneTimeSetting.c_str()),
+ entry("INTERFACE=%s", iface.c_str()));
+ elog<InternalFailure>();
+ }
+
+ sdbusplus::message::variant<bool> enabled;
+ reply.read(enabled);
+ auto oneTimeEnabled = enabled.get<bool>();
+ const Path& setting = oneTimeEnabled ? oneTimeSetting : regularSetting;
+ return std::make_tuple(setting, oneTimeEnabled);
+}
+
+} // namespace boot
+
} // namespace settings
OpenPOWER on IntegriCloud