New BMC redfish library integration

Changes:
   - Use redfish_plus.py when importing Redfish instances.
   - Update bmc_redfish.py.
   - Update bmc_redfish_utility.py.
   - Update object name 'redfish' to 'Redfish'.
   - Update test setup and teardown in suites.
   - Update response error checking using valid_status_codes.
   - Fix test cases required for migration.

Change-Id: Ida154aede649d9a2bbef66d16ccf725f5ea37ed0
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/redfish/account_service/test_user_account.robot b/redfish/account_service/test_user_account.robot
index 13a1d1a..a81feb6 100644
--- a/redfish/account_service/test_user_account.robot
+++ b/redfish/account_service/test_user_account.robot
@@ -15,7 +15,7 @@
     [Documentation]  Verify Redfish account service is available.
     [Tags]  Verify_AccountService_Available
 
-    ${resp} =  redfish_utils.Get Attribute  /redfish/v1/AccountService  ServiceEnabled
+    ${resp} =  Redfish_utils.Get Attribute  /redfish/v1/AccountService  ServiceEnabled
     Should Be Equal As Strings  ${resp}  ${True}
 
 
@@ -24,11 +24,11 @@
 Test Setup Execution
     [Documentation]  Do test case setup tasks.
 
-    redfish.Login
+    Redfish.Login
 
 
 Test Teardown Execution
     [Documentation]  Do the post test teardown.
 
     FFDC On Test Case Fail
-    redfish.Logout
+    Redfish.Logout
diff --git a/redfish/dmtf_tools/Redfish-JsonSchema-ResponseValidator.robot b/redfish/dmtf_tools/Redfish-JsonSchema-ResponseValidator.robot
index d875c22..60c9e81 100644
--- a/redfish/dmtf_tools/Redfish-JsonSchema-ResponseValidator.robot
+++ b/redfish/dmtf_tools/Redfish-JsonSchema-ResponseValidator.robot
@@ -22,9 +22,9 @@
 
     Download DMTF Tool  ${rsv_dir_path}  ${rsv_github_url}
 
-    redfish.Login
+    Redfish.Login
     ${url_list}=  redfish_utils.List Request  /redfish/v1
-    redfish.Logout
+    Redfish.Logout
 
     Shell Cmd  mkdir -p logs/
 
diff --git a/redfish/managers/test_bmc_network_conf.robot b/redfish/managers/test_bmc_network_conf.robot
index 5e4b70c..6891e6e 100644
--- a/redfish/managers/test_bmc_network_conf.robot
+++ b/redfish/managers/test_bmc_network_conf.robot
@@ -37,7 +37,7 @@
     [Documentation]  Get MAC address and verify it's existence on the BMC.
     [Tags]  Get_MAC_Address_And_Verify
 
-    ${resp}=  redfish.Get  ${REDFISH_NW_ETH0_URI}
+    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH0_URI}
     ${macaddr}=  Get From Dictionary  ${resp.dict}  MACAddress
     Validate MAC On BMC  ${macaddr}
 
@@ -54,7 +54,7 @@
 Test Setup Execution
     [Documentation]  Test setup execution.
 
-    redfish.Login
+    Redfish.Login
 
     @{network_configurations}=  Get Network Configuration
     Set Test Variable  @{network_configurations}
@@ -96,7 +96,7 @@
     #    "VLANId": 0
     #  }
 
-    ${resp}=  redfish.Get  ${REDFISH_NW_ETH0_URI}
+    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH0_URI}
     @{network_configurations}=  Get From Dictionary  ${resp.dict}  IPv4Addresses
     [Return]  @{network_configurations}
 
@@ -162,4 +162,4 @@
     [Documentation]  Test teardown execution.
 
     FFDC On Test Case Fail
-    redfish.Logout
+    Redfish.Logout
diff --git a/redfish/managers/test_managers_bmc.robot b/redfish/managers/test_managers_bmc.robot
index 3c65884..9f2f29b 100644
--- a/redfish/managers/test_managers_bmc.robot
+++ b/redfish/managers/test_managers_bmc.robot
@@ -4,8 +4,8 @@
 Resource         ../../lib/common_utils.robot
 Resource         ../../lib/openbmc_ffdc.robot
 
-Test Teardown    FFDC On Test Case Fail
-Suite Teardown   redfish.Logout
+Test Setup       Test Setup Execution
+Test Teardown    Redfish.Logout
 
 *** Test Cases ***
 
@@ -13,21 +13,20 @@
     [Documentation]  Get firmware version from BMC manager.
     [Tags]  Verify_Redfish_BMC_Firmware_Version
 
-    redfish.Login
-    ${resp}=  redfish.Get  /redfish/v1/Managers/bmc
+    Redfish.Login
+    ${resp}=  Redfish.Get  /redfish/v1/Managers/bmc
     Should Be Equal As Strings  ${resp.status}  ${HTTP_OK}
     ${bmc_version}=  Get BMC Version
     Should Be Equal As Strings
     ...  ${resp.dict["FirmwareVersion"]}  ${bmc_version.strip('"')}
-    redfish.Logout
 
 
 Verify Redfish BMC Manager Properties
     [Documentation]  Verify BMC managers resource properties.
     [Tags]  Verify_Redfish_BMC_Manager_Properties
 
-    redfish.Login
-    ${resp}=  redfish.Get  /redfish/v1/Managers/bmc
+    Redfish.Login
+    ${resp}=  Redfish.Get  /redfish/v1/Managers/bmc
     Should Be Equal As Strings  ${resp.status}  ${HTTP_OK}
     # Example:
     #  "Description": "Baseboard Management Controller"
@@ -44,7 +43,6 @@
     Should Be Equal As Strings  ${resp.dict["Name"]}  OpenBmc Manager
     Should Not Be Empty  ${resp.dict["UUID"]}
     Should Be Equal As Strings  ${resp.dict["PowerState"]}  On
-    redfish.Logout
 
 
 Test Redfish BMC Manager GracefulRestart
@@ -60,12 +58,24 @@
     #  "target": "/redfish/v1/Managers/bmc/Actions/Manager.Reset"
     # }
 
-    redfish.Login
+    Redfish.Login
     ${payload}=  Create Dictionary  ResetType=GracefulRestart
-    ${resp}=  redfish.Post  Managers/bmc/Actions/Manager.Reset  body=&{payload}
+    ${resp}=  Redfish.Post  Managers/bmc/Actions/Manager.Reset  body=&{payload}
     Should Be Equal As Strings  ${resp.status}  ${HTTP_OK}
 
     # TODO: Add logic to ping and check BMC online state
 
+*** Keywords ***
 
+Test Setup Execution
+    [Documentation]  Do test case setup tasks.
+
+    redfish.Login
+
+
+Test Teardown Execution
+    [Documentation]  Do the post test teardown.
+
+    FFDC On Test Case Fail
+    redfish.Logout
 
diff --git a/redfish/service_root/test_service_root.robot b/redfish/service_root/test_service_root.robot
index 23a2ea6..8aef25e 100644
--- a/redfish/service_root/test_service_root.robot
+++ b/redfish/service_root/test_service_root.robot
@@ -1,9 +1,12 @@
 *** Settings ***
+
 Resource         ../../lib/resource.robot
 Resource         ../../lib/bmc_redfish_resource.robot
 Resource         ../../lib/openbmc_ffdc.robot
 
+
 Test Teardown    FFDC On Test Case Fail
+Test Setup       Rprintn
 
 *** Test Cases ***
 
@@ -11,8 +14,8 @@
     [Documentation]  Login to BMCweb and then logout.
     [Tags]  Redfish_Login_And_Logout
 
-    redfish.Login
-    redfish.Logout
+    Redfish.Login
+    Redfish.Logout
 
 
 GET Redfish Hypermedia Without Login
@@ -30,18 +33,17 @@
     [Documentation]  Login to BMCweb and get /redfish/v1/SessionService.
     [Tags]  GET_Redfish_SessionService_Resource_With_Login
 
-    redfish.Login
-    ${resp}=  redfish.Get  /redfish/v1/SessionService
-    Should Be Equal As Strings  ${resp.status}  ${HTTP_OK}
-    redfish.Logout
+    Redfish.Login
+    ${resp}=  Redfish.Get  /redfish/v1/SessionService
+    Redfish.Logout
 
 
 GET Redfish SessionService Without Login
     [Documentation]  Get /redfish/v1/SessionService without login
     [Tags]  GET_Redfish_SessionService_Without_Login
 
-    ${resp}=  redfish.Get  /redfish/v1/SessionService
-    Should Be Equal As Strings  ${resp.status}  ${HTTP_UNAUTHORIZED}
+    ${resp}=  Redfish.Get  /redfish/v1/SessionService
+    ...  valid_status_codes=[${HTTP_UNAUTHORIZED}]
 
 
 Redfish Login Using Invalid Token
@@ -64,15 +66,17 @@
     [Documentation]  Delete a session using valid login.
     [Tags]  Delete_Redfish_Session_Using_Valid_Login
 
-    redfish.Login
+    Redfish.Login
+    Redfish.Login
 
     # Example o/p:
     # [{'@odata.id': '/redfish/v1/SessionService/Sessions/bOol3WlCI8'},
     #  {'@odata.id': '/redfish/v1/SessionService/Sessions/Yu3xFqjZr1'}]
-    ${resp_list}=  redfish_utils.List Request  /redfish/v1/SessionService/Sessions
-    redfish.Delete  ${resp_list[1]}
+    ${resp_list}=  Redfish_Utils.List Request
+    ...  /redfish/v1/SessionService/Sessions
+    Redfish.Delete  ${resp_list[1]}
 
-    ${resp}=  redfish_utils.List Request  /redfish/v1/SessionService/Sessions
+    ${resp}=  Redfish_Utils.List Request  /redfish/v1/SessionService/Sessions
     List Should Not Contain Value  ${resp}  ${resp_list[1]}
 
 
@@ -80,11 +84,12 @@
 
 GET And Verify Redfish Response
     [Documentation]  GET given resource and verfiy response.
-    [Arguments]  ${expected_response_code}  ${resource_path}
+    [Arguments]  ${valid_status_codes}  ${resource_path}
 
-    # Description of arguments:
-    # expected_response_code   Expected REST status codes.
-    # resource_path            Redfish resource URL path.
+    # Description of argument(s):
+    # valid_status_codes            A comma-separated list of acceptable
+    #                               status codes (e.g. 200).
+    # resource_path                 Redfish resource URL path.
 
-    ${resp}=  redfish.Get  ${resource_path}
-    Should Be Equal As Strings  ${resp.status}  ${expected_response_code}
+    ${resp}=  Redfish.Get  ${resource_path}
+    ...  valid_status_codes=[${valid_status_codes}]
diff --git a/redfish/service_root/test_service_root_security.robot b/redfish/service_root/test_service_root_security.robot
index f8d0e4f..ac2f482 100644
--- a/redfish/service_root/test_service_root_security.robot
+++ b/redfish/service_root/test_service_root_security.robot
@@ -4,6 +4,7 @@
 Resource         ../../lib/openbmc_ffdc.robot
 
 Test Teardown    FFDC On Test Case Fail
+Test Setup       Rprintn
 
 *** Variables ***
 
@@ -59,7 +60,7 @@
     [Tags]  Create_Multiple_Login_Sessions_And_Verify
     [Teardown]  Multiple Session Cleanup
 
-    redfish.Login
+    Redfish.Login
     # Example:
     #    {
     #      'key': 'L0XEsZAXpNdF147jJaOD',
@@ -75,10 +76,9 @@
 
     # Update the redfish session object with the first login key and location
     # and verify if it is still working.
-    redfish.Set Session Key  ${saved_session_info["key"]}
-    redfish.Set Session Location  ${saved_session_info["location"]}
-    ${resp}=  redfish.Get  ${saved_session_info["location"]}
-    Should Be Equal As Strings  ${resp.status}  ${HTTP_OK}
+    Redfish.Set Session Key  ${saved_session_info["key"]}
+    Redfish.Set Session Location  ${saved_session_info["location"]}
+    Redfish.Get  ${saved_session_info["location"]}
 
 
 Attempt Login With Expired Session
@@ -86,17 +86,16 @@
     ...   use the session.
     [Tags]  Attempt_Login_With_Expired_Session
 
-    redfish.Login
+    Redfish.Login
     ${saved_session_info}=  Get Redfish Session Info
-    redfish.Logout
+    Redfish.Logout
 
     # Attempt login with expired session.
     # By default 60 minutes of inactivity closes the session.
-    redfish.Set Session Key  ${saved_session_info["key"]}
-    redfish.Set Session Location  ${saved_session_info["location"]}
+    Redfish.Set Session Key  ${saved_session_info["key"]}
+    Redfish.Set Session Location  ${saved_session_info["location"]}
 
-    ${resp}=  redfish.Get  ${saved_session_info["location"]}
-    Should Be Equal As Strings  ${resp.status}  ${HTTP_UNAUTHORIZED}
+    Redfish.Get  ${saved_session_info["location"]}  valid_status_codes=[${HTTP_UNAUTHORIZED}]
 
 
 *** Keywords ***
@@ -111,13 +110,13 @@
     # password            The password to be used to connect to the server.
 
     ${data}=  Create Dictionary  username=${username}  password=${password}
-    Run Keyword And Expect Error  ${expected_response}  redfish.Login  ${data}
+    Run Keyword And Expect Error  ${expected_response}  Redfish.Login  ${data}
 
 
 Create New Login Session
     [Documentation]  Multiple login session keys.
 
-    redfish.Login
+    Redfish.Login
     ${session_info}=  Get Redfish Session Info
 
     # Append the session location to the list.
@@ -132,5 +131,5 @@
     FFDC On Test Case Fail
 
     :FOR  ${item}  IN  @{session_list}
-    \  redfish.Delete  ${item}
+    \  Redfish.Delete  ${item}
 
diff --git a/redfish/update_service/test_firmware_inventory.robot b/redfish/update_service/test_firmware_inventory.robot
index 0b0848f..9e26b88 100644
--- a/redfish/update_service/test_firmware_inventory.robot
+++ b/redfish/update_service/test_firmware_inventory.robot
@@ -3,7 +3,8 @@
 Resource         ../../lib/bmc_redfish_resource.robot
 Resource         ../../lib/openbmc_ffdc.robot
 
-Test Teardown    FFDC On Test Case Fail
+Test Setup       Test Setup Execution
+Test Teardown    Test Teardown Execution
 
 *** Test Cases ***
 
@@ -17,11 +18,8 @@
     # "Name": "Update Service",
     # "ServiceEnabled": true
 
-    redfish.Login
-    ${resp}=  redfish.Get  /redfish/v1/UpdateService
-    Should Be Equal As Strings  ${resp.status}  ${HTTP_OK}
+    ${resp}=  Redfish.Get  /redfish/v1/UpdateService
     Should Be Equal As Strings  ${resp.dict["ServiceEnabled"]}  ${True}
-    redfish.Logout
 
 
 Verify Redfish Software Inventory Collection
@@ -46,22 +44,17 @@
     #   "Name": "Software Inventory Collection"
     # }
 
-    redfish.Login
-    ${resp}=  redfish.Get  /redfish/v1/UpdateService/FirmwareInventory
-    Should Be Equal As Strings  ${resp.status}  ${HTTP_OK}
+    ${resp}=  Redfish.Get  /redfish/v1/UpdateService/FirmwareInventory
 
     Should Be True  ${resp.dict["Members@odata.count"]} >= ${1}
     Length Should Be  ${resp.dict["Members"]}  ${resp.dict["Members@odata.count"]}
-    redfish.Logout
 
 
 Redfish Software Inventory Status Check
     [Documentation]  Get firmware inventory entries and do health check status.
     [Tags]  Redfish_Software_Inventory_Status_Check
 
-    redfish.Login
-    ${resp}=  redfish.Get  /redfish/v1/UpdateService/FirmwareInventory
-    Should Be Equal As Strings  ${resp.status}  ${HTTP_OK}
+    ${resp}=  Redfish.Get  /redfish/v1/UpdateService/FirmwareInventory
 
     # Entries "Members@odata.count": 3,
     # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/a3522998'}
@@ -69,8 +62,7 @@
     # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/ace821ef'}
 
     :FOR  ${entry}  IN RANGE  0  ${resp.dict["Members@odata.count"]}
-    \  ${resp_resource}=  redfish.Get  ${resp.dict["Members"][${entry}]["@odata.id"]}
-    \  Should Be Equal As Strings  ${resp_resource.status}  ${HTTP_OK}
+    \  ${resp_resource}=  Redfish.Get  ${resp.dict["Members"][${entry}]["@odata.id"]}
     # Example:
     # "Status": {
     #     "Health": "OK",
@@ -80,4 +72,18 @@
     \  Should Be Equal As Strings  ${resp_resource.dict["Status"]["Health"]}  OK
     \  Should Be Equal As Strings  ${resp_resource.dict["Status"]["HealthRollup"]}  OK
     \  Should Be Equal As Strings  ${resp_resource.dict["Status"]["State"]}  Enabled
-    redfish.Logout
+
+
+*** Keywords ***
+
+Test Setup Execution
+    [Documentation]  Do test case setup tasks.
+
+    Redfish.Login
+
+
+Test Teardown Execution
+    [Documentation]  Do the post test teardown.
+
+    FFDC On Test Case Fail
+    Redfish.Logout