Correct osState string to match xyz naming format for fixing automation test

Symptom:
"Verify Dump After Host Watchdog Error Injection" automation test item failed.

Root cause:
Due to "Is OS Booted" keyword got failed in lib/state_manager.robot.

According openbmc-test-automation/lib/variables.py
The "os_state" must match to
"xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Standby".

But, "osState" string in x86-power-control just return "Standby" instead of
"xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Standby".
Thus keyword "Is OS Booted" return failed then cause test item got failed.

Reference:
openbmc-test-automation/lib/state_manager.robot:
Is OS Booted
    [Documentation]  Check OS status.
${os_state}=  Get Host State Attribute  OperatingSystemState
Should Be Equal  ${OS_BOOT_COMPLETE}  ${os_state}

openbmc-test-automation/lib/variables.py:
STATE_DBUS_BASE = 'xyz.openbmc_project.State.'
OS_BOOT_COMPLETE = STATE_DBUS_BASE + \
    'OperatingSystem.Status.OSStatus.Standby'

Solution:
Correct osState string to match xyz naming format and consistent with auto test.

Tested:
Host Power ON:
busctl call xyz.openbmc_project.State.Host /xyz/openbmc_project/state/host0 \
org.freedesktop.DBus.Properties \
GetAll s "xyz.openbmc_project.State.OperatingSystem.Status"
a{sv} 1 "OperatingSystemState" s "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Standby"

Host Power OFF:
busctl call xyz.openbmc_project.State.Host /xyz/openbmc_project/state/host0 \
org.freedesktop.DBus.Properties \
GetAll s "xyz.openbmc_project.State.OperatingSystem.Status"
"xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Inactive"

Signed-off-by: Tim Lee <timlee660101@gmail.com>
Change-Id: Ia63100a6756104a645c2d789d3b5be560a1305ff
diff --git a/src/power_control.cpp b/src/power_control.cpp
index 84160bd..b897c3b 100644
--- a/src/power_control.cpp
+++ b/src/power_control.cpp
@@ -207,6 +207,36 @@
         "xyz.openbmc_project.BeepCode", "Beep", uint8_t(beepPriority));
 }
 
+enum class OperatingSystemStateStage
+{
+    Inactive,
+    Standby,
+};
+static constexpr std::string_view
+    getOperatingSystemStateStage(const OperatingSystemStateStage stage)
+{
+    switch (stage)
+    {
+        case OperatingSystemStateStage::Inactive:
+            return "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Inactive";
+            break;
+        case OperatingSystemStateStage::Standby:
+            return "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Standby";
+            break;
+        default:
+            return "xyz.openbmc_project.State.OperatingSystem.Status.OSStatus.Inactive";
+            break;
+    }
+};
+static void setOperatingSystemState(const OperatingSystemStateStage stage)
+{
+    osIface->set_property("OperatingSystemState",
+                          std::string(getOperatingSystemStateStage(stage)));
+
+    lg2::info("Moving os state to {STATE} stage", "STATE",
+              getOperatingSystemStateStage(stage));
+}
+
 enum class PowerState
 {
     on,
@@ -1603,8 +1633,7 @@
                 // 'OperatingSystemState' to stay at 'Standby', even though
                 // system is OFF. Set 'OperatingSystemState' to 'Inactive'
                 // if HostState is trurned to OFF.
-                osIface->set_property("OperatingSystemState",
-                                      std::string("Inactive"));
+                setOperatingSystemState(OperatingSystemStateStage::Inactive);
 
                 // Set the restart cause set for this restart
                 setRestartCause();
@@ -2220,12 +2249,12 @@
     if (!state)
     {
         sendPowerControlEvent(Event::postCompleteAssert);
-        osIface->set_property("OperatingSystemState", std::string("Standby"));
+        setOperatingSystemState(OperatingSystemStateStage::Standby);
     }
     else
     {
         sendPowerControlEvent(Event::postCompleteDeAssert);
-        osIface->set_property("OperatingSystemState", std::string("Inactive"));
+        setOperatingSystemState(OperatingSystemStateStage::Inactive);
     }
 }
 
@@ -3247,17 +3276,23 @@
     // Get the initial OS state based on POST complete
     //      0: Asserted, OS state is "Standby" (ready to boot)
     //      1: De-Asserted, OS state is "Inactive"
-    std::string osState;
+    OperatingSystemStateStage osState;
     if (postCompleteConfig.type == ConfigType::GPIO)
     {
-        osState = postCompleteLine.get_value() > 0 ? "Inactive" : "Standby";
+        osState = postCompleteLine.get_value() > 0
+                      ? OperatingSystemStateStage::Inactive
+                      : OperatingSystemStateStage::Standby;
     }
     else
     {
-        osState = getProperty(postCompleteConfig) > 0 ? "Inactive" : "Standby";
+        osState = getProperty(postCompleteConfig) > 0
+                      ? OperatingSystemStateStage::Inactive
+                      : OperatingSystemStateStage::Standby;
     }
 
-    osIface->register_property("OperatingSystemState", std::string(osState));
+    osIface->register_property(
+        "OperatingSystemState",
+        std::string(getOperatingSystemStateStage(osState)));
 
     osIface->initialize();