[Kimchi-devel] [PATCH 3/5] Use get_vm() instead of conn.lookupByName
Aline Manera
alinefm at linux.vnet.ibm.com
Mon May 4 18:58:10 UTC 2015
As I said before you don't need to query all the guests to get a
specific one as you know how to convert the non-ASCII name to only ASCII
characters
On 28/04/2015 10:16, Ramon Medeiros wrote:
> 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 6792447..87d63c1 100644
> --- a/src/kimchi/model/vms.py
> +++ b/src/kimchi/model/vms.py
> @@ -266,7 +266,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 37aca64..8dabae7 100644
> --- a/src/kimchi/model/vmstorages.py
> +++ b/src/kimchi/model/vmstorages.py
> @@ -138,7 +138,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})
> @@ -173,7 +173,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
>
More information about the Kimchi-devel
mailing list