correctly handle the glance upload error (closes #232849)
authorPaul Tonelli <paul.tonelli@logilab.fr>
Mon, 13 May 2013 11:12:53 +0200
changeset 134 1b8d9f500d7a
parent 133 8b3f7b082539
child 135 9e786945c1a5
correctly handle the glance upload error (closes #232849) should provide better log information
_modules/openstack_client.py
--- a/_modules/openstack_client.py	Mon May 13 12:14:57 2013 +0200
+++ b/_modules/openstack_client.py	Mon May 13 11:12:53 2013 +0200
@@ -53,12 +53,15 @@
     log.info("glance add is_public=false disk_format="
             + disk_format + " container_format=" + disk_format + " name=\""
             + image_name + "\" " + other_params + " < " + filename)
-    output_add = __salt__['cmd.run']("glance add is_public=false disk_format="
+    output_add = __salt__['cmd.run_all']("glance add is_public=false disk_format="
             + disk_format + " container_format=" + disk_format + " name=\""
             + image_name + "\" " + other_params + " < " + filename)
-    log.info(output_add)
-    id_image = output_add.split("ID: ")[1].split('\n')[0]
-    print "Uploaded " + disk_format + " with id : " + id_image
+    if output_add['retcode'] != 0:
+        log.info(output_add['stdout'])
+        log.error(output_add['stderr'])
+        return ""
+    id_image = output_add['stdout'].split("ID: ")[1].split('\n')[0]
+    log.info("Uploaded " + disk_format + " with id : " + id_image)
     return id_image
 
 def get_list():