Possible python api bug on api.clusters.list

--_=__=_XaM3_.1416562632.2A.744181.42.22667.52.42.007.1042646237 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =0A Hello,=0A before opening a new bug, I'm asking here if somebody c= ould let me know if this is a bug or there are other ways to obtain clust= ers list...=0A on python script I retrieve cluster list by using:=0A = clulist =3D api.clusters.list( "datacenter=3D" + "PROD" )=0A but this q= uery on python script will be *automatically* expandend on something like= evething datacenter containg word PROD -> *PROD*, and on our env there a= re either NO_PROD datacenter and PROD datacenter, and this cause that clu= list object contains every clusters on both datacenter.=0A Instead ovir= t-shell works fine and returns only clusters filtered by datacenter-ident= ifier parameter.=0A To better understand this is snippet of python code= :=0A >>> clulist =3D api.clusters.list( "datacenter=3D" + "PROD" )=0A =
=0A >>>=0A >>>=0A >>> for clu in clulist:=0A ... print "F= ound cluster " + clu.get_name()=0A ...=0A Found cluster NO_PROD = <-------- THIS CLUSTER IS ON NO_PROD DATACENTER=0A Found cluster PRO= D=0A >>>=0A ovirt-shell snippet that works fine:=0A [oVirt shell (c= onnected)]# list clusters --datacenter-identifier PROD=0A id : = 168c0d5e-8f12-4377-aabf-604adfd36b2b=0A name : PROD=0A [oVirt s= hell (connected)]# list clusters --datacenter-identifier NO_PROD=0A id = : a092c9fc-0f5f-471e-8bca-b3828255aa5a=0A name : NO_PROD=0A= [oVirt shell (connected)]#=0A Is this a bug? Can I open a new bug on= bugzilla?=0A Best regards=0A Amedeo Salvati=0A --_=__=_XaM3_.1416562632.2A.744181.42.22667.52.42.007.1042646237 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
=0A<div class=3D"xam_msg_class">=0A<font size=3D"2">Hello,<br /><br />bef= ore opening a new bug, I'm asking here if somebody could let me know if t= his is a bug or there are other ways to obtain clusters list...<br /><br = />on python script I retrieve cluster list by using:<br /><br />clulist =3D= api.clusters.list( "datacenter=3D" + "PROD" )<br /><= br />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 t= his cause that clulist object contains every clusters on both datacenter.= <br /><br />Instead ovirt-shell works fine and returns only clusters filt= ered by datacenter-identifier parameter.<br /><br />To better understand = this is snippet of python code:<br /><br />>>> clulist =3D api.c= lusters.list( "datacenter=3D" + "PROD" )<br />>>= ;> <br />>>> <br />>>> <br />>>> for clu in= clulist:<br />...=C2=A0=C2=A0=C2=A0=C2=A0 print "Found cluster &quo= t; + clu.get_name()<br />... <br />Found cluster NO_PROD=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <-------- THIS CLUSTER IS ON NO_PROD DA= TACENTER<br />Found cluster PROD<br />>>><br /><br />ovirt-shell= snippet that works fine:<br /><br />[oVirt shell (connected)]# list clus= ters --datacenter-identifier PROD<br /><br />id=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 : 168c0d5e-8f12-4377-aabf-604adfd36b2b<br />name=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : PROD<br /><br />[oVirt shell (connect= ed)]# list clusters --datacenter-identifier NO_PROD<br /><br />id=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : a092c9fc-0f5f-471e-8bca-b382825= 5aa5a<br />name=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : NO_PROD<br /><br />= [oVirt shell (connected)]#<br /><br />Is this a bug? Can I open a new bug= on bugzilla?<br /><br />Best regards<br />Amedeo Salvati</font>=0A</div>= =0A --_=__=_XaM3_.1416562632.2A.744181.42.22667.52.42.007.1042646237--

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.
participants (2)
-
Amedeo Salvati
-
Juan Hernandez