Add a new query option for the effective rank order

This rank order will be changed during PSU Redundancy running,
Settings service only stores the user initial settings,
add a new option to return the current effective settings
from Redundancy service.

Tested:
With two PSUs, AC cycle the board,

// Two PSUs available
ipmitool raw 0x30 0x2E 0x05
 05 02

// Wait for 2 minutes, query the current effective order
ipmitool raw 0x30 0x2E 0x06
06 01 02

ipmitool raw 0x30 0x2E 0x03
03 00 00

// Set a new order 2,1
ipmitool raw 0x30 0x2d 0x03 0x01 0x02 0x01
 00

// Query the new order settings for several times, always 2,1
ipmitool raw 0x30 0x2E 0x03
 03 01 02 01

// Query the current effective order for several times, it changes
ipmitool raw 0x30 0x2E 0x06
 06 01 02

ipmitool raw 0x30 0x2E 0x06
 06 02 01

Change-Id: I355193ea0da18abaf0dfbb3210083614018d05a8
Signed-off-by: Yong Li <yong.b.li@linux.intel.com>
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index 1313316..43ba0fa 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -2030,11 +2030,12 @@
 
 int getCRConfig(ipmi::Context::ptr ctx, const std::string& property,
                 crConfigVariant& value,
+                const std::string& service = "xyz.openbmc_project.Settings",
                 std::chrono::microseconds timeout = ipmi::IPMI_DBUS_TIMEOUT)
 {
     boost::system::error_code ec;
     value = ctx->bus->yield_method_call<crConfigVariant>(
-        ctx->yield, ec, "xyz.openbmc_project.Settings",
+        ctx->yield, ec, service,
         "/xyz/openbmc_project/control/power_supply_redundancy",
         "org.freedesktop.DBus.Properties", "Get",
         "xyz.openbmc_project.Control.PowerSupplyRedundancy", property);
@@ -2110,7 +2111,8 @@
     rotationFeature = 2,
     rotationAlgo = 3,
     rotationPeriod = 4,
-    numOfPSU = 5
+    numOfPSU = 5,
+    rotationRankOrderEffective = 6
 };
 
 constexpr ipmi::Cc ccParameterNotSupported = 0x80;
@@ -2409,6 +2411,23 @@
             }
             return ipmi::responseSuccess(parameter, numberOfPSU);
         }
+        case crParameter::rotationRankOrderEffective:
+        {
+            if (getCRConfig(ctx, "RotationRankOrder", value,
+                            "xyz.openbmc_project.PSURedundancy"))
+            {
+                return ipmi::responseResponseError();
+            }
+            std::vector<uint8_t>* pResponse =
+                std::get_if<std::vector<uint8_t>>(&value);
+            if (!pResponse)
+            {
+                phosphor::logging::log<phosphor::logging::level::ERR>(
+                    "Error to get effective RotationRankOrder property");
+                return ipmi::responseResponseError();
+            }
+            return ipmi::responseSuccess(parameter, *pResponse);
+        }
         default:
         {
             return ipmi::response(ccParameterNotSupported);