<br><br><div class="gmail_quote">On Wed, Jun 6, 2012 at 8:17 PM, Ori Liel <span dir="ltr"><<a href="mailto:oliel@redhat.com" target="_blank">oliel@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Anil,<br>
<br>
when you tried what Rami suggested:<br>
<div class="im"><br>
vmnames = api.vms.list(query = 'name=a')<br>
</div><div class="im">for vm in vmnames:<br>
print <a href="http://vm.name" target="_blank">vm.name</a><br>
<br>
</div>what was the output?<br></blockquote><div><br>Thanks everyone and special thank to Ori. That worked and I Understood my mistake.<br>Anil<br><br><br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Thanks,<br>
<br>
Ori.<br>
<div class="im HOEnZb">----- Original Message -----<br>
From: "Anil Vettathu" <<a href="mailto:anilv.in@gmail.com">anilv.in@gmail.com</a>><br>
To: <a href="mailto:rvaknin@redhat.com">rvaknin@redhat.com</a><br>
Cc: <a href="mailto:users@ovirt.org">users@ovirt.org</a><br>
Sent: Wednesday, June 6, 2012 5:02:23 PM<br>
Subject: Re: [Users] API Query on --> api.vms.list<br>
<br>
<br>
<br>
</div><div class="HOEnZb"><div class="h5">[<ovirtsdk.infrastructure.brokers.VM object at 0x12d6790>]<br>
Traceback (most recent call last):<br>
File "connect.py", line 21, in <module><br>
print <a href="http://vmnames.name" target="_blank">vmnames.name</a><br>
AttributeError: 'list' object has no attribute 'name'<br>
<br>
===<br>
<br>
It did not work. Actually following are the functions I am getting for vmnames.<br>
<br>
vmnames.append vmnames.extend vmnames.insert vmnames.remove vmnames.sort<br>
vmnames.count vmnames.index vmnames.pop vmnames.reverse<br>
<br>
Thanks,<br>
Anil<br>
<br>
<br>
On Wed, Jun 6, 2012 at 7:01 PM, Rami Vaknin < <a href="mailto:rvaknin@redhat.com">rvaknin@redhat.com</a> > wrote:<br>
<br>
<br>
<br>
<br>
On 06/06/2012 04:02 PM, Anil Vettathu wrote:<br>
<br>
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 href="https://192.168.1.1:8443/api" target="_blank">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>
<br>
you print the vm object you get, while you need to print the "name" field:<br>
print <a href="http://vmnames.name" target="_blank">vmnames.name</a><br>
<br>
<br>
<br>
==========<br>
<br>
Print output is,<br>
<br>
<ovirtsdk.infrastructure.brokers.VM object at 0x1d4e790><br>
<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 href="http://www.ovirt.org/wiki/SDK#Querying_collection_with_oVirt_search_engine_query_.26_custom_constraint" target="_blank">http://www.ovirt.org/wiki/SDK#Querying_collection_with_oVirt_search_engine_query_.26_custom_constraint</a><br>
<br>
Thanks,<br>
Anil<br>
<br>
<br>
_______________________________________________<br>
Users mailing list <a href="mailto:Users@ovirt.org">Users@ovirt.org</a> <a href="http://lists.ovirt.org/mailman/listinfo/users" target="_blank">http://lists.ovirt.org/mailman/listinfo/users</a><br>
<br>
--<br>
<br>
Thanks,<br>
<br>
Rami Vaknin, QE @ Red Hat, TLV, IL.<br>
<br>
<br>
--<br>
<a href="http://www.anilv.in" target="_blank">http://www.anilv.in</a><br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@ovirt.org">Users@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/users" target="_blank">http://lists.ovirt.org/mailman/listinfo/users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.anilv.in">http://www.anilv.in</a><br>