redfish code update keyword

Resolves  openbmc/openbmc-test-automation#1612

Change-Id: I9b6cea5e0b6b2424ed347ea0e6e44275baeac7c0
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/redfish/update_service/redfish_bmc_code_update.robot b/redfish/update_service/redfish_bmc_code_update.robot
new file mode 100644
index 0000000..5925af6
--- /dev/null
+++ b/redfish/update_service/redfish_bmc_code_update.robot
@@ -0,0 +1,58 @@
+*** Settings ***
+Documentation     Update the BMC code on a target BMC via Redifsh.
+
+Resource          ../../lib/resource.robot
+Resource          ../../lib/bmc_redfish_resource.robot
+Resource          ../../lib/openbmc_ffdc.robot
+Resource          ../../lib/common_utils.robot
+Resource          ../../lib/code_update_utils.robot
+Library           ../../lib/gen_robot_valid.py
+
+Suite Setup       Suite Setup Execution
+Suite Teardown    Redfish.Logout
+Test Setup        Printn
+Test Teardown     FFDC On Test Case Fail
+
+Force Tags   BMC_Code_Update
+
+*** Variables ***
+${immediate}      Immediate
+${onreset}        OnReset
+
+*** Test Cases ***
+
+Redfish BMC Code Update
+    [Documentation]  Do a BMC code update by uploading image on BMC via redfish.
+    [Tags]  Redfish_BMC_Code_Update
+
+    Set ApplyTime  policy=${onreset}
+
+    ${base_redfish_uri}=  Set Variable  ${REDFISH_BASE_URI}UpdateService
+
+    Redfish Upload Image  ${base_redfish_uri}  ${IMAGE_FILE_PATH}
+
+    ${image_id}=  Get Latest Image ID
+    Rprint Vars  image_id
+
+    Check Image Update Progress State  match_state='Disabled', 'Updating'  image_id=${image_id}
+
+    # Wait a few seconds to check if the update progress started.
+    Sleep  5s
+    Check Image Update Progress State  match_state='Updating'  image_id=${image_id}
+
+    Wait Until Keyword Succeeds  5 min  20 sec
+    ...  Check Image Update Progress State  match_state='Enabled'  image_id=${image_id}
+
+    Redfish OBMC Reboot (off)
+    Redfish.Login
+    Redfish Verify BMC Version  ${IMAGE_FILE_PATH}
+
+
+*** Keywords ***
+
+Suite Setup Execution
+    [Documentation]  Do the suite setup.
+
+    Redfish.Login
+    # Checking for file existence.
+    OperatingSystem.File Should Exist  ${IMAGE_FILE_PATH}