[Kimchi-devel] [RFC PATCH V2 29/31] Use pool_uri to avoid case pool_name is not defined

Lucio Correia luciojhc at linux.vnet.ibm.com
Mon Jun 22 22:59:43 UTC 2015


If exception is raised when setting pool_uri, a new
exception will be raised trying to print pool_uri
value, which will be undefined.

Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
Signed-off-by: Gustavo Y. Ribeiro <gyr at linux.vnet.ibm.com>
---
 plugins/kimchi/model/templates.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/plugins/kimchi/model/templates.py b/plugins/kimchi/model/templates.py
index 0f1f6be..a7a74fc 100644
--- a/plugins/kimchi/model/templates.py
+++ b/plugins/kimchi/model/templates.py
@@ -76,7 +76,7 @@ class TemplatesModel(object):
                 pool_name = pool_name_from_uri(pool_uri)
                 pool = conn.storagePoolLookupByName(pool_name.encode("utf-8"))
             except Exception:
-                raise InvalidParameter("KCHTMPL0004E", {'pool': pool_name,
+                raise InvalidParameter("KCHTMPL0004E", {'pool': pool_uri,
                                                         'template': name})
 
             tmp_volumes = [disk['volume'] for disk in params.get('disks', [])
@@ -194,7 +194,7 @@ class TemplateModel(object):
                 pool_name = pool_name_from_uri(pool_uri)
                 pool = conn.storagePoolLookupByName(pool_name.encode("utf-8"))
             except Exception:
-                raise InvalidParameter("KCHTMPL0004E", {'pool': pool_name,
+                raise InvalidParameter("KCHTMPL0004E", {'pool': pool_uri,
                                                         'template': name})
             tmp_volumes = [disk['volume'] for disk in new_t.get('disks', [])
                            if 'volume' in disk]
@@ -239,7 +239,7 @@ class LibvirtVMTemplate(VMTemplate):
             conn = self.conn.get()
             pool = conn.storagePoolLookupByName(pool_name.encode("utf-8"))
         except libvirt.libvirtError:
-            raise InvalidParameter("KCHTMPL0004E", {'pool': pool_name,
+            raise InvalidParameter("KCHTMPL0004E", {'pool': pool_uri,
                                                     'template': self.name})
 
         if not pool.isActive():
-- 
1.7.1




More information about the Kimchi-devel mailing list