[Kimchi-devel] [PATCH 3/9] Use get_vm() instead of conn.lookupByName

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


Remove duplicated code of conn.lookupByName.

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

diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index 2ae58ee..3445def 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -284,7 +284,7 @@ class VMModel(object):
         # fetch base XML
         cb('reading source VM XML')
         try:
-            vir_dom = vir_conn.lookupByName(name)
+            vir_dom = self.get_vm(name)
             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 87c6b3d..95af7ac 100644
--- a/src/kimchi/model/vmstorages.py
+++ b/src/kimchi/model/vmstorages.py
@@ -136,7 +136,7 @@ class VMStoragesModel(object):
         dev, xml = get_disk_xml(params)
         try:
             conn = self.conn.get()
-            dom = conn.lookupByName(vm_name)
+            dom = VMModel.get_vm(vm_name, conn)
             dom.attachDeviceFlags(xml, get_vm_config_flag(dom, 'all'))
         except Exception as e:
             raise OperationFailed("KCHVMSTOR0008E", {'error': e.message})
@@ -171,7 +171,7 @@ class VMStorageModel(object):
 
         try:
             bus_type = self.lookup(vm_name, dev_name)['bus']
-            dom = conn.lookupByName(vm_name)
+            dom = VMModel.get_vm(vm_name, conn)
         except NotFoundError:
             raise
 
-- 
2.1.0




More information about the Kimchi-devel mailing list