[ovirt-users] Python-SDK4: How to list VM user sessions?

Juan Hernández jhernand at redhat.com
Mon Apr 10 11:18:49 UTC 2017


On 04/10/2017 11:10 AM, Giulio Casella wrote:
> On 07/04/2017 16:00, Juan Hernández wrote:
>> I have been trying to reproduce this and I wasn't able. In theory the
>> 404 error that you get should only happen if the virtual machine doesn't
>> exist, but that isn't the case.
>>
>> Can you check the server.log file and share the complete stack traces
>> that should appear after the "HTTP 404 Not Found" message?
>>
> 
> No problem, find attached a snippet of server.log.
> 
> Bye,
> Giulio
> 

Thanks, that helps. What the engine isn't finding is the user, not the
virtual machine. Can you provide more information about that user? I
mean, take the virtual machine and find via the GUI which user is using
it. Then go to https://.../ovirt-engine/api/users and find that user.
Share the definition of that user that you get there, if possible.

>> On 03/31/2017 10:25 AM, Giulio Casella wrote:
>>> On 30/03/2017 20:05, Juan Hernández wrote:
>>>> On 03/30/2017 01:01 PM, Giulio Casella wrote:
>>>>> Hi,
>>>>> I'm trying to obtain a list of users connected to a VM, using
>>>>> python SDK
>>>>> v4.
>>>>> Here's what I'm doing:
>>>>>
>>>>> vm = vms_service.list(search="name=vmname")[0]
>>>>> vm_service = vms_service.vm_service(vm.id)
>>>>> sessions = vm_service.sessions_service().list()
>>>>>
>>>>> But "sessions" is None.
>>>>>
>>>>> Same result using:
>>>>>
>>>>> s = connection.follow_link(vm.sessions)
>>>>>
>>>>> "s" is None.
>>>>>
>>>>> I tried also using curl, and if I connect to:
>>>>>
>>>>> https://my.ovirt.host/ovirt-engine/api/v4/vms/<vmid>/sessions
>>>>>
>>>>> I get a beautiful 404.
>>>>>
>>>>> Also using v3 of python SDK I obtain the same behaviour.
>>>>>
>>>>> So I suspect that retrieving user sessions via API is not implemented,
>>>>> is it? If not, what I'm doing wrong?
>>>>>
>>>>> I'm using RHV 4.0.6.3-0.1.el7ev
>>>>>
>>>>> Thanks in advance,
>>>>> Giulio
>>>>>
>>>>
>>>> Giulio, you should never get a 404 error from that URL, unless the
>>>> virtual doesn't exist or isn't visible for you. What user name are you
>>>> to create the SDK connection? An administrator or a regular user?
>>>>
>>>
>>> I tried with a regular domain user (with superuser role assigned) and
>>> admin at internal, with same result.
>>>
>>>> Also, please check the /var/log/ovirt-engine/server.log and
>>>> /var/log/ovirt-engine/engine.log when you send that request. Do you see
>>>> there something relevant?
>>>
>>> server.log reports:
>>>
>>> 2017-03-31 10:03:11,346 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n]
>>> (default task-33) RESTEASY002010: Failed to execute:
>>> javax.ws.rs.WebApplicationException: HTTP 404 Not Found
>>>
>>> (no surprise here, same message obtained by curl).
>>>
>>> engine.log is full of:
>>>
>>> ERROR [org.ovirt.engine.core.aaa.filters.SsoRestApiAuthFilter] (default
>>> task-7) [] Cannot authenticate using authentication Headers:
>>> invalid_grant: The provided authorization grant for the auth code has
>>> expired
>>>
>>> (indipendently of my request)
>>>
>>> It's quite strange I can perform almost every other operation (e.g.
>>> getting other VM parameters, running methods, etc.)
>>>
>>>
>>>>
>>>> Finally, please run your script with the 'debug=True' option in the
>>>> connection, and with a log file, like here:
>>>>
>>>>
>>>> https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/list_vms.py#L20-L37
>>>>
>>>>
>>>>
>>>> Then share that log file so that we can check what the server is
>>>> returning exactly. Make sure to remove your password from that log file
>>>> before sharing it.
>>>>
>>> Find attached produced log (passwords purged).
>>>
>>> BTW: VM is a Fedora 24, with guest agents correctly installed (I can see
>>> user sessions in admin portal and in postgresql DB).
>>>
>>> Thanks,
>>> Giulio
>>>
>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at ovirt.org
>>> http://lists.ovirt.org/mailman/listinfo/users
>>>
>>
> 



More information about the Users mailing list