[Kimchi-devel] [PATCH 7/9] Fix functions that uses connection as parameter

Ramon Medeiros ramonn at linux.vnet.ibm.com
Thu May 7 17:40:37 UTC 2015


Some calls to get_vm() were passing the connection instance, but the
function waits for the connection object.

Signed-off-by: Ramon Medeiros <ramonn at linux.vnet.ibm.com>
---
 src/kimchi/model/vms.py        | 2 +-
 src/kimchi/model/vmstorages.py | 7 ++-----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index 79967cc..5f9dbaa 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -290,7 +290,7 @@ class VMModel(object):
         # fetch base XML
         cb('reading source VM XML')
         try:
-            vir_dom = self.get_vm(name)
+            vir_dom = self.get_vm(name, self.conn)
             flags = libvirt.VIR_DOMAIN_XML_SECURE
             xml = vir_dom.XMLDesc(flags).decode('utf-8')
         except libvirt.libvirtError, e:
diff --git a/src/kimchi/model/vmstorages.py b/src/kimchi/model/vmstorages.py
index 95af7ac..c2aa7be 100644
--- a/src/kimchi/model/vmstorages.py
+++ b/src/kimchi/model/vmstorages.py
@@ -135,8 +135,7 @@ class VMStoragesModel(object):
         # Add device to VM
         dev, xml = get_disk_xml(params)
         try:
-            conn = self.conn.get()
-            dom = VMModel.get_vm(vm_name, conn)
+            dom = VMModel.get_vm(vm_name, self.conn)
             dom.attachDeviceFlags(xml, get_vm_config_flag(dom, 'all'))
         except Exception as e:
             raise OperationFailed("KCHVMSTOR0008E", {'error': e.message})
@@ -167,11 +166,9 @@ class VMStorageModel(object):
         return get_vm_disk_info(dom, dev_name)
 
     def delete(self, vm_name, dev_name):
-        conn = self.conn.get()
-
         try:
             bus_type = self.lookup(vm_name, dev_name)['bus']
-            dom = VMModel.get_vm(vm_name, conn)
+            dom = VMModel.get_vm(vm_name, self.conn)
         except NotFoundError:
             raise
 
-- 
2.1.0




More information about the Kimchi-devel mailing list