Fix for host code update when
no host image on BMC

Change-Id: Ic14372e8181087f070184807544e60920cb0dcd3
Signed-off-by: Sushil Singh <susilsi7@in.ibm.com>
diff --git a/redfish/extended/redfish_host_code_update.robot b/redfish/extended/redfish_host_code_update.robot
index b79814f..d8832b0 100644
--- a/redfish/extended/redfish_host_code_update.robot
+++ b/redfish/extended/redfish_host_code_update.robot
@@ -39,19 +39,17 @@
     Rprint Vars  image_version
 
     ${sw_inv}=  Get Functional Firmware  Host image
-    ${nonfunctional_sw_inv}=  Get Non Functional Firmware  ${sw_inv}  True
+    ${functional_sw_inv}=  Get Non Functional Firmware  ${sw_inv}  True
 
-    ${functional_version}=  Set Variable  ${nonfunctional_sw_inv['version']}
-    Rprint Vars  functional_version
+    ${num_records}=  Get Length  ${functional_sw_inv}
+
+    Run Keyword If  ${num_records} != 0  Pass Execution If  '${functional_sw_inv['version']}' == '${image_version}'
+    ...  The existing ${image_version} firmware is already functional.
 
     ${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.
-
    Print Timen  Performing firmware update ${image_version}.
 
    Redfish Update Firmware