Remove redfish login and logout from lib code

With this change, the test script caller is expected to have the
valid session before invoking the changed keywords in library.

Changes:
      - Remove login/logout from lib/bmc_redfish_utils.robot
        for power and reset operation.
      - Update impacted test suites.

Tested: To identify the impact, ran the existing test bucket and
        the result is looking good.

Change-Id: I6df69d6fcc4c38470fdb2ec3b31fb28beb726d70
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/bmc_redfish_utils.robot b/lib/bmc_redfish_utils.robot
index 0fb2c50..5936574 100644
--- a/lib/bmc_redfish_utils.robot
+++ b/lib/bmc_redfish_utils.robot
@@ -31,11 +31,9 @@
     #  }
     # }
 
-    Redfish.Login
     ${target}=  redfish_utils.Get Target Actions  /redfish/v1/Systems/system/  ComputerSystem.Reset
     ${payload}=  Create Dictionary  ResetType=${reset_type}
     ${resp}=  Redfish.Post  ${target}  body=&{payload}
-    Redfish.Logout
 
 
 Redfish BMC Reset Operation
@@ -50,13 +48,9 @@
     #  "target": "/redfish/v1/Managers/bmc/Actions/Manager.Reset"
     # }
 
-    Redfish.Login
     ${target}=  redfish_utils.Get Target Actions  /redfish/v1/Managers/bmc/  Manager.Reset
     ${payload}=  Create Dictionary  ResetType=GracefulRestart
-    ${resp}=  Redfish.Post  ${target}  body=&{payload}
-    # The logout may very well fail because the system was just asked to
-    # reset itself.
-    Run Keyword And Ignore Error  Redfish.Logout
+    Redfish.Post  ${target}  body=&{payload}
 
 
 Reset BIOS Via Redfish
diff --git a/redfish/account_service/test_user_account.robot b/redfish/account_service/test_user_account.robot
index 00e19c0..e3b3d2a 100644
--- a/redfish/account_service/test_user_account.robot
+++ b/redfish/account_service/test_user_account.robot
@@ -5,6 +5,7 @@
 Resource         ../../lib/bmc_redfish_resource.robot
 Resource         ../../lib/openbmc_ffdc.robot
 
+Suite Setup      Suite Setup Execution
 Test Setup       Test Setup Execution
 Test Teardown    Test Teardown Execution
 
@@ -33,7 +34,6 @@
 
     # Reboot BMC.
     Redfish OBMC Reboot (off)  stack_mode=normal
-    Redfish.Login
 
     # Verify users after reboot.
     Redfish Verify User  admin_user     TestPwd123  Administrator   ${True}
@@ -487,3 +487,9 @@
 
     # Delete newly created user.
     Redfish.Delete  /redfish/v1/AccountService/Accounts/${username}
+
+
+Suite Setup Execution
+    [Documentation]  Do test case setup tasks.
+
+    Redfish.Login
diff --git a/redfish/extended/redfish_bmc_code_update.robot b/redfish/extended/redfish_bmc_code_update.robot
index 921ae1a..1cadb6e 100644
--- a/redfish/extended/redfish_bmc_code_update.robot
+++ b/redfish/extended/redfish_bmc_code_update.robot
@@ -121,9 +121,7 @@
     ...  ${SOFTWARE_VERSION_URI}${software_inventory['image_id']}
     ...  Priority  ${least_priority}
 
-    # Reboot BMC And Login
     Redfish OBMC Reboot (off)
-    Redfish.Login
 
 
 Redfish Update Firmware
diff --git a/redfish/systems/test_power_operations.robot b/redfish/systems/test_power_operations.robot
index d61f547..a6431a5 100644
--- a/redfish/systems/test_power_operations.robot
+++ b/redfish/systems/test_power_operations.robot
@@ -36,7 +36,6 @@
     # TODO: Replace OCC state check with redfish property when available.
     Verify OCC State
 
-    Redfish.Login
     ${power_control}=  Redfish.Get Attribute  ${REDFISH_CHASSIS_POWER_URI}  PowerControl
     Rprint Vars   power_control
     Valid Dict  power_control[${0}]  ['PowerConsumedWatts']
@@ -72,7 +71,6 @@
     ${sol_log}=    Stop SOL Console Logging
     Log   ${sol_log}
 
-    Redfish.Login
     Run Keyword If  ${REDFISH_SUPPORTED}
     ...    Redfish Set Auto Reboot  RetryAttempts
     ...  ELSE
diff --git a/redfish/systems/test_systems_inventory.robot b/redfish/systems/test_systems_inventory.robot
index dbbc833..606cf09 100755
--- a/redfish/systems/test_systems_inventory.robot
+++ b/redfish/systems/test_systems_inventory.robot
@@ -159,7 +159,6 @@
     [Tags]  Check_GPU_States_When_Power_Off
 
     Redfish Power Off
-    Redfish.Login
     GPU State Check
 
 
@@ -245,8 +244,8 @@
 Suite Setup Execution
     [Documentation]  Do test case setup tasks.
 
-    Redfish Power On  stack_mode=skip
     Redfish.Login
+    Redfish Power On  stack_mode=skip
 
     ${cpu_info}  ${gpu_info}  ${power_supplies}=  Get Inventory URIs