Added setup to remove old PNOR images before code update.
Change-Id: I668d44cecf2dd9cc72b0d3d1e938154d27c78781
Signed-off-by: Charles Paul Hofer <Charles.Hofer@ibm.com>
diff --git a/extended/code_update/code_update.py b/extended/code_update/code_update.py
index d4f838a..1569107 100644
--- a/extended/code_update/code_update.py
+++ b/extended/code_update/code_update.py
@@ -25,6 +25,28 @@
###############################################################################
+def delete_all_pnor_images():
+
+ r"""
+ Delete all PNOR images from the BMC.
+ """
+
+ status, images = keyword.run_key("Read Properties "
+ + var.SOFTWARE_VERSION_URI + "enumerate")
+ for image_name in images:
+ image_id = image_name.split('/')[-1]
+ image_purpose = images[image_name]["Purpose"]
+ if var.VERSION_PURPOSE_HOST == image_purpose:
+ # Delete twice, in case the image is in the /tmp/images directory
+ keyword.run_key("Call Method " + var.SOFTWARE_VERSION_URI
+ + image_id + " delete data={\"data\":[]}")
+ keyword.run_key("Call Method " + var.SOFTWARE_VERSION_URI
+ + image_id + " delete data={\"data\":[]}")
+
+###############################################################################
+
+
+###############################################################################
def wait_for_activation_state_change(version_id, initial_state):
r"""
diff --git a/extended/code_update/code_update.robot b/extended/code_update/code_update.robot
index 741c16b..27a274b 100644
--- a/extended/code_update/code_update.robot
+++ b/extended/code_update/code_update.robot
@@ -2,6 +2,7 @@
Documentation Code update to a target BMC.
... Execution Method:
... python -m robot -v OPENBMC_HOST:<hostname>
+... -v DELETE_OLD_PNOR_IMAGES:<"true" or "false">
... -v IMAGE_FILE_PATH:<path/*.tar> code_update.robot
...
... Code update method BMC
@@ -34,12 +35,14 @@
${activation_state} ${EMPTY}
${requested_state} ${EMPTY}
${IMAGE_FILE_PATH} ${EMPTY}
+${DELETE_OLD_PNOR_IMAGES} false
*** Test Cases ***
REST PNOR Code Update
[Documentation] Do a PNOR code update by uploading image on BMC via REST.
[Tags] REST_PNOR_Code_Update
+ [Setup] Code Update Setup
OperatingSystem.File Should Exist ${IMAGE_FILE_PATH}
${IMAGE_VERSION}= Get Version Tar ${IMAGE_FILE_PATH}
@@ -68,6 +71,12 @@
*** Keywords ***
+Code Update Setup
+ [Documentation] Do code update test case setup.
+
+ Run Keyword If 'true' == '${DELETE_OLD_PNOR_IMAGES}'
+ ... Delete All PNOR Images
+
Code Update Teardown
[Documentation] Do code update test case teardown.