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/chassis_check_power_status.cpp b/chassis_check_power_status.cpp
index abb03c4..cd9eae8 100644
--- a/chassis_check_power_status.cpp
+++ b/chassis_check_power_status.cpp
@@ -10,6 +10,7 @@
#include <sdbusplus/exception.hpp>
#include <sdbusplus/server.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
+#include <xyz/openbmc_project/State/Chassis/client.hpp>
#include <iostream>
#include <map>
@@ -20,9 +21,13 @@
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
+using ChassisState = sdbusplus::client::xyz::openbmc_project::state::Chassis<>;
+
int main(int argc, char** argv)
{
- std::string chassisPath = "/xyz/openbmc_project/state/chassis0";
+ size_t chassisId = 0;
+ const auto* objPath = ChassisState::namespace_path::value;
+ auto chassisBusName = ChassisState::interface + std::to_string(chassisId);
int arg;
int optIndex = 0;
@@ -34,20 +39,23 @@
switch (arg)
{
case 'c':
- chassisPath =
- std::string("/xyz/openbmc_project/state/chassis") + optarg;
+ chassisId = std::stoul(optarg);
break;
default:
break;
}
}
+ auto chassisName = std::string(ChassisState::namespace_path::chassis) +
+ std::to_string(chassisId);
+ std::string chassisPath =
+ sdbusplus::message::object_path(objPath) / chassisName;
auto bus = sdbusplus::bus::new_default();
// If the chassis power status is not good, log an error and exit with
// a non-zero rc so the system does not power on
auto currentPowerStatus = phosphor::state::manager::utils::getProperty(
- bus, chassisPath, CHASSIS_BUSNAME, "CurrentPowerStatus");
+ bus, chassisPath, ChassisState::interface, "CurrentPowerStatus");
if (currentPowerStatus !=
"xyz.openbmc_project.State.Chassis.PowerStatus.Good")
{