Redfish CI code update changes

changes:
   - if FORCE_UPDATE is 0, then back up image will become functional
   - if FORCE_UPDATE is 1, then delete the back up image,
     and do fresh firmware update.

Change-Id: I7e140187aa148717e45708d65b560d530113b169
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
diff --git a/redfish/extended/redfish_bmc_code_update.robot b/redfish/extended/redfish_bmc_code_update.robot
index baea00a..191232e 100644
--- a/redfish/extended/redfish_bmc_code_update.robot
+++ b/redfish/extended/redfish_bmc_code_update.robot
@@ -46,13 +46,24 @@
     ${functional_version}=  Set Variable  ${bmc_release_info['version_id']}
     Rprint Vars  functional_version
 
+    ${post_code_update_actions}=  Get Post Boot Action
+    ${state}=  Get Pre Reboot State
+    Rprint Vars  state
+
     # Check if the existing firmware is functional.
     Pass Execution If  '${functional_version}' == '${image_version}'
     ...  The existing ${image_version} firmware is already functional.
 
-    # TODO: Replace with redfish ActiveSoftwareImage API.
-    #Run Keyword If  not ${FORCE_UPDATE}
-    #...  Activate Existing Firmware  ${image_version}
+    ${sw_inv}=  Get Functional Firmware  BMC image
+    ${nonfunctional_sw_inv}=  Get Non Functional Firmware  ${sw_inv}  False
+
+    # Redfish active software image API.
+    Run Keyword If  not ${FORCE_UPDATE}
+    ...  Run Keyword If  '${nonfunctional_sw_inv['version']}' == '${image_version}'
+    ...    Run Keywords  Switch Backup Firmware Image To Functional  AND
+    ...    Wait For Reboot  start_boot_seconds=${state['epoch_seconds']}  AND
+    ...    Redfish Verify BMC Version  ${IMAGE_FILE_PATH}  AND
+    ...    Pass Execution  The firmware ${image_version} is backup image.
 
     # Firmware inventory record of the given image version.
     ${image_info}=  Get Software Inventory State By Version  ${image_version}