-------- Original Message --------
Subject: Re: [Users] API Query on --> api.vms.list
Date: Wed, 06 Jun 2012 16:31:59 +0300
From: Rami Vaknin <rvaknin@redhat.com>
Reply-To: rvaknin@redhat.com
Organization: Red Hat
To: Anil Vettathu <anilv.in@gmail.com>
CC: users@ovirt.org


On 06/06/2012 04:02 PM, Anil Vettathu wrote:
Hi

I am writing a small python script to get the name of all the VMs that matches a string.

==========
import sys
import getopt
import optparse
import os
import time
from ovirtsdk.api import API
from ovirtsdk.xml import params

URL='https://192.168.1.1:8443/api' #RHEVM API ACCESS URL
USERNAME='admin@internal'
PASSWORD='ovirt'


api=API(url=URL, username=USERNAME, password=PASSWORD)

vmnames = api.vms.list(query = 'name=a')
print vmnames

you print the vm object you get, while you need to print the "name" field:
print vmnames.name

Sorry, you first need to iterate on what you got:
for vm in vmnames:
    print vm.name
==========

Print output is,

<ovirtsdk.infrastructure.brokers.VM object at 0x1d4e790>

I was expecting a list of VMs which contains "a" in their names.

Am I doing it correct? Can someone guide me with a small example?
My reference is http://www.ovirt.org/wiki/SDK#Querying_collection_with_oVirt_search_engine_query_.26_custom_constraint

Thanks,
Anil


_______________________________________________
Users mailing list
Users@ovirt.org
http://lists.ovirt.org/mailman/listinfo/users


-- 

Thanks,

Rami Vaknin, QE @ Red Hat, TLV, IL.