Replaced REST with Redfish for IPMI ambient temperature test case

Change-Id: I1e6b3ccf4418c82ce05d4731d503fdcd9bcdb270
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 aa16e37..e2d4c46 100644
--- a/ipmi/test_ipmi_sensor.robot
+++ b/ipmi/test_ipmi_sensor.robot
@@ -9,6 +9,11 @@
 Test Setup        Printn
 Test Teardown     FFDC On Test Case Fail
 
+
+*** Variables ***
+${allowed_temp_diff}    ${1}
+
+
 *** Test Cases ***
 
 Verify IPMI Temperature Readings using Redfish
@@ -30,6 +35,66 @@
     DCMI            pcie       pcie
     DCMI            ambient    ambient
 
+
+Test Ambient Temperature Via IPMI
+    [Documentation]  Test ambient temperature via IPMI and verify using Redfish.
+    [Tags]  Test_Ambient_Temperature_Via_IPMI
+
+    # Example of IPMI dcmi get_temp_reading output:
+    #        Entity ID                       Entity Instance    Temp. Readings
+    # Inlet air temperature(40h)                      1               +19 C
+    # CPU temperature sensors(41h)                    5               +51 C
+    # CPU temperature sensors(41h)                    6               +50 C
+    # CPU temperature sensors(41h)                    7               +50 C
+    # CPU temperature sensors(41h)                    8               +50 C
+    # CPU temperature sensors(41h)                    9               +50 C
+    # CPU temperature sensors(41h)                    10              +48 C
+    # CPU temperature sensors(41h)                    11              +49 C
+    # CPU temperature sensors(41h)                    12              +47 C
+    # CPU temperature sensors(41h)                    8               +50 C
+    # CPU temperature sensors(41h)                    16              +51 C
+    # CPU temperature sensors(41h)                    24              +50 C
+    # CPU temperature sensors(41h)                    32              +43 C
+    # CPU temperature sensors(41h)                    40              +43 C
+    # Baseboard temperature sensors(42h)              1               +35 C
+
+    ${temp_reading}=  Run IPMI Standard Command  dcmi get_temp_reading -N 10
+    Should Contain  ${temp_reading}  Inlet air temperature
+    ...  msg="Unable to get inlet temperature via DCMI".
+
+    ${ambient_temp_line}=
+    ...  Get Lines Containing String  ${temp_reading}
+    ...  Inlet air temperature  case-insensitive
+
+    ${ambient_temp_ipmi}=  Set Variable  ${ambient_temp_line.split('+')[1].strip(' C')}
+
+    # Example of ambient temperature via Redfish
+
+    #"@odata.id": "/redfish/v1/Chassis/chassis/Thermal#/Temperatures/0",
+    #"@odata.type": "#Thermal.v1_3_0.Temperature",
+    #"LowerThresholdCritical": 0.0,
+    #"LowerThresholdNonCritical": 0.0,
+    #"MaxReadingRangeTemp": 0.0,
+    #"MemberId": "ambient",
+    #"MinReadingRangeTemp": 0.0,
+    #"Name": "ambient",
+    #"ReadingCelsius": 24.987000000000002,
+    #"Status": {
+          #"Health": "OK",
+          #"State": "Enabled"
+    #},
+    #"UpperThresholdCritical": 35.0,
+    #"UpperThresholdNonCritical": 25.0
+
+    ${ambient_temp_redfish}=  Get Temperature Reading From Redfish  ambient
+
+    ${ipmi_redfish_temp_diff}=
+    ...  Evaluate  abs(${ambient_temp_redfish} - ${ambient_temp_ipmi})
+
+    Should Be True  ${ipmi_redfish_temp_diff} <= ${allowed_temp_diff}
+    ...  msg=Ambient temperature above allowed threshold ${allowed_temp_diff}.
+
+
 *** Keywords ***
 
 Get Temperature Reading And Verify In Redfish