Bug 1219829 - [REGENERATE PYTHON SDK] Allow use of role names in api definitions
Summary: [REGENERATE PYTHON SDK] Allow use of role names in api definitions
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine-sdk-python
Version: 3.4.0
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ovirt-3.6.0-rc
: 3.6.0
Assignee: Juan Hernández
QA Contact: Antonin Pagac
URL:
Whiteboard:
Depends On: 1152989
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-05-08 11:44 UTC by Juan Hernández
Modified: 2016-04-20 01:28 UTC (History)
14 users (show)

Fixed In Version: ovirt-engine-sdk-python-3.6.0.0-0.15
Doc Type: Bug Fix
Doc Text:
Clone Of: 1152989
Environment:
Last Closed: 2016-04-20 01:28:43 UTC
oVirt Team: Infra
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

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.


Note You need to log in before you can comment on or make changes to this bug.