summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh D. King <jdking@us.ibm.com>2017-02-21 13:37:17 -0600
committerJosh D King <jdking@us.ibm.com>2017-02-28 19:27:21 +0000
commit2b5d887852c228ceb3cf2a89521498b596954ff9 (patch)
tree49cd7973d5414b7dfdf1286d5badcd2e0f237d93
parentadaa721742d565aaf6a00cdaa25db745aa6993d5 (diff)
downloadphosphor-state-manager-2b5d887852c228ceb3cf2a89521498b596954ff9.tar.gz
phosphor-state-manager-2b5d887852c228ceb3cf2a89521498b596954ff9.zip
Resolve obmc-standby.target into a path
A slight modification to bmc_state_manager.cpp. Added a systemd call GetUnit to derive the obmc-standby.target instead of using a hard coded string such as obmc_2dstandby_2etarget. Change-Id: Ica1e1e9c327e68190e800e88c0db865922c7443f Signed-off-by: Josh D. King <jdking@us.ibm.com>
-rw-r--r--bmc_state_manager.cpp44
1 files changed, 34 insertions, 10 deletions
diff --git a/bmc_state_manager.cpp b/bmc_state_manager.cpp
index 03026ff..4559c80 100644
--- a/bmc_state_manager.cpp
+++ b/bmc_state_manager.cpp
@@ -25,27 +25,51 @@ const std::map<server::BMC::Transition, const char*> SYSTEMD_TABLE =
{server::BMC::Transition::Reboot, "reboot.target"}
};
-constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
-constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
-constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
-
+constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
+constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
+constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
constexpr auto SYSTEMD_PRP_INTERFACE = "org.freedesktop.DBus.Properties";
-constexpr auto SYSTEMD_TGT_PATH = "/org/freedesktop/systemd1/unit/"
- "obmc_2dstandby_2etarget";
void BMC::discoverInitialState()
{
sdbusplus::message::variant<std::string> currentState;
+ sdbusplus::message::object_path unitTargetPath;
auto method = this->bus.new_method_call(SYSTEMD_SERVICE,
- SYSTEMD_TGT_PATH,
- SYSTEMD_PRP_INTERFACE,
- "Get");
+ SYSTEMD_OBJ_PATH,
+ SYSTEMD_INTERFACE,
+ "GetUnit");
- method.append("org.freedesktop.systemd1.Unit", "ActiveState");
+ method.append(obmcStandbyTarget);
auto result = this->bus.call(method);
+ //Check that the bus call didn't result in an error
+ if(result.is_method_error())
+ {
+ log<level::ERR>("Error in bus call.");
+ return;
+ }
+
+ result.read(unitTargetPath);
+
+ method = this->bus.new_method_call(SYSTEMD_SERVICE,
+ static_cast<const std::string&>
+ (unitTargetPath).c_str(),
+ SYSTEMD_PRP_INTERFACE,
+ "Get");
+
+ method.append("org.freedesktop.systemd1.Unit", "ActiveState");
+
+ result = this->bus.call(method);
+
+ //Check that the bus call didn't result in an error
+ if(result.is_method_error())
+ {
+ log<level::INFO>("Error in bus call.");
+ return;
+ }
+
//Is obmc-standby.target active or inactive?
result.read(currentState);
OpenPOWER on IntegriCloud