Automation fix for code update

Changes:
    - Increase the sleep time to get
      the image id.
    - Added tear down.

Tested: - Ran successfully
      redfish/update_service/
      test_redfish_bmc_code_update.robot

Change-Id: I6312825afa54dd2f70e379c9646780d4585cfc47
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
diff --git a/redfish/update_service/test_redfish_bmc_code_update.robot b/redfish/update_service/test_redfish_bmc_code_update.robot
index d0b7a19..70c9261 100644
--- a/redfish/update_service/test_redfish_bmc_code_update.robot
+++ b/redfish/update_service/test_redfish_bmc_code_update.robot
@@ -172,6 +172,7 @@
     ...              when kernel panic.
     [Tags]  Redfish_Code_Update_With_Different_Interrupted_Operation
     [Template]  Verify Redfish Code Update With Different Interrupted Operation
+    [Teardown]  Code Update Interrupted Operation Teardown
 
     # operation          count
     host_name            1
@@ -192,6 +193,30 @@
     Redfish Power Off  stack_mode=skip
 
 
+Code Update Interrupted Operation Teardown
+    [Documentation]  Code update interrupted operation teardown.
+
+    ${task_inv_dict}=  Get Task State from File
+
+    ${redfish_update_uri}=  Get Redfish Update Service URI
+
+    IF  '${TEST STATUS}' == 'FAIL'
+
+      ${task_inv}=  Check Task With Match TargetUri  ${redfish_update_uri}
+      Rprint Vars  task_inv
+
+      Wait Until Keyword Succeeds  2 min  10 sec
+      ...  Verify Task Progress State  ${task_inv}  ${task_inv_dict['TaskStarting']}
+
+      Wait Until Keyword Succeeds  5 min  10 sec
+      ...  Verify Task Progress State  ${task_inv}  ${task_inv_dict['TaskCompleted']}
+
+      Redfish BMC Reset Operation
+      Is BMC Standby
+
+    END
+
+
 Get Redfish Update Service URI
     [Documentation]  Get Redfish firmware update URI.
 
@@ -305,9 +330,20 @@
     [Arguments]  ${operation}  ${count}
 
     # Description of argument(s):
-    # operation    If host_name then change hostname.
+    # operation    Supports differnt variables.
+    #              If host_name then change hostname,
+    #              If kernel_panic then perform kernel panic,
+    #              If https_certificate then change the https certificate.
     # count        Loop count.
 
+    # Below directory is required by keyword.
+    # Redfish Update Certificate Upload In Loop
+
+    IF  '${operation}' == 'https_certificate'
+      Run  rm -r certificate_dir
+      Run  mkdir certificate_dir
+    END
+
     Run Keyword If  '${operation}' == 'host_name'
     ...    Run Configure BMC Hostname In Loop  count=${count}
     ...  ELSE IF  '${operation}' == 'kernel_panic'
@@ -365,7 +401,7 @@
     Upload Image To BMC  ${redfish_update_uri}  timeout=${600}  data=${file_bin_data}
     Log To Console   Completed image upload to BMC.
 
-    Sleep  5
+    Sleep  8
 
     ${image_id}=  Get New Image ID
     Rprint Vars  image_id