[ovirt-users] Error when trying to retrieve cluster, hosts via ovirt API

Juan Hernández jhernand at redhat.com
Thu Nov 26 14:26:22 UTC 2015


On 11/25/2015 11:13 AM, Jean-Pierre Ribeauville wrote:
> H,
> 
> Thanks for infos.
> 
> BTW,  as I need to retrieve cluster and datacenter to which my host belongs   within a software running on the host , I use a Python script 
> interacting with the ovirt-engine ; is there another way to get these  infos "locally" on the host itself ?
> 

I'm not aware of any way to do that, I'd suggest that you stick to
interacting with the engine for that.

> 
> -----Message d'origine-----
> De : Juan Hernández [mailto:jhernand at redhat.com] 
> Envoyé : mercredi 18 novembre 2015 19:10
> À : Jean-Pierre Ribeauville; Karli Sjöberg
> Cc : users at ovirt.org
> Objet : Re: [ovirt-users] Error when trying to retrieve cluster, hosts via ovirt API
> 
> On 11/18/2015 12:22 PM, Jean-Pierre Ribeauville wrote:
>> Hi,
>>
>> You were right .
>>
>> By setting correct URL and correct certificate file location , it's working.
>>
>> If I well understand , as this certificate file has to be on the 
>> client side , isn't a point if failure ?
>>
> 
> The certificate is needed to secure the SSL communication. You can do without it, adding "insecure=True" to the constructor of the API object, but then the identity of the server could be forged and you won't notice.
> 
>>
>> For example , for a cluster , it's possible to retrieve hosts 
>> belonging to the cluster via this call:
>>
>> hostoncluster = api.clusters.get(id=api.hosts.get(obj.name
>> <http://obj.name>).get_cluster().get_id()).get_name()
>>
> 
> That should work, but when you are doing this kind of query it is usually better to let the server do the search. You can achieve that using the same query language that is used in the GUI search bar. For example, in the GUI search bar you can type "Hosts: cluster=mycluster".
> With the SDK you can do the same, using the "list" method and the "query" parameter:
> 
>   hosts = api.hosts.list(query="cluster=mycluster")
>   for host in hosts:
>     print(host.get_name())
> 
>>
>> How may I know list of available "fields"  for  host, cluster, 
>> datacenters and so on .. .
>>
> 
> You can open the "params.py" file
> (/usr/lib/python2.7/site-packages/ovirtsdk/xml/params.py if you are using the RPM packags) and look for the corrsponding class: Host, Cluster, DataCenter etc. There you will see all the available "get_..."
> methods.
> 
>>
>> Thanks for help.
>>
>>  
>>
>> J.P.
>>
>>  
>>
>> *De :*Karli Sjöberg [mailto:karli.sjoberg at slu.se] *Envoyé :* mardi 17 
>> novembre 2015 17:52 *À :* Jean-Pierre Ribeauville *Cc :* 
>> users at ovirt.org *Objet :* Re: [ovirt-users] Error when trying to 
>> retrieve cluster, hosts via ovirt API
>>
>>  
>>
>>
>> Den 17 nov. 2015 5:30 em skrev Jean-Pierre Ribeauville 
>> <jpribeauville at axway.com <mailto:jpribeauville at axway.com>>:
>>>
>>> Hi,
>>>
>>>  
>>>
>>> By running python example got here ( :
>> http://website-humblec.rhcloud.com/ovirt-find-hosts-clusters-vm-runnin
>> g-status-ids-storage-domain-details-ovirt-dc-pythonovirt-sdk-part-3)
>>
>>> and modified with my connection  parameters, I got following error :
>>>
>>>  
>>>
>>>  
>>>
>>> Unexpected error: [ERROR]::oVirt API connection failure, (77, '')
>>>
>>>  
>>>
>>> How may I get error  codes meanings ?
>>
>> I don't know the meaning but I saw that APIURL was wrong, it should be:
>>
>> APIURL = "https://${ENGINE_ADDRESS}/ovirt-engine/api
>> <https://$%7bENGINE_ADDRESS%7d/ovirt-engine/api>"
>>
>> Could you correct that and try again?
>>
>> /K
>>
>>>
>>>  
>>>
>>> Thanks for help.
>>>
>>>  
>>>
>>>  
>>>
>>>  
>>>
>>> J.P. Ribeauville
>>>
>>>  
>>>
>>> P: +33.(0).1.47.17.20.49
>>>
>>> .
>>>
>>> Puteaux 3 Etage 5  Bureau 4
>>>
>>>  
>>>
>>> jpribeauville at axway.com <mailto:jpribeauville at axway.com> 
>>> http://www.axway.com
>>>
>>>  
>>>
>>>  
>>>
>>> P Pensez à l'environnement avant d'imprimer.
>>>
>>>  
>>>
>>>  
>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/users
>>
> 
> 
> --
> 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.
> _______________________________________________
> Users mailing list
> Users at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users
> 


-- 
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