Replaced REST with Redfish for below IPMI Power Reading test case

    - Test Power Reading Via IPMI Raw Command

Change-Id: I1dae323b03e23312700ea6e5609e9067c104f707
Signed-off-by: Sushma M M <sushmm99@in.ibm.com>
diff --git a/ipmi/test_ipmi_sensor.robot b/ipmi/test_ipmi_sensor.robot
index 2d636bd..c87873e 100644
--- a/ipmi/test_ipmi_sensor.robot
+++ b/ipmi/test_ipmi_sensor.robot
@@ -4,11 +4,11 @@
 Resource          ../lib/ipmi_client.robot
 Resource          ../lib/openbmc_ffdc.robot
 Library           ../lib/ipmi_utils.py
+Variables         ../data/ipmi_raw_cmd_table.py
 
-Suite Setup       Redfish.Login
-Suite Teardown    Redfish.Logout
-Test Setup        Printn
-Test Teardown     FFDC On Test Case Fail
+Test Setup        Redfish.Login
+Test Teardown     Run Keywords  FFDC On Test Case Fail  AND
+...  Redfish.Logout
 
 
 *** Variables ***
@@ -175,6 +175,16 @@
     ...  msg=Baseboard temperature above allowed threshold ${allowed_temp_diff}.
 
 
+Test Power Reading Via IPMI Raw Command
+    [Documentation]  Test power reading via IPMI raw command and verify
+    ...  using Redfish.
+    [Tags]  Test_Power_Reading_Via_IPMI_Raw_Command
+
+    IPMI Power On  stack_mode=skip
+
+    Wait Until Keyword Succeeds  2 min  30 sec  Verify Power Reading Via Raw Command
+
+
 *** Keywords ***
 
 Get Temperature Reading And Verify In Redfish
@@ -257,7 +267,6 @@
 
     ${ipmi_reading}=  Get IPMI Power Reading
 
-    Redfish.Login
     ${power}=  Redfish.Get Properties  /redfish/v1/Chassis/chassis/Power
     ${redfish_reading}=  Set Variable  ${power['PowerControl'][0]['PowerConsumedWatts']}
 
@@ -265,4 +274,31 @@
     ...  Evaluate  abs(${redfish_reading} - ${ipmi_reading['instantaneous_power_reading']})
 
     Should Be True  ${ipmi_redfish_power_diff} <= ${allowed_power_diff}
+    ...  msg=Power reading above allowed threshold ${allowed_power_diff}.
+
+
+Verify Power Reading Via Raw Command
+    [Documentation]  Get dcmi power reading via IPMI raw command.
+
+    ${ipmi_raw_output}=  Run IPMI Standard Command
+    ...  raw ${IPMI_RAW_CMD['power_reading']['Get'][0]}
+
+    ${power_reading_ipmi}=  Set Variable  ${ipmi_raw_output.split()[1]}
+    ${power_reading_ipmi}=
+    ...  Convert To Integer  0x${power_reading_ipmi}
+
+    #  Example of power reading via Redfish
+    #  "@odata.id": "/redfish/v1/Chassis/chassis/Power#/PowerControl/0",
+    #  "@odata.type": "#Power.v1_0_0.PowerControl",
+    #  "MemberId": "0",
+    #  "Name": "Chassis Power Control",
+    #  "PowerConsumedWatts": 145.0,
+
+    ${power}=  Redfish.Get Properties  /redfish/v1/Chassis/chassis/Power
+    ${redfish_reading}=  Set Variable  ${power['PowerControl'][0]['PowerConsumedWatts']}
+
+    ${ipmi_redfish_power_diff}=
+    ...  Evaluate  abs(${redfish_reading} - ${power_reading_ipmi})
+
+    Should Be True  ${ipmi_redfish_power_diff} <= ${allowed_power_diff}
     ...  msg=Power reading above allowed threshold ${allowed_power_diff}.
\ No newline at end of file