[ovirt-users] Possible python api bug on api.clusters.list

Juan Hernandez jhernand at redhat.com
Fri Nov 21 04:56:07 EST 2014


On 11/21/2014 10:37 AM, Amedeo Salvati wrote:
> Hello,
> 
> before opening a new bug, I'm asking here if somebody could let me know
> if this is a bug or there are other ways to obtain clusters list...
> 
> on python script I retrieve cluster list by using:
> 
> clulist = api.clusters.list( "datacenter=" + "PROD" )
> 
> but this query on python script will be *automatically* expandend on
> something like evething datacenter containg word PROD -> *PROD*, and on
> our env there are either NO_PROD datacenter and PROD datacenter, and
> this cause that clulist object contains every clusters on both datacenter.
> 

This call is translated into the following request:

  GET /ovirt-engine/api/clusters?search=datacenter%3DPROD

And as you discovered this means "all clusters from all data centers
whose name contains PROD". This is by design, it isn't a bug.

If you only want the clusters of the "PROD" data center then you should
instead do something like this:

  prod_datacenter = api.datacenters.get(name="PROD")
  prod_clusters = prod_datacenter.clusters.list()

This is what ovirt-shell does when you run "list clusters
--datacenter-identifier PROD".

> Instead ovirt-shell works fine and returns only clusters filtered by
> datacenter-identifier parameter.
> 
> To better understand this is snippet of python code:
> 
>>>> clulist = api.clusters.list( "datacenter=" + "PROD" )
>>>>
>>>>
>>>>
>>>> for clu in clulist:
> ...     print "Found cluster " + clu.get_name()
> ...
> Found cluster NO_PROD         <-------- THIS CLUSTER IS ON NO_PROD
> DATACENTER
> Found cluster PROD
>>>>
> 
> ovirt-shell snippet that works fine:
> 
> [oVirt shell (connected)]# list clusters --datacenter-identifier PROD
> 
> id         : 168c0d5e-8f12-4377-aabf-604adfd36b2b
> name       : PROD
> 
> [oVirt shell (connected)]# list clusters --datacenter-identifier NO_PROD
> 
> id         : a092c9fc-0f5f-471e-8bca-b3828255aa5a
> name       : NO_PROD
> 
> [oVirt shell (connected)]#
> 
> Is this a bug? Can I open a new bug on bugzilla?
> 
> Best regards
> Amedeo Salvati
> 

-- 
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
3ºD, 28016 Madrid, Spain
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.


More information about the Users mailing list