[ovirt-users] Python-SDK4: Listing template by ID throws exception

Juan Hernández jhernand at redhat.com
Tue Apr 4 09:22:46 UTC 2017


On 04/04/2017 10:59 AM, nicolas at devels.es wrote:
> Hi,
> 
> I'm using ovirt-engine-sdk-python 4.1.3 (ovirt ver is 4.1.0), and in a
> snippet I'm trying to get a template by its id. For that, I did this:
> 
> conn = ovirtsdk4.Connection(...)
> sys_serv = conn.system_service()
> tpl_serv = sys_serv.templates_service()
> 
> t = tpl_serv.list(search='id=fedff75f-635f-4790-9bbf-2ac389e14f93')
> 
> And it throws:
> 
> Error: Fault reason is "Operation Failed". Fault detail is
> "statementcallback; bad sql grammar [select * from (select * from vm
> templates view where ( vmt guid in (select distinct vm templates storage
> domain.vmt guid from  vm templates storage domain   where  (  vm
> templates storage domain.cluster name ilike
> '%id=fedff75f-635f-4790-9bbf-2ac389e14f93%' or  vm templates storage
> domain.description ilike '%id=fedff75f-635f-4790-9bbf-2ac389e14f93%' or 
> vm templates storage domain.free text comment ilike
> '%id=fedff75f-635f-4790-9bbf-2ac389e14f93%' or  vm templates storage
> domain.name ilike '%id=fedff75f-635f-4790-9bbf-2ac389e14f93%' or  vm
> templates storage domain.quota name ilike
> '%id=fedff75f-635f-4790-9bbf-2ac389e14f93%' or  vm templates storage
> domain.storage pool name ilike
> '%id=fedff75f-635f-4790-9bbf-2ac389e14f93%' or  vm templates storage
> domain.template version name,template version number ilike
> '%id=fedff75f-635f-4790-9bbf-2ac389e14f93%' ) ))  order by name asc ) as
> t1 offset (1 -1) limit 2147483647]; nested exception is
> org.postgresql.util.psqlexception: error: argument of or must be type
> boolean, not type character varying
>   position: 737". HTTP response code is 400.
> 
> I'm sure this template exists and it has this ID. If I search in the
> webadmin by this ID, the search seems to hang and never returns anything
> (I have to stop it by pressing the 'X' button).
> 
> Am I using this call improperly?
> 
> Thanks.

This should work, or at least it shouldn't generate that error. But it
isn't the best way to get a template (or any object) if you already know
the id. It is better to do this:

  conn = ovirtsdk4.Connection(...)
  sys_serv = conn.system_service()
  tpls_serv = sys_serv.templates_service()
  tpl_serv =
tpls_serv.tmeplate_service('fedff75f-635f-4790-9bbf-2ac389e14f93')
  tpl = tpl_serv.get()




More information about the Users mailing list