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"

Signed-off-by: susilsi7 <susilsi7@in.ibm.com>
Change-Id: I44262ed4f62f95ec99cf2832b6c96d82a91ca3c4
diff --git a/lib/redfish_code_update_utils.robot b/lib/redfish_code_update_utils.robot
index 7f82c1f..40a1595 100644
--- a/lib/redfish_code_update_utils.robot
+++ b/lib/redfish_code_update_utils.robot
@@ -135,6 +135,10 @@
     # functional_state  Functional state can be either True or False.
 
     ${resp}=  Filter Struct  ${sw_inv}  [('functional', ${functional_state})]
+
+    ${num_records}=  Get Length  ${resp}
+    Return From Keyword If  ${num_records} == ${0}  ${EMPTY}
+
     ${list_inv_dict}=  Get Dictionary Values  ${resp}
 
     [Return]  ${list_inv_dict}[0]
diff --git a/redfish/extended/redfish_bmc_code_update.robot b/redfish/extended/redfish_bmc_code_update.robot
index fafc3c5..228622e 100644
--- a/redfish/extended/redfish_bmc_code_update.robot
+++ b/redfish/extended/redfish_bmc_code_update.robot
@@ -59,10 +59,11 @@
 
     ${sw_inv}=  Get Functional Firmware  BMC image
     ${nonfunctional_sw_inv}=  Get Non Functional Firmware  ${sw_inv}  False
+    ${num_records}=  Get Length  ${nonfunctional_sw_inv}
 
     # Redfish active software image API.
     Run Keyword If  not ${FORCE_UPDATE}
-    ...  Run Keyword If  '${nonfunctional_sw_inv['version']}' == '${image_version}'
+    ...  Run Keyword If  ${num_records} > 0  AND '${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