Automation fix to delete the non functional image

Changes:
   - In previous code if user try to install the firmware which is
     non-functional but in active state then the code update skip,
     and it changes the priority to lowest and then make it
     fucntional image.
   - In new implementation, user can flash the firmware.
   - When user flash an image which is non functional on BMC,
     then these changes will delete the non functional image on BMC.
     After the deleting the non fucntional image, a fresh code update
     start with user image.

Signed-off-by: susilsi7 <susilsi7@in.ibm.com>
Change-Id: Ib4a42506614495e3c0b572d445d3858c13bfc4fc
diff --git a/extended/code_update/bmc_code_update.robot b/extended/code_update/bmc_code_update.robot
index bdb9981..e0233ad 100644
--- a/extended/code_update/bmc_code_update.robot
+++ b/extended/code_update/bmc_code_update.robot
@@ -87,6 +87,8 @@
     Pass Execution If  '${functional_version}' == '${image_version}'
     ...  The existing ${image_version} firmware is already functional.
 
+    Run Keyword And Ignore Error  Delete Only BMC Image
+
     Upload And Activate Image  ${IMAGE_FILE_PATH}
     ...  skip_if_active=${SKIP_UPDATE_IF_ACTIVE}
     OBMC Reboot (off)
@@ -271,6 +273,13 @@
     Should Not Be Empty  ${ALTERNATE_IMAGE_FILE_PATH}
 
 
+Delete Only BMC Image
+    [Documentation]  Delete a BMC image from the BMC flash chip.
+
+    ${software_object}=  Get Non Running BMC Software Object
+    Delete Image And Verify  ${software_object}  ${VERSION_PURPOSE_BMC}
+
+
 REST BMC Code Update Teardown
     [Documentation]  Do code update test teardown.