[Users] API Query on --> api.vms.list

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 ========== 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_q... Thanks, Anil

This is a multi-part message in MIME format. --------------090000000700080106090303 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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
==========
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_q...
Thanks, Anil
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- Thanks, Rami Vaknin, QE @ Red Hat, TLV, IL. --------------090000000700080106090303 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#FFFFFF" text="#000000"> On 06/06/2012 04:02 PM, Anil Vettathu wrote: <blockquote cite="mid:CAEixW=YEzY3FuPWxe3PiN=v8PjdL_X_1R9Bk=J3ZutivE0oUrA@mail.gmail.com" type="cite">Hi<br> <br> I am writing a small python script to get the name of all the VMs that matches a string.<br> <br> ==========<br> import sys<br> import getopt<br> import optparse<br> import os<br> import time<br> from ovirtsdk.api import API<br> from ovirtsdk.xml import params<br> <br> URL='<a moz-do-not-send="true" href="https://192.168.1.1:8443/api">https://192.168.1.1:8443/api</a>' #RHEVM API ACCESS URL<br> USERNAME='admin@internal'<br> PASSWORD='ovirt'<br> <br> <br> api=API(url=URL, username=USERNAME, password=PASSWORD)<br> <br> vmnames = api.vms.list(query = 'name=a')<br> print vmnames<br> </blockquote> <br> you print the vm object you get, while you need to print the "name" field:<br> print vmnames.name<br> <blockquote cite="mid:CAEixW=YEzY3FuPWxe3PiN=v8PjdL_X_1R9Bk=J3ZutivE0oUrA@mail.gmail.com" type="cite">==========<br> <br> Print output is,<br> <br> <ovirtsdk.infrastructure.brokers.VM object at 0x1d4e790><br clear="all"> <br> I was expecting a list of VMs which contains "a" in their names.<br> <br> Am I doing it correct? Can someone guide me with a small example?<br> My reference is <a moz-do-not-send="true" href="http://www.ovirt.org/wiki/SDK#Querying_collection_with_oVirt_search_engine_query_.26_custom_constraint">http://www.ovirt.org/wiki/SDK#Querying_collection_with_oVirt_search_engine_query_.26_custom_constraint</a><br> <br> Thanks,<br> Anil<br> <br> <fieldset class="mimeAttachmentHeader"></fieldset> <br> <pre wrap="">_______________________________________________ Users mailing list <a class="moz-txt-link-abbreviated" href="mailto:Users@ovirt.org">Users@ovirt.org</a> <a class="moz-txt-link-freetext" href="http://lists.ovirt.org/mailman/listinfo/users">http://lists.ovirt.org/mailman/listinfo/users</a> </pre> </blockquote> <br> <br> <pre class="moz-signature" cols="72">-- Thanks, Rami Vaknin, QE @ Red Hat, TLV, IL. </pre> </body> </html> --------------090000000700080106090303--

-------- 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_q...
Thanks, Anil
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- Thanks, Rami Vaknin, QE @ Red Hat, TLV, IL.

[<ovirtsdk.infrastructure.brokers.VM object at 0x12d6790>] Traceback (most recent call last): File "connect.py", line 21, in <module> print vmnames.name AttributeError: 'list' object has no attribute 'name' === It did not work. Actually following are the functions I am getting for vmnames. vmnames.append vmnames.extend vmnames.insert vmnames.remove vmnames.sort vmnames.count vmnames.index vmnames.pop vmnames.reverse Thanks, Anil On Wed, Jun 6, 2012 at 7:01 PM, Rami Vaknin <rvaknin@redhat.com> wrote:
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
==========
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_q...
Thanks, Anil
_______________________________________________ Users mailing listUsers@ovirt.orghttp://lists.ovirt.org/mailman/listinfo/users
--
Thanks,
Rami Vaknin, QE @ Red Hat, TLV, IL.

Hi Anil, when you tried what Rami suggested: vmnames = api.vms.list(query = 'name=a') for vm in vmnames: print vm.name what was the output? Thanks, Ori. ----- Original Message ----- From: "Anil Vettathu" <anilv.in@gmail.com> To: rvaknin@redhat.com Cc: users@ovirt.org Sent: Wednesday, June 6, 2012 5:02:23 PM Subject: Re: [Users] API Query on --> api.vms.list [<ovirtsdk.infrastructure.brokers.VM object at 0x12d6790>] Traceback (most recent call last): File "connect.py", line 21, in <module> print vmnames.name AttributeError: 'list' object has no attribute 'name' === It did not work. Actually following are the functions I am getting for vmnames. vmnames.append vmnames.extend vmnames.insert vmnames.remove vmnames.sort vmnames.count vmnames.index vmnames.pop vmnames.reverse Thanks, Anil On Wed, Jun 6, 2012 at 7:01 PM, Rami Vaknin < rvaknin@redhat.com > wrote: 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 ========== 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_q... Thanks, Anil _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users -- Thanks, Rami Vaknin, QE @ Red Hat, TLV, IL. -- http://www.anilv.in _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

On Wed, Jun 6, 2012 at 8:17 PM, Ori Liel <oliel@redhat.com> wrote:
Hi Anil,
when you tried what Rami suggested:
vmnames = api.vms.list(query = 'name=a') for vm in vmnames: print vm.name
what was the output?
Thanks everyone and special thank to Ori. That worked and I Understood my mistake. Anil
Thanks,
Ori. ----- Original Message ----- From: "Anil Vettathu" <anilv.in@gmail.com> To: rvaknin@redhat.com Cc: users@ovirt.org Sent: Wednesday, June 6, 2012 5:02:23 PM Subject: Re: [Users] API Query on --> api.vms.list
[<ovirtsdk.infrastructure.brokers.VM object at 0x12d6790>] Traceback (most recent call last): File "connect.py", line 21, in <module> print vmnames.name AttributeError: 'list' object has no attribute 'name'
===
It did not work. Actually following are the functions I am getting for vmnames.
vmnames.append vmnames.extend vmnames.insert vmnames.remove vmnames.sort vmnames.count vmnames.index vmnames.pop vmnames.reverse
Thanks, Anil
On Wed, Jun 6, 2012 at 7:01 PM, Rami Vaknin < rvaknin@redhat.com > wrote:
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
==========
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_q...
Thanks, Anil
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
--
Thanks,
Rami Vaknin, QE @ Red Hat, TLV, IL.
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
participants (3)
-
Anil Vettathu
-
Ori Liel
-
Rami Vaknin