[ovirt-users] Python-SDK4: How to list VM user sessions?
Ondra Machacek
omachace at redhat.com
Thu Mar 30 13:21:16 UTC 2017
On Thu, Mar 30, 2017 at 2:25 PM, Giulio Casella <giulio at di.unimi.it> wrote:
> On 30/03/2017 13:39, nicolas at devels.es wrote:
>
>> Hi Giulio,
>>
>> I tried to reproduce your same steps and it returns an non-empty list
>> for me.
>>
>> In [1]: vms_serv = sys_serv.vms_service()
>>
>> In [2]: vm = vms_serv.list(search='name=bleh')[0]
>>
>> In [3]: vmsv = vms_serv.vm_service(vm.id)
>>
>> In [4]: vmsess = vmsv.sessions_service()
>>
>> In [5]: vmsess.list()
>> Out[5]:
>> [<ovirtsdk4.types.Session at 0x4701e10>,
>> <ovirtsdk4.types.Session at 0x4701e90>]
>>
>> Are you sure a session is initiated on vmname in the moment you run the
>> vms_service.list(...)[0] statement?
>>
>
> Yes, if I print vm I obtain:
>
> <ovirtsdk4.types.Vm object at 0x15dcb10>
>
> while if I print vm_service:
>
> VmService:/vms/<vmid>
>
> and it is a real service (e.g. I can call method start, shutdown, ...)
>
>
>
>
>
>> El 2017-03-30 12:01, Giulio Casella escribió:
>>
>>> 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?
>>>
>>
Works OK for me:
In [12]: vm_service =
vms_service.vm_service('55095f91-e8e3-4634-9d05-47e0cc91e66b')
In [13]: vm_service.sessions_service().list()
Out[13]: []
In [14]: sdk.version.VERSION
Out[14]: '4.0.4'
What is the version of the SDK you are using?
>
>>> I'm using RHV 4.0.6.3-0.1.el7ev
>>>
>>> Thanks in advance,
>>> Giulio
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at ovirt.org
>>> http://lists.ovirt.org/mailman/listinfo/users
>>>
>> _______________________________________________
>> Users mailing list
>> Users at ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/users
>>
>
> --
> Giulio Casella giulio at di.unimi.it
> System and network manager
> Computer Science Dept. - University of Milano
>
> _______________________________________________
> Users mailing list
> Users at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/users/attachments/20170330/44bc13cf/attachment-0001.html>
More information about the Users
mailing list