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

Fix for Specifying unified_job_template as ID doesn't work #15255

Open
wants to merge 7 commits into
base: devel
Choose a base branch
from

Conversation

ppavlovrus
Copy link

SUMMARY

related #14458

Summary: set unified_job_template as value for key id in search_fields if
unified_job_template is digit

ISSUE TYPE
  • Bug
COMPONENT NAME
  • Collection
AWX VERSION
awx: 0.1.dev34000+g36b2ecb
ADDITIONAL INFORMATION

This issue described at #14458

…n't work ansible#14458

Summary: set unified_job_template as value for key id in search_fields if unified_job_template is digit

Signed-off-by: Павел Павлов <[email protected]>
@github-actions github-actions bot added component:awx_collection issues related to the collection for controlling AWX community labels Jun 5, 2024
@ppavlovrus ppavlovrus marked this pull request as ready for review June 5, 2024 11:19
@@ -262,7 +262,10 @@ def main():
search_fields['organization'] = module.resolve_name_to_id('organizations', organization)
unified_job_template_id = None
if unified_job_template:
search_fields['name'] = unified_job_template
if unified_job_template.isdigit():
Copy link
Member

Choose a reason for hiding this comment

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

module.get_one has a parameter called name_or_id. Might be better to use that instead

here is an example from a different module

host = module.get_one('hosts', name_or_id=name, check_exists=(state == 'exists'), **{'data': {'inventory': inventory_id}})

Copy link
Author

Choose a reason for hiding this comment

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

Hello, thank you for review! I changed code and it use name_or_id now

@fosterseth fosterseth self-assigned this Jun 5, 2024
Павел Павлов and others added 2 commits June 10, 2024 16:35
…n't work ansible#14458

Summary: fix after review, using name_or_id=id parameter

Signed-off-by: Павел Павлов <[email protected]>
@@ -262,8 +262,7 @@ def main():
search_fields['organization'] = module.resolve_name_to_id('organizations', organization)
unified_job_template_id = None
if unified_job_template:
search_fields['name'] = unified_job_template
unified_job_template_id = module.get_one('unified_job_templates', **{'data': search_fields})['id']
unified_job_template_id = module.get_one('unified_job_templates', name_or_id=id, **{'data': search_fields})['id']
Copy link
Member

Choose a reason for hiding this comment

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

name_or_id=id, -- id isn't a defined variable here

instead I think you want name_or_id=unified_job_template

Also, since search_fields is no longer defined, we don't need to include **{'data': search_fields}

@fosterseth
Copy link
Member

also can you provide steps on how you are verifying the change?

ppavlovrus and others added 4 commits June 13, 2024 08:48
…n't work ansible#14458

Summary: changes after review name_or_id=id changed to name_or_id=unified_jod_template

Signed-off-by: Павел Павлов <[email protected]>
…n't work ansible#14458

Summary: remove  **{'data': search_fields}

Signed-off-by: Павел Павлов <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community component:awx_collection issues related to the collection for controlling AWX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants