Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1219829

Summary: [REGENERATE PYTHON SDK] Allow use of role names in api definitions
Product: Red Hat Enterprise Virtualization Manager Reporter: Juan Hernández <juan.hernandez>
Component: ovirt-engine-sdk-pythonAssignee: Juan Hernández <juan.hernandez>
Status: CLOSED CURRENTRELEASE QA Contact: Antonin Pagac <apagac>
Severity: medium Docs Contact:
Priority: medium    
Version: 3.4.0CC: apagac, bazulay, gassmann, gklein, juan.hernandez, lsurette, oourfali, pmukhedk, rbalakri, Rhev-m-bugs, sherold, srevivo, ykaul, ylavi
Target Milestone: ovirt-3.6.0-rc   
Target Release: 3.6.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: ovirt-engine-sdk-python-3.6.0.0-0.15 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1152989 Environment:
Last Closed: 2016-04-20 01:28:43 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1152989    
Bug Blocks:    

Description Juan Hernández 2015-05-08 11:44:27 UTC
+++ This bug was initially created as a clone of Bug #1152989 +++

Description of problem:

Currently, If we want to add the role "UserVmManager" to a group we need to get the Id of that role first.

Current API:

<permission>
    <role id="00000000-0000-0000-0000-000000000001" />
    <group id="abee5751-3857-46dd-abaa-03f57bca2e86"/>
</permission>

I would like to directly use the role name:

<permission>
    <role><name>UserVmManager</name></role>
    <group id="abee5751-3857-46dd-abaa-03f57bca2e86"/>
</permission>

with most other resource references this already works, For example,
network can be referenced by id or by name: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Virtualization/3.4/html-single/Technical_Guide/index.html#sect-Networks_Sub-Collection

why not roles than?

Comment 1 Antonin Pagac 2015-07-07 12:56:22 UTC
ovirt-engine-sdk-python-3.6.0.0-0.15.20150625.gitfc90daf.el6.noarch

Juan, can you please specify how to test this change in python sdk? I am able to add permission using:

perm = Permission(role=api.roles.get("VmCreator"), user=api.users.get("myuser"))
api.permissions.add(perm)

However, I think this was possible also in previous versions of the sdk.

Comment 2 Juan Hernández 2015-07-07 13:13:32 UTC
When you call api.roles.get("VmCreator") you are getting the complete role representation, including the name and the id. If you then pass this representation to the api.permissions.add(...) method then the server will use the id and ignore the name, that is why this worked in previous versions of the SDK. To verify the name is used correctly with the Python SDK you need to make sure that you are providing only the name, and not the id:

  api.permission.add(
    role=params.Role(
      name="VmCreator"
    ),
    ...
  )

Comment 3 Antonin Pagac 2015-07-07 13:50:27 UTC
ovirt-engine-sdk-python-3.6.0.0-0.15.20150625.gitfc90daf.el6.noarch

Thanks Juan - verified.