From 13791bd5519d2fe63a4b71f48db32e03c159369a Mon Sep 17 00:00:00 2001 From: Deepak Kodihalli Date: Mon, 28 Aug 2017 06:50:51 -0500 Subject: boot settings: use the new 'one time' setting Resolves openbmc/openbmc#2008. Change-Id: Id79d1f61a3e627fef28b071e2a415e94de14634f Signed-off-by: Deepak Kodihalli --- settings.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'settings.cpp') diff --git a/settings.cpp b/settings.cpp index 59f9f33..a1ca62c 100644 --- a/settings.cpp +++ b/settings.cpp @@ -2,6 +2,7 @@ #include #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 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& paths = objects.map.at(iface); + auto count = paths.size(); + if (count != bootObjCount) + { + log("Exactly two objects expected", + entry("INTERFACE=%s", iface.c_str()), + entry("COUNT=%d", count)); + elog(); + } + 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("Error in getting Enabled property", + entry("OBJECT=%s", oneTimeSetting.c_str()), + entry("INTERFACE=%s", iface.c_str())); + elog(); + } + + sdbusplus::message::variant enabled; + reply.read(enabled); + auto oneTimeEnabled = enabled.get(); + const Path& setting = oneTimeEnabled ? oneTimeSetting : regularSetting; + return std::make_tuple(setting, oneTimeEnabled); +} + +} // namespace boot + } // namespace settings -- cgit v1.2.1