Python-SDK4: How to list user permissions?

Hi, I'm trying to get a user's list of permissions, i.e., list all permissions a user have on VMs and VmPools. In SDK3 that was easy as I could run (being 'u' a User object): for perm in u.permissions.list(): vm = perm.get_vm() vmpool = perm.get_vmpool() if vm or vmpool: print "User has some permissions!" In SDK4 I cannot reproduce the same logic. u.permissions returns an empty list ([]). What I have so far is something like this: for u in users_serv.list(): if u.user_name == 'admin@internal': continue vms_service = sys_serv.vms_service() for vm in vms_service.list(): vms = vms_service.vm_service(id=vm.id) ps = vms.permissions_service() for perm in ps.list(): perm_service = ps.permission_service(id=perm.id) getperm = perm_service.get() if getperm.user.user_name == u.user_name: print "Permission for %s" % (u.user_name) if getperm.vm: print "VM: %s" % (getperm.vm.id) if getperm.vm_pool: print "VmPool: %s" % (getperm.vm_pool.id) However, this seems a bit overkill. We have nearly 850 VMs and for a single user this takes about 25 minutes to run. Additionally, it doesn't seem to return any permission, although I know this user has some permissions over 2 VMs (not sure where is it messed up). I also tried using the system_service.permissions_service() but it seems to return only the global permissions. Is there an easier way to do this? Thanks!

On 03/29/2017 01:05 PM, nicolas@devels.es wrote:
Hi,
I'm trying to get a user's list of permissions, i.e., list all permissions a user have on VMs and VmPools.
In SDK3 that was easy as I could run (being 'u' a User object):
for perm in u.permissions.list(): vm = perm.get_vm() vmpool = perm.get_vmpool()
if vm or vmpool: print "User has some permissions!"
In SDK4 I cannot reproduce the same logic. u.permissions returns an empty list ([]).
What I have so far is something like this:
for u in users_serv.list(): if u.user_name == 'admin@internal': continue
vms_service = sys_serv.vms_service() for vm in vms_service.list(): vms = vms_service.vm_service(id=vm.id) ps = vms.permissions_service() for perm in ps.list(): perm_service = ps.permission_service(id=perm.id) getperm = perm_service.get() if getperm.user.user_name == u.user_name: print "Permission for %s" % (u.user_name) if getperm.vm: print "VM: %s" % (getperm.vm.id) if getperm.vm_pool: print "VmPool: %s" % (getperm.vm_pool.id)
However, this seems a bit overkill. We have nearly 850 VMs and for a single user this takes about 25 minutes to run. Additionally, it doesn't seem to return any permission, although I know this user has some permissions over 2 VMs (not sure where is it messed up).
I also tried using the system_service.permissions_service() but it seems to return only the global permissions.
Is there an easier way to do this?
Thanks!
Version 4 of the SDK makes a clear distinction between what are pure containers of data (like the User class) and what are services (like the UsersService class). Therefore when you call 'u.permissions' in version 4 of the SD you get nothing, because the object that you retrieved previously doesn't contain the permissions, only a link. That is exactly how the API behaves. When you do this: GET /ovirt-engine/api/users/{user:id} You only get the data of the user, and some links to other related data, like the permissions: <user id="..." href="..."> <name>myuser</name> ... <link rel="permissions" href="/ovirt-engine/api/users/{user:id}/permissions"/> </user> In version 4 of the SDK the simple way to follow the link is to use the Connection.follow_link method. So, you need something like this: ---8<--- # Find the user: users_service = connection.system_service().users_service() user = users_service.list(search='name=myuser')[0] # Follow the link to the permissions of the user: perms = connection.follow_link(user.permissions) for perm in perms: if perm.vm or perm.vm_pool: print "User has some permissions!" --->8---

El 2017-03-29 12:35, Juan Hernández escribió:
On 03/29/2017 01:05 PM, nicolas@devels.es wrote:
Hi,
I'm trying to get a user's list of permissions, i.e., list all permissions a user have on VMs and VmPools.
In SDK3 that was easy as I could run (being 'u' a User object):
for perm in u.permissions.list(): vm = perm.get_vm() vmpool = perm.get_vmpool()
if vm or vmpool: print "User has some permissions!"
In SDK4 I cannot reproduce the same logic. u.permissions returns an empty list ([]).
What I have so far is something like this:
for u in users_serv.list(): if u.user_name == 'admin@internal': continue
vms_service = sys_serv.vms_service() for vm in vms_service.list(): vms = vms_service.vm_service(id=vm.id) ps = vms.permissions_service() for perm in ps.list(): perm_service = ps.permission_service(id=perm.id) getperm = perm_service.get() if getperm.user.user_name == u.user_name: print "Permission for %s" % (u.user_name) if getperm.vm: print "VM: %s" % (getperm.vm.id) if getperm.vm_pool: print "VmPool: %s" % (getperm.vm_pool.id)
However, this seems a bit overkill. We have nearly 850 VMs and for a single user this takes about 25 minutes to run. Additionally, it doesn't seem to return any permission, although I know this user has some permissions over 2 VMs (not sure where is it messed up).
I also tried using the system_service.permissions_service() but it seems to return only the global permissions.
Is there an easier way to do this?
Thanks!
Version 4 of the SDK makes a clear distinction between what are pure containers of data (like the User class) and what are services (like the UsersService class). Therefore when you call 'u.permissions' in version 4 of the SD you get nothing, because the object that you retrieved previously doesn't contain the permissions, only a link. That is exactly how the API behaves. When you do this:
GET /ovirt-engine/api/users/{user:id}
You only get the data of the user, and some links to other related data, like the permissions:
<user id="..." href="..."> <name>myuser</name> ... <link rel="permissions" href="/ovirt-engine/api/users/{user:id}/permissions"/> </user>
In version 4 of the SDK the simple way to follow the link is to use the Connection.follow_link method. So, you need something like this:
---8<--- # Find the user: users_service = connection.system_service().users_service() user = users_service.list(search='name=myuser')[0]
# Follow the link to the permissions of the user: perms = connection.follow_link(user.permissions) for perm in perms: if perm.vm or perm.vm_pool: print "User has some permissions!" --->8---
Thanks, that makes things much easier! Regards, Nicolás

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

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? 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?
I'm using RHV 4.0.6.3-0.1.el7ev
Thanks in advance, Giulio
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

On 30/03/2017 13:39, nicolas@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?
I'm using RHV 4.0.6.3-0.1.el7ev
Thanks in advance, Giulio
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Users mailing list Users@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

On Thu, Mar 30, 2017 at 2:25 PM, Giulio Casella <giulio@di.unimi.it> wrote:
On 30/03/2017 13:39, nicolas@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@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@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@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

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

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

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? 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@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....
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@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

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
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@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....
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@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

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@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....
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@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

Hi, I'm taking over Giulio because he's not at work now. I'm starting to understand what's happening because we have not that users (and many others) in the users tab in the admin portal. We have heavily modified the paradigm of ovirt, VM are bound to thin clients and not to users, this because we want to reproduce a lab/classroom environment and we don't use the user portal. We wrote an alternative administration portal where we define classrooms, thin clients and associations between clients and VMs. Windows VMs are joined to a AD domain and linux VMs are joined to IPA, home dirs are remotely mounted upon user login. So there's no need to have all that users (over 31000) in the admin portal because they have no permission on any VM, they can login from any client to the VM bound to that client. In the admin portal, if I go to a VM with a logged in user in the "Guest info" tab I can see which user is logged in because, I think, the guest agents are aware of the logged in username, but there's no "user object" in the engine when I try to get that information via API. Thanks for your time and patience.. Regards, Giorgio On 04/10/2017 01:18 PM, Juan Hernández wrote:
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@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....
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@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- gb PGP Key: http://pgp.mit.edu/ Primary key fingerprint: C510 0765 943E EBED A4F2 69D3 16CC DC90 B9CB 0F34

On 04/10/2017 05:38 PM, Giorgio Biacchi wrote:
Hi, I'm taking over Giulio because he's not at work now. I'm starting to understand what's happening because we have not that users (and many others) in the users tab in the admin portal.
We have heavily modified the paradigm of ovirt, VM are bound to thin clients and not to users, this because we want to reproduce a lab/classroom environment and we don't use the user portal. We wrote an alternative administration portal where we define classrooms, thin clients and associations between clients and VMs.
Windows VMs are joined to a AD domain and linux VMs are joined to IPA, home dirs are remotely mounted upon user login.
So there's no need to have all that users (over 31000) in the admin portal because they have no permission on any VM, they can login from any client to the VM bound to that client.
In the admin portal, if I go to a VM with a logged in user in the "Guest info" tab I can see which user is logged in because, I think, the guest agents are aware of the logged in username, but there's no "user object" in the engine when I try to get that information via API.
Thanks for your time and patience..
Regards, Giorgio
OK, that makes sense. I think this is a bug in the server then. If the users are not oVirt users we should just not report them, or maybe report just the user name and domain, if available. But returning 404 and failing in that case isn't correct, in my opinion. I have opened the following bug to track this issue: Don't fail with 404 if session user doesn't exist in the database https://bugzilla.redhat.com/1440861
On 04/10/2017 01:18 PM, Juan Hernández wrote:
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@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....
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@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users

On 10/04/2017 17:50, Juan Hernández wrote:
On 04/10/2017 05:38 PM, Giorgio Biacchi wrote:
...
OK, that makes sense. I think this is a bug in the server then. If the users are not oVirt users we should just not report them, or maybe report just the user name and domain, if available. But returning 404 and failing in that case isn't correct, in my opinion. I have opened the following bug to track this issue:
Don't fail with 404 if session user doesn't exist in the database https://bugzilla.redhat.com/1440861
Great, thank you Juan. My preference is for reporting username and domain, instead of not reporting at all. Thank you again. Bye, Giulio
On 04/10/2017 01:18 PM, Juan Hernández wrote:
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@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.... > > > > > 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@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
participants (5)
-
Giorgio Biacchi
-
Giulio Casella
-
Juan Hernández
-
nicolas@devels.es
-
Ondra Machacek