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/bmc_state_manager_main.cpp b/bmc_state_manager_main.cpp
index 1d6f617..f574a52 100644
--- a/bmc_state_manager_main.cpp
+++ b/bmc_state_manager_main.cpp
@@ -4,20 +4,25 @@
 
 #include <sdbusplus/bus.hpp>
 
+using BMCState = sdbusplus::server::xyz::openbmc_project::state::BMC;
+
 int main()
 {
     auto bus = sdbusplus::bus::new_default();
 
     // For now, we only have one instance of the BMC
     // 0 is for the current instance
-    auto objPathInst = std::string(BMC_OBJPATH) + '0';
+    const auto* BMCName = BMCState::namespace_path::bmc;
+    const auto* objPath = BMCState::namespace_path::value;
+    std::string objPathInst =
+        sdbusplus::message::object_path(objPath) / BMCName;
 
     // Add sdbusplus ObjectManager.
     sdbusplus::server::manager_t objManager(bus, objPathInst.c_str());
 
     phosphor::state::manager::BMC manager(bus, objPathInst.c_str());
 
-    bus.request_name(BMC_BUSNAME);
+    bus.request_name(BMCState::interface);
 
     while (true)
     {
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")
     {
diff --git a/chassis_state_manager_main.cpp b/chassis_state_manager_main.cpp
index 377786e..0d169b9 100644
--- a/chassis_state_manager_main.cpp
+++ b/chassis_state_manager_main.cpp
@@ -17,6 +17,8 @@
 constexpr auto LEGACY_STATE_CHANGE_PERSIST_PATH =
     "/var/lib/phosphor-state-manager/chassisStateChangeTime";
 
+using ChassisState = sdbusplus::server::xyz::openbmc_project::state::Chassis;
+
 int main(int argc, char** argv)
 {
     size_t chassisId = 0;
@@ -41,9 +43,12 @@
 
     auto bus = sdbusplus::bus::new_default();
 
-    auto chassisBusName =
-        std::string{CHASSIS_BUSNAME} + std::to_string(chassisId);
-    auto objPathInst = std::string{CHASSIS_OBJPATH} + std::to_string(chassisId);
+    auto chassisBusName = ChassisState::interface + std::to_string(chassisId);
+    const auto* objPath = ChassisState::namespace_path::value;
+    auto chassisName = std::string(ChassisState::namespace_path::chassis) +
+                       std::to_string(chassisId);
+    std::string objPathInst =
+        sdbusplus::message::object_path(objPath) / chassisName;
 
     if (chassisId == 0)
     {
@@ -77,7 +82,7 @@
     // input id is 0.
     if (chassisId == 0)
     {
-        bus.request_name(CHASSIS_BUSNAME);
+        bus.request_name(ChassisState::interface);
     }
 
     bus.request_name(chassisBusName.c_str());
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));
             }
         }
diff --git a/host_state_manager_main.cpp b/host_state_manager_main.cpp
index a306a57..406a642 100644
--- a/host_state_manager_main.cpp
+++ b/host_state_manager_main.cpp
@@ -15,6 +15,8 @@
 constexpr auto LEGACY_HOST_STATE_PERSIST_PATH =
     "/var/lib/phosphor-state-manager/requestedHostTransition";
 
+using HostState = sdbusplus::server::xyz::openbmc_project::state::Host;
+
 int main(int argc, char** argv)
 {
     size_t hostId = 0;
@@ -41,8 +43,12 @@
 
     auto bus = sdbusplus::bus::new_default();
 
-    auto hostBusName = std::string{HOST_BUSNAME} + std::to_string(hostId);
-    auto objPathInst = std::string{HOST_OBJPATH} + std::to_string(hostId);
+    auto hostBusName = HostState::interface + std::to_string(hostId);
+    auto hostName = std::string(HostState::namespace_path::host) +
+                    std::to_string(hostId);
+    const auto* objPath = HostState::namespace_path::value;
+    std::string objPathInst =
+        sdbusplus::message::object_path(objPath) / hostName;
 
     if (hostId == 0)
     {
@@ -72,7 +78,7 @@
     // input id is 0.
     if (hostId == 0)
     {
-        bus.request_name(HOST_BUSNAME);
+        bus.request_name(HostState::interface);
     }
 
     bus.request_name(hostBusName.c_str());
diff --git a/meson.build b/meson.build
index 12daf35..981345c 100644
--- a/meson.build
+++ b/meson.build
@@ -16,24 +16,12 @@
 
 conf = configuration_data()
 conf.set_quoted(
-    'HOST_BUSNAME', get_option('host-busname'))
-conf.set_quoted(
-    'HOST_OBJPATH', get_option('host-objpath'))
-conf.set_quoted(
     'HOST_SCHED_OBJPATH', get_option('host-sched-objpath'))
 conf.set_quoted(
     'HYPERVISOR_BUSNAME', get_option('hypervisor-busname'))
 conf.set_quoted(
     'HYPERVISOR_OBJPATH', get_option('hypervisor-objpath'))
 conf.set_quoted(
-    'CHASSIS_BUSNAME', get_option('chassis-busname'))
-conf.set_quoted(
-    'CHASSIS_OBJPATH', get_option('chassis-objpath'))
-conf.set_quoted(
-    'BMC_BUSNAME', get_option('bmc-busname'))
-conf.set_quoted(
-    'BMC_OBJPATH', get_option('bmc-objpath'))
-conf.set_quoted(
     'HOST_STATE_PERSIST_PATH', get_option('host-state-persist-path'))
 conf.set_quoted(
     'POH_COUNTER_PERSIST_PATH', get_option('poh-counter-persist-path'))
@@ -41,8 +29,6 @@
     'CHASSIS_STATE_CHANGE_PERSIST_PATH', get_option('chassis-state-change-persist-path'))
 conf.set_quoted(
     'SCHEDULED_HOST_TRANSITION_PERSIST_PATH', get_option('scheduled-host-transition-persist-path'))
-conf.set_quoted(
-    'SCHEDULED_HOST_TRANSITION_BUSNAME', get_option('scheduled-host-transition-busname'))
 conf.set(
     'BOOT_COUNT_MAX_ALLOWED', get_option('boot-count-max-allowed'))
 conf.set(
diff --git a/meson.options b/meson.options
index aac32dc..e2fd0f4 100644
--- a/meson.options
+++ b/meson.options
@@ -1,18 +1,6 @@
 option('tests', type: 'feature', description: 'Build tests')
 
 option(
-    'host-busname', type: 'string',
-    value: 'xyz.openbmc_project.State.Host',
-    description: 'The Host DBus busname to own.',
-)
-
-option(
-    'host-objpath', type: 'string',
-    value: '/xyz/openbmc_project/state/host',
-    description: 'The host state manager Dbus root.',
-)
-
-option(
     'host-sched-objpath', type: 'string',
     value: '/xyz/openbmc_project/scheduled/host',
     description: 'The scheduled host Dbus root.',
@@ -31,30 +19,6 @@
 )
 
 option(
-    'chassis-busname', type: 'string',
-    value: 'xyz.openbmc_project.State.Chassis',
-    description: 'The Chassis DBus busname to own.',
-)
-
-option(
-    'chassis-objpath', type: 'string',
-    value: '/xyz/openbmc_project/state/chassis',
-    description: 'The chassis state manager Dbus root.',
-)
-
-option(
-    'bmc-busname', type: 'string',
-    value: 'xyz.openbmc_project.State.BMC',
-    description: 'The BMC DBus busname to own.',
-)
-
-option(
-    'bmc-objpath', type: 'string',
-    value: '/xyz/openbmc_project/state/bmc',
-    description: 'The bmc state manager Dbus root.',
-)
-
-option(
     'host-state-persist-path', type: 'string',
     value: '/var/lib/phosphor-state-manager/host{}-PersistData',
     description: 'Path format of file for storing requested HostState,boot progress and os status.',
@@ -90,12 +54,6 @@
     description: 'Class version to register with Cereal.',
 )
 
-option(
-    'scheduled-host-transition-busname', type: 'string',
-    value: 'xyz.openbmc_project.State.ScheduledHostTransition',
-    description: 'The scheduled host transition Dbus busname to own.',
-)
-
 option('warm-reboot', type : 'feature',
     value : 'enabled',
     description : 'Enable warm reboots of the system',
diff --git a/scheduled_host_transition.cpp b/scheduled_host_transition.cpp
index eb5975c..d2c136b 100644
--- a/scheduled_host_transition.cpp
+++ b/scheduled_host_transition.cpp
@@ -94,14 +94,18 @@
 
 void ScheduledHostTransition::hostTransition()
 {
-    auto hostPath = std::string{HOST_OBJPATH} + std::to_string(id);
+    auto hostName = std::string(HostState::namespace_path::host) +
+                    std::to_string(id);
+    std::string hostPath =
+        sdbusplus::message::object_path(HostState::namespace_path::value) /
+        hostName;
 
     auto reqTrans = convertForMessage(HostTransition::scheduledTransition());
 
     info("Trying to set requestedTransition to {REQUESTED_TRANSITION}",
          "REQUESTED_TRANSITION", reqTrans);
 
-    utils::setProperty(bus, hostPath, HOST_BUSNAME, PROPERTY_TRANSITION,
+    utils::setProperty(bus, hostPath, HostState::interface, PROPERTY_TRANSITION,
                        reqTrans);
 
     // Set RestartCause to indicate this transition is occurring due to a
@@ -111,8 +115,8 @@
         info("Set RestartCause to scheduled power on reason");
         auto resCause =
             convertForMessage(HostState::RestartCause::ScheduledPowerOn);
-        utils::setProperty(bus, hostPath, HOST_BUSNAME, PROPERTY_RESTART_CAUSE,
-                           resCause);
+        utils::setProperty(bus, hostPath, HostState::interface,
+                           PROPERTY_RESTART_CAUSE, resCause);
     }
 }
 
diff --git a/scheduled_host_transition_main.cpp b/scheduled_host_transition_main.cpp
index aaecd39..07cd47f 100644
--- a/scheduled_host_transition_main.cpp
+++ b/scheduled_host_transition_main.cpp
@@ -10,6 +10,9 @@
 #include <exception>
 #include <filesystem>
 
+using ScheduledHostTransition =
+    sdbusplus::server::xyz::openbmc_project::state::ScheduledHostTransition;
+
 int main(int argc, char** argv)
 {
     size_t hostId = 0;
@@ -60,10 +63,10 @@
     // input id is 0.
     if (hostId == 0)
     {
-        bus.request_name(SCHEDULED_HOST_TRANSITION_BUSNAME);
+        bus.request_name(ScheduledHostTransition::interface);
     }
 
-    bus.request_name((std::string{SCHEDULED_HOST_TRANSITION_BUSNAME} +
+    bus.request_name((std::string{ScheduledHostTransition::interface} +
                       std::to_string(hostId))
                          .c_str());