<div dir="ltr">Hello there,<div><br></div><div>Thanks for yours answer.</div><div><br></div><div>I will try your note.</div><div><br></div><div>We have an oVirt test installation (very litle users and few permissions, so you can count permissions) and if I try to get the permissions with the users entry point, I got a wrong number of them.</div><div><br></div><div><span style="color:rgb(80,0,80);font-size:12.8px">user_service = users_service.user_service(id=</span><a href="http://user.id/" rel="noreferrer" target="_blank" style="font-size:12.8px"><wbr>user.id</a><span style="color:rgb(80,0,80);font-size:12.8px">)</span><br style="color:rgb(80,0,80);font-size:12.8px"><br style="color:rgb(80,0,80);font-size:12.8px"><span style="color:rgb(80,0,80);font-size:12.8px">user_permissions_service = user_service.permissions_</span><wbr style="color:rgb(80,0,80);font-size:12.8px"><span style="color:rgb(80,0,80);font-size:12.8px">service()</span><br style="color:rgb(80,0,80);font-size:12.8px"><br style="color:rgb(80,0,80);font-size:12.8px"><span style="color:rgb(80,0,80);font-size:12.8px">list = user_permissions_service.list(</span><wbr style="color:rgb(80,0,80);font-size:12.8px"><span style="color:rgb(80,0,80);font-size:12.8px">)</span><br></div><div><br></div><div>The list "list" have wrong number of permissions...Do not know if this is a bug or what, I will double check later on. In case I am wrong I will be writing to you again.</div><div><br></div><div>Thanks again</div><div>Manuel</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-02-22 12:01 GMT+00:00 Ondra Machacek <span dir="ltr"><<a href="mailto:omachace@redhat.com" target="_blank">omachace@redhat.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Wed, Feb 22, 2017 at 10:16 AM, Manuel Luis Aznar<br>
<<a href="mailto:manuel.luis.aznar@gmail.com">manuel.luis.aznar@gmail.com</a>> wrote:<br>
> Hello there,<br>
><br>
> I need to remove the specific Users Permission a user have in a DataCenter.<br>
><br>
> I manage to do it in this way:<br>
><br>
> username = "..."<br>
> dc = "..."<br>
><br>
> system_service = connection.system_service()<br>
> users_service = system_service.users_service()<br>
> data_centers_service = system_service.data_centers_<wbr>service()<br>
><br>
> # Getting the User object<br>
> for user in users_service.list():<br>
> if username in user.user_name:<br>
> break<br>
><br>
> # Getting the DataCenter object<br>
> for data_center in data_centers_service.list():<br>
> if dc in <a href="http://data_center.name" rel="noreferrer" target="_blank">data_center.name</a>:<br>
> break<br>
<br>
</span>Just a note that you can use:<br>
<br>
data_center = data_centers_service.list(<wbr>search='name=dc')[0]<br>
<div><div class="h5"><br>
<br>
><br>
> # Getting DataCenter service and its Permission Service<br>
> data_center_service =<br>
> data_centers_service.data_<wbr>center_service(id=<a href="http://data_center.id" rel="noreferrer" target="_blank">data_center.<wbr>id</a>)<br>
> data_center_permissions_<wbr>service = data_center_service.<wbr>permissions_service()<br>
><br>
> # Getting the Permission for the User in the DataCenter<br>
> for data_center_permission in data_center_permissions_<wbr>service.list():<br>
> data_center_permission_user = data_center_permission.user<br>
> if data_center_permission_user:<br>
> if <a href="http://data_center_permission_user.id" rel="noreferrer" target="_blank">data_center_permission_user.id</a> == <a href="http://user.id" rel="noreferrer" target="_blank">user.id</a>:<br>
> data_center_permission_user.<wbr>remove()<br>
><br>
> As you can see I can do it, but, I am using the permissions of the<br>
> DataCenter and this list could be very long.<br>
><br>
> In the old ovirtsdk (version 3) this was done by the following:<br>
><br>
> u = kvm.users.get(id=userid)<br>
> for perm in u.permissions.list():<br>
> udc = perm.get_data_center()<br>
> if udc:<br>
> globaldc = kvm.datacenters.get(id=udc.<wbr>get_id())<br>
> if globaldc.get_name() == dc:<br>
> perm.delete()<br>
><br>
> that last piece of code iterate by the user permission list and delete the<br>
> specific Data Center permission. I have been trying this doing the<br>
> following:<br>
><br>
> user_service = users_service.user_service(id=<a href="http://user.id" rel="noreferrer" target="_blank"><wbr>user.id</a>)<br>
><br>
> user_permissions_service = user_service.permissions_<wbr>service()<br>
><br>
> list = user_permissions_service.list(<wbr>)<br>
><br>
> Is that last variable, list: the permissions list for the specified user, I<br>
> ask that because if I print the size of the list for an specific user, the<br>
> number I get is not correct...<br>
<br>
</div></div>It should work, what do you expect to see and what do you actually see?<br>
<span class=""><br>
><br>
> Thanks for all in advance to all<br>
> Manuel<br>
><br>
</span>> ______________________________<wbr>_________________<br>
> Users mailing list<br>
> <a href="mailto:Users@ovirt.org">Users@ovirt.org</a><br>
> <a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a><br>
><br>
</blockquote></div><br></div>