[Kimchi-devel] [PATCH] get vms list by listAllDomains

Mark Wu wudxw at linux.vnet.ibm.com
Thu Jan 16 02:12:13 UTC 2014


On 01/13/2014 07:12 PM, shaohef at linux.vnet.ibm.com wrote:
> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>
> we can get all domains by listAllDomains
>
> Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> ---
>   src/kimchi/model.py | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/src/kimchi/model.py b/src/kimchi/model.py
> index 671af02..4b7df7e 100644
> --- a/src/kimchi/model.py
> +++ b/src/kimchi/model.py
> @@ -646,10 +646,7 @@ class Model(object):
>
>       def vms_get_list(self):
>           conn = self.conn.get()
> -        ids = conn.listDomainsID()
> -        names = map(lambda x: conn.lookupByID(x).name(), ids)
> -        names += conn.listDefinedDomains()
> -        names = map(lambda x: x.decode('utf-8'), names)
> +        names = [dom.name().decode('utf-8') for dom in conn.listAllDomains(0)]
use generator is more efficient than generating a new list:

names = (dom.name().decode('utf-8') for dom in conn.listAllDomains(0))


>           return sorted(names, key=unicode.lower)
>
>       def vmscreenshot_lookup(self, name):




More information about the Kimchi-devel mailing list