[Users] API Query on --> api.vms.list
Anil Vettathu
anilv.in at gmail.com
Wed Jun 6 15:24:58 UTC 2012
On Wed, Jun 6, 2012 at 8:17 PM, Ori Liel <oliel at 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 at gmail.com>
> To: rvaknin at redhat.com
> Cc: users at 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 at 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 at 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_query_.26_custom_constraint
>
> Thanks,
> Anil
>
>
> _______________________________________________
> Users mailing list Users at 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 at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users
>
--
http://www.anilv.in
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/users/attachments/20120606/187f6844/attachment-0001.html>
More information about the Users
mailing list