Switch to Use phosphor-dbus-interface defined constants
We are redefining a lot of the constants which are already
defined in the phosphor-dbus-interface auto-generated
headers. This change switches the code to use those instead
of allowing compile time definition of those.
Allowing for compile time definition would probably break
clients who are not aware of the new paths anyway.
Tested by build a harma image and loading in qemu to test
the added interfaces are unchanged.
```
busctl introspect xyz.openbmc_project.State.BMC \
/xyz/openbmc_project/state/bmc0
busctl introspect xyz.openbmc_project.State.Host \
/xyz/openbmc_project/state/host0
busctl introspect xyz.openbmc_project.State.Chassis \
/xyz/openbmc_project/state/chassis0
```
Change-Id: Ib4c77d2789c13f509b75a2b1837ea454e53e8ae9
Signed-off-by: Amithash Prasasd <amithash@meta.com>
diff --git a/discover_system_state.cpp b/discover_system_state.cpp
index c84b511..cadaedd 100644
--- a/discover_system_state.cpp
+++ b/discover_system_state.cpp
@@ -34,6 +34,8 @@
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
using namespace sdbusplus::server::xyz::openbmc_project::control::power;
+using HostState = sdbusplus::client::xyz::openbmc_project::state::Host<>;
+using BMCState = sdbusplus::client::xyz::openbmc_project::state::BMC<>;
} // namespace manager
} // namespace state
@@ -86,7 +88,7 @@
auto bmcRebootCause =
sdbusplus::message::convert_from_string<BMC::RebootCause>(
phosphor::state::manager::utils::getProperty(
- bus, bmcPath.str, BMC_BUSNAME, "LastRebootCause"));
+ bus, bmcPath.str, BMCState::interface, "LastRebootCause"));
if (bmcRebootCause == BMC::RebootCause::PinholeReset)
{
@@ -175,11 +177,11 @@
"DELAY", powerRestoreDelaySec.count());
utils::waitBmcReady(bus, powerRestoreDelaySec);
phosphor::state::manager::utils::setProperty(
- bus, hostPath, HOST_BUSNAME, "RestartCause",
+ bus, hostPath, HostState::interface, "RestartCause",
convertForMessage(
server::Host::RestartCause::PowerPolicyAlwaysOn));
phosphor::state::manager::utils::setProperty(
- bus, hostPath, HOST_BUSNAME, "RequestedHostTransition",
+ bus, hostPath, HostState::interface, "RequestedHostTransition",
convertForMessage(server::Host::Transition::On));
}
// Always execute power on if AlwaysOn is set, otherwise check config
@@ -202,12 +204,13 @@
utils::waitBmcReady(bus, powerRestoreDelaySec);
// Read last requested state and re-request it to execute it
auto hostReqState = phosphor::state::manager::utils::getProperty(
- bus, hostPath, HOST_BUSNAME, "RequestedHostTransition");
+ bus, hostPath, HostState::interface, "RequestedHostTransition");
if (hostReqState !=
convertForMessage(server::Host::Transition::Off))
{
phosphor::state::manager::utils::setProperty(
- bus, hostPath, HOST_BUSNAME, "RequestedHostTransition",
+ bus, hostPath, HostState::interface,
+ "RequestedHostTransition",
convertForMessage(server::Host::Transition::Off));
}
}
@@ -219,18 +222,19 @@
utils::waitBmcReady(bus, powerRestoreDelaySec);
// Read last requested state and re-request it to execute it
auto hostReqState = phosphor::state::manager::utils::getProperty(
- bus, hostPath, HOST_BUSNAME, "RequestedHostTransition");
+ bus, hostPath, HostState::interface, "RequestedHostTransition");
// As long as the host transition is not 'Off' power on host state.
if (hostReqState !=
convertForMessage(server::Host::Transition::Off))
{
phosphor::state::manager::utils::setProperty(
- bus, hostPath, HOST_BUSNAME, "RestartCause",
+ bus, hostPath, HostState::interface, "RestartCause",
convertForMessage(
server::Host::RestartCause::PowerPolicyPreviousState));
phosphor::state::manager::utils::setProperty(
- bus, hostPath, HOST_BUSNAME, "RequestedHostTransition",
+ bus, hostPath, HostState::interface,
+ "RequestedHostTransition",
convertForMessage(server::Host::Transition::On));
}
}