PNOR image delete fix

Logic changes is to get only the host purpose obj path.

Change-Id: I71d31d2a349b474fc9ac1f6507fc5c055744956d
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/code_update_utils.py b/lib/code_update_utils.py
index 5dd0ca7..88836d6 100644
--- a/lib/code_update_utils.py
+++ b/lib/code_update_utils.py
@@ -80,17 +80,15 @@
     Delete all PNOR images from the BMC.
     """
 
-    status, images = keyword.run_key("Read Properties  "
-                                     + var.SOFTWARE_VERSION_URI + "enumerate")
+    status, images = keyword.run_key("Get Software Objects  "
+                                     + var.VERSION_PURPOSE_HOST)
     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\":[]}")
+        BuiltIn().log_to_console(image_name)
+        # Delete twice, in case the image is in the /tmp/images directory
+        keyword.run_key("Call Method  " + image_name
+                        + "  delete  data={\"data\":[]}")
+        keyword.run_key("Call Method  " + image_name
+                        + "  delete  data={\"data\":[]}")
 
 ###############################################################################
 
@@ -311,4 +309,4 @@
             BuiltIn().fail('Found invalid BMC Image: ' + image_dir)
         time.sleep(30)
 
-###############################################################################
\ No newline at end of file
+###############################################################################