Skip to content

Append unique info and hash to AAP resource names#39

Merged
beeankha merged 6 commits into
ansible:mainfrom
beeankha:aap-resource-name-hash
Sep 17, 2025
Merged

Append unique info and hash to AAP resource names#39
beeankha merged 6 commits into
ansible:mainfrom
beeankha:aap-resource-name-hash

Conversation

@beeankha

@beeankha beeankha commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

Resolves AAP-51478

A new helper function for generating a unique name for an AAP resource. The function appends the resource name from the pattern definition with the collection name and pattern name, plus a short hash generated from the combination of the collection name, pattern name, collection version, and organization ID.

This new unique name is in the format of:
{original_resource_name} {collection_name}.{pattern_name} {hash}

Comment thread core/utils/controller/helpers.py
Comment thread core/task_runner.py Outdated
task.mark_running({"info": "Creating job templates"})
automations = create_job_templates(
session, instance, pattern_def, project_id, ee_id
session, instance, pattern, pattern_def, project_id, ee_id

@alinabuzachis alinabuzachis Sep 16, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I do not understand the reason you need to pass pattern instance here. Cannot you access the information needed from pattern_def already? If that's not the case, I would only pass the pattern instance and remove pattern_def, because pattern_def can be obtained pattern_def = pattern.pattern_definition inside create_job_templates.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated accordingly!

@beeankha beeankha force-pushed the aap-resource-name-hash branch from d4f6f06 to bcaa3ba Compare September 17, 2025 00:25

@abikouo abikouo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment thread core/utils/controller/helpers.py Outdated
Creates controller labels and returns model instances.
Args:
instance (PatternInstance): The PatternInstance object.
pattern (Pattern): The related Pattern object.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this something that need to be removed?

@GomathiselviS GomathiselviS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Docstring update needed. Otherwise LGTM.

@sonarqubecloud

Copy link
Copy Markdown

@beeankha beeankha merged commit 27f4d8b into ansible:main Sep 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants