Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create galaxy_ng specific Roles #1058

Merged
merged 7 commits into from
Mar 17, 2022

Conversation

bmclaughlin
Copy link
Contributor

Before:

galaxy_ng=# select pulp_id, name, description, locked from core_role;
               pulp_id                |        name        |         description          | locked 
--------------------------------------+--------------------+------------------------------+--------
 f471e6df-ecb2-457e-b6f1-92b9b31ca9bd | core.group_creator |                              | t
 e9f09348-f77f-4047-a180-b35cd2981902 | core.group_owner   |                              | t
 de17876c-32ab-4d46-97da-492a566663dd | core.group_viewer  |                              | t
 170ac59c-b34c-4c5e-aa22-c8504232569d | core.task_owner    | Allow all actions on a task. | t
 cb9e3ed5-14ba-471e-a245-ffc28404e7f7 | core.task_viewer   |                              | t
(5 rows)

galaxy_ng=# select * from core_role_permissions;
 id |               role_id                | permission_id 
----+--------------------------------------+---------------
  1 | f471e6df-ecb2-457e-b6f1-92b9b31ca9bd |            54
  2 | e9f09348-f77f-4047-a180-b35cd2981902 |            56
  3 | e9f09348-f77f-4047-a180-b35cd2981902 |            57
  4 | e9f09348-f77f-4047-a180-b35cd2981902 |            55
  5 | de17876c-32ab-4d46-97da-492a566663dd |            57
  6 | 170ac59c-b34c-4c5e-aa22-c8504232569d |           168
  7 | 170ac59c-b34c-4c5e-aa22-c8504232569d |           169
  8 | 170ac59c-b34c-4c5e-aa22-c8504232569d |           170
  9 | 170ac59c-b34c-4c5e-aa22-c8504232569d |           167
 10 | cb9e3ed5-14ba-471e-a245-ffc28404e7f7 |           169
(10 rows)

After:

galaxy_ng=# select pulp_id, name, description, locked from core_role;
               pulp_id                |           name           |         description          | locked 
--------------------------------------+--------------------------+------------------------------+--------
 43b605e5-c4e9-478d-a696-5fa5b0e543e0 | core.group_creator       |                              | t
 37684011-d3bc-4a6b-ae2c-87f89659c14a | core.group_owner         |                              | t
 cafdd558-dd56-4ee7-9aec-c0b1607c8172 | core.group_viewer        |                              | t
 3a1ecb09-d19e-47da-b1c4-957540516fe8 | core.task_owner          | Allow all actions on a task. | t
 92d3c988-ec43-438b-b892-b6d05067b88a | core.task_viewer         |                              | t
 ee9bfb71-2af7-46bc-a911-33e6d799f60b | galaxy.namespace_creator |                              | t
 53e54e0a-851e-46c7-bbed-f90b5d9430eb | galaxy.namespace_owner   |                              | t
 40fa672b-f4ed-46a5-a17c-f889c0b3e75a | galaxy.namespace_updater |                              | t
 9c4a5986-c1aa-44ac-be05-b7dfa13c7329 | galaxy.collection_delete |                              | t
 67378630-3911-4ff0-b792-036dde01b64d | galaxy.collection_mover  |                              | t
(10 rows)

galaxy_ng=# select * from core_role_permissions;
 id |               role_id                | permission_id 
----+--------------------------------------+---------------
  1 | 43b605e5-c4e9-478d-a696-5fa5b0e543e0 |            54
  2 | 37684011-d3bc-4a6b-ae2c-87f89659c14a |            56
  3 | 37684011-d3bc-4a6b-ae2c-87f89659c14a |            57
  4 | 37684011-d3bc-4a6b-ae2c-87f89659c14a |            55
  5 | cafdd558-dd56-4ee7-9aec-c0b1607c8172 |            57
  6 | 3a1ecb09-d19e-47da-b1c4-957540516fe8 |           168
  7 | 3a1ecb09-d19e-47da-b1c4-957540516fe8 |           169
  8 | 3a1ecb09-d19e-47da-b1c4-957540516fe8 |           170
  9 | 3a1ecb09-d19e-47da-b1c4-957540516fe8 |           167
 10 | 92d3c988-ec43-438b-b892-b6d05067b88a |           169
 11 | ee9bfb71-2af7-46bc-a911-33e6d799f60b |           324
 12 | 53e54e0a-851e-46c7-bbed-f90b5d9430eb |           324
 13 | 53e54e0a-851e-46c7-bbed-f90b5d9430eb |           325
 14 | 53e54e0a-851e-46c7-bbed-f90b5d9430eb |           326
 15 | 40fa672b-f4ed-46a5-a17c-f889c0b3e75a |           325
 16 | 9c4a5986-c1aa-44ac-be05-b7dfa13c7329 |            19
 17 | 67378630-3911-4ff0-b792-036dde01b64d |            33
(17 rows)

Issue: AAH-1092

locked_roles = GALAXY_VIEWSETS[viewset]['LOCKED_ROLES']
if locked_roles is not None:
desired_roles.update(locked_roles or {})
adjust_roles(apps, role_prefix, desired_roles, 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use either of these (or if you really want to shut it up pass it as kwarg verbosity=0.)

Suggested change
adjust_roles(apps, role_prefix, desired_roles, 0)
adjust_roles(apps, role_prefix, desired_roles)
Suggested change
adjust_roles(apps, role_prefix, desired_roles, 0)
adjust_roles(apps, role_prefix, desired_roles, verbosity=kwargs.get("verbosity", 0))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this. I meant to correct it before opening the PR...

@bmclaughlin bmclaughlin force-pushed the aah-1092-poc-define-system-roles branch from 3a8521e to 02666fc Compare January 6, 2022 20:31
@bmclaughlin
Copy link
Contributor Author

@mdellweg Can adjust_roles be made available via pulpcore.plugin?

@mdellweg
Copy link

mdellweg commented Jan 7, 2022

@mdellweg Can adjust_roles be made available via pulpcore.plugin?

I guess so. can you file a request for this?

@bmclaughlin
Copy link
Contributor Author

@@ -48,6 +50,26 @@ def create_namespace_if_not_present(sender, instance, created, **kwargs):
Namespace.objects.get_or_create(name=instance.namespace)


def set_role_definitions(sender, **kwargs):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized, you could do

Suggested change
def set_role_definitions(sender, **kwargs):
def set_role_definitions(sender, apps=None, verbosity=1, **kwargs):

instead of the kwargs.get. (Just a matter of preference...)

@mdellweg
Copy link

mdellweg commented Jan 7, 2022

@mdellweg Created https://pulp.plan.io/issues/9665

pulp/pulpcore#1802

@bmclaughlin bmclaughlin changed the title PoC to create galaxy_ng specific Roles Create galaxy_ng specific Roles Jan 10, 2022
@bmclaughlin bmclaughlin force-pushed the aah-1092-poc-define-system-roles branch 3 times, most recently from fcc5e8e to 126156c Compare January 13, 2022 15:31
@bmclaughlin
Copy link
Contributor Author

/retest

@bmclaughlin bmclaughlin marked this pull request as ready for review January 13, 2022 15:49
@bmclaughlin bmclaughlin force-pushed the aah-1092-poc-define-system-roles branch 4 times, most recently from aad4e50 to 0b8f56f Compare March 7, 2022 14:45
@bmclaughlin bmclaughlin force-pushed the aah-1092-poc-define-system-roles branch 9 times, most recently from 6d74484 to 509d1a3 Compare March 7, 2022 19:48
@bmclaughlin bmclaughlin force-pushed the aah-1092-poc-define-system-roles branch 4 times, most recently from 743f987 to 36ef4c4 Compare March 8, 2022 15:21
@bmclaughlin
Copy link
Contributor Author

/retest

@bmclaughlin bmclaughlin force-pushed the aah-1092-poc-define-system-roles branch 5 times, most recently from 3f4d717 to 5fc46da Compare March 9, 2022 19:22
@bmclaughlin
Copy link
Contributor Author

/retest

@bmclaughlin bmclaughlin force-pushed the aah-1092-poc-define-system-roles branch from 5fc46da to 1b2e1e8 Compare March 16, 2022 14:12
@awcrosby awcrosby merged commit 3fefab0 into ansible:master Mar 17, 2022
@bmclaughlin bmclaughlin deleted the aah-1092-poc-define-system-roles branch March 17, 2022 18:59
@mdellweg
Copy link

🗞️ 🎢 🛼
So glad to see this work in action!

newswangerd added a commit to newswangerd/galaxy_ng that referenced this pull request Apr 11, 2022
Revert "Create galaxy_ng specific Roles (ansible#1058)"

This reverts commit 3fefab0.

No-Issue
newswangerd added a commit that referenced this pull request Apr 11, 2022
* Revert "Remove django guardian (#1057)". This reverts commit d84dee6.
* Revert "Create galaxy_ng specific Roles (#1058)". This reverts commit 3fefab0.

No-Issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants