List the BMC/PNOR images before code update.
Resolves openbmc/openbmc-test-automation#1198
Change-Id: I8b894377fc9955ffd3012fb53bb44947381c89c1
Signed-off-by: Sweta Potthuri <spotthur@in.ibm.com>
diff --git a/extended/code_update/bmc_code_update.robot b/extended/code_update/bmc_code_update.robot
index 2865991..88ee6e7 100644
--- a/extended/code_update/bmc_code_update.robot
+++ b/extended/code_update/bmc_code_update.robot
@@ -70,6 +70,8 @@
[Tags] REST_BMC_Code_Update
[Teardown] REST BMC Code Update Teardown
+ Run Keyword And Ignore Error List Installed Images BMC
+
Upload And Activate Image ${IMAGE_FILE_PATH}
... skip_if_active=${SKIP_UPDATE_IF_ACTIVE}
OBMC Reboot (off)
diff --git a/extended/code_update/host_code_update.robot b/extended/code_update/host_code_update.robot
index c44749d..06b36b5 100644
--- a/extended/code_update/host_code_update.robot
+++ b/extended/code_update/host_code_update.robot
@@ -49,6 +49,8 @@
[Tags] REST_Host_Code_Update
[Setup] Code Update Setup
+ Run Keyword And Ignore Error List Installed Images Host
+
Upload And Activate Image ${IMAGE_FILE_PATH}
OBMC Reboot (off)
diff --git a/lib/code_update_utils.robot b/lib/code_update_utils.robot
index fbd68b8..89c00f0 100644
--- a/lib/code_update_utils.robot
+++ b/lib/code_update_utils.robot
@@ -414,3 +414,27 @@
${value}= Read Attribute ${SOFTWARE_VERSION_URI} FieldModeEnabled
Should Be True ${value} ${1}
+
+List Installed Images
+ [Documentation] List all the installed images.
+ [Arguments] ${image_type}
+
+ # Desciption of argument(s):
+ # image_type Either "BMC" or "PNOR".
+
+ # List the installed images.
+ ${installed_images}= Get Software Objects
+ ... ${SOFTWARE_PURPOSE}.${image_type}
+
+ Run Keyword If ${installed_images} != []
+ ... Get List of Images ${installed_images}
+ ... ELSE Log No ${image_type} images are present.
+
+Get List of Images
+ [Documentation] Get List of Images
+ [Arguments] ${installed_images}
+
+ :FOR ${uri} IN @{installed_images}
+ \ ${resp}= OpenBMC Get Request ${uri}
+ \ ${json}= To JSON ${resp.content}
+ \ Log ${json}["data"]