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
diff --git a/tests/ipmi/test_general_ipmi.robot b/tests/ipmi/test_general_ipmi.robot
index 379f367..752ae81 100755
--- a/tests/ipmi/test_general_ipmi.robot
+++ b/tests/ipmi/test_general_ipmi.robot
@@ -96,21 +96,6 @@
     ...  msg=msg=Verification failed for watchdog off check.
 
 
-Test Power Reading Via IPMI Raw Command
-    [Documentation]  Test power reading via IPMI raw command and verify
-    ...  using REST.
-    [Tags]  Test_Power_Reading_Via_IPMI_Raw_Command
-
-    # Response data structure of power reading command output via IPMI.
-    # 1        Completion Code. Refer to section 8, DCMI Completion Codes.
-    # 2        Group Extension Identification = DCh
-    # 3:4      Current Power in watts
-
-    REST Power On  stack_mode=skip  quiet=1
-
-    Wait Until Keyword Succeeds  2 min  30 sec  Verify Power Reading Via Raw Command
-
-
 Verify Get Device ID
     [Documentation]  Verify get device ID command output.
     [Tags]  Verify_Get_Device_ID
@@ -257,49 +242,6 @@
     [Return]  ${value_fetch}
 
 
-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]}
-
-    @{raw_output_list}=  Split String  ${ipmi_raw_output}  ${SPACE}
-
-    # On successful execution of raw IPMI power reading command, completion
-    # code does not come in output. So current power value will start from 2
-    # byte instead of 3.
-
-    ${power_reading_ipmi_raw_3_item}=  Get From List  ${raw_output_list}  2
-    ${power_reading_ipmi_raw_3_item}=
-    ...  Convert To Integer  0x${power_reading_ipmi_raw_3_item}
-
-    ${power_reading_rest}=  Read Attribute
-    ...  ${SENSORS_URI}power/total_power  Value
-
-    # Example of power reading via REST
-    #  "CriticalAlarmHigh": 0,
-    #  "CriticalAlarmLow": 0,
-    #  "CriticalHigh": 3100000000,
-    #  "CriticalLow": 0,
-    #  "Scale": -6,
-    #  "Unit": "xyz.openbmc_project.Sensor.Value.Unit.Watts",
-    #  "Value": 228000000,
-    #  "WarningAlarmHigh": 0,
-    #  "WarningAlarmLow": 0,
-    #  "WarningHigh": 3050000000,
-    #  "WarningLow": 0
-
-    # Get power value based on scale i.e. Value * (10 power Scale Value)
-    # e.g. from above case 228000000 * (10 power -6) = 228000000/1000000
-
-    ${power_reading_rest}=  Evaluate  ${power_reading_rest}/1000000
-    ${ipmi_rest_power_diff}=
-    ...  Evaluate  abs(${power_reading_rest} - ${power_reading_ipmi_raw_3_item})
-
-    Should Be True  ${ipmi_rest_power_diff} <= ${allowed_power_diff}
-    ...  msg=Power Reading above allowed threshold ${allowed_power_diff}.
-
-
 Set IPMI Restriction Mode
     [Documentation]  Set the IPMI restriction mode.
     [Arguments]  ${restriction_mode}