Automation fix for code update

Changes:
   - New code enhancement is to handle scenario when BMC,
     have single firmware as functional.
     these changes will skip the keyword,
     "Switch Backup Firmware Image To Functional"
   - this scenario will come when system is new or
     factory reset is performed. Then it might have
     single image only.

Change-Id: I92104261cf2aaaf5aeb7b3e89621c4b654bf2ec8
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 fafc3c5..2e1df12 100644
--- a/redfish/extended/redfish_bmc_code_update.robot
+++ b/redfish/extended/redfish_bmc_code_update.robot
@@ -62,11 +62,12 @@
 
     # 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.
+    ...  Run Keyword If  ${num_records} > 0
+    ...    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}