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

Use upstream terminology #3351

Merged
merged 5 commits into from
Oct 9, 2024

Conversation

maximiliankolb
Copy link
Contributor

@maximiliankolb maximiliankolb commented Oct 7, 2024

What changes are you introducing?

Use attributes in favor of hardcoded branded variable names.

Why are you introducing these changes? (Explanation, links to references, issues, etc.)

Fixes branding issues upstream+downstream.

Anything else to add? (Considerations, potential downsides, alternative solutions you have explored, etc.)

Checklists

  • I am okay with my commits getting squashed when you merge this PR.
  • I am familiar with the contributing guidelines.

Please cherry-pick my commits into:

  • Foreman 3.12/Katello 4.14 (Satellite 6.16)
  • Foreman 3.11/Katello 4.13
  • Foreman 3.10/Katello 4.12
  • Foreman 3.9/Katello 4.11 (Satellite 6.15; orcharhino 6.8/6.9/6.10)
  • Foreman 3.8/Katello 4.10
  • Foreman 3.7/Katello 4.9 (Satellite 6.14)
  • Foreman 3.6/Katello 4.8
  • Foreman 3.5/Katello 4.7 (Satellite 6.13; orcharhino 6.6/6.7)
  • We do not accept PRs for Foreman older than 3.5.

Copy link
Contributor

@Lennonka Lennonka left a comment

Choose a reason for hiding this comment

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

Build looking great! Just one small request.

guides/common/modules/proc_calling-the-api-in-python.adoc Outdated Show resolved Hide resolved
Copy link
Contributor Author

@maximiliankolb maximiliankolb left a comment

Choose a reason for hiding this comment

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

Applied Ewoud's suggestions. Kindly asking for a re-review.

guides/common/modules/proc_calling-the-api-in-python.adoc Outdated Show resolved Hide resolved
guides/common/modules/proc_calling-the-api-in-python.adoc Outdated Show resolved Hide resolved
guides/common/modules/proc_calling-the-api-in-python.adoc Outdated Show resolved Hide resolved
# URL for the API to your deployed {ProjectX} server
{project-allcaps}_API = f"\{URL}/katello/api/v2/"
# Katello-specific API
FOREMAN_API = f"\{URL}/katello/api/v2/"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
FOREMAN_API = f"\{URL}/katello/api/v2/"
FOREMAN_API = f"\{URL}/api/"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. The URL was borked :D

Copy link
Contributor

Choose a reason for hiding this comment

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

Bo-what? :D However, I'm not sure how this change will impact the rest of the script.

Copy link
Contributor

Choose a reason for hiding this comment

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

The thing is that I wonder about the following:

  • {FOREMAN_API}/organizations should be okay
  • but I guess that you need Katello to work with environments {KATELLO_API}/organizations/{org_id}/environments/

Let me verify this in the API doc.

Copy link
Contributor

Choose a reason for hiding this comment

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

A-ha!
image

@maximiliankolb maximiliankolb force-pushed the use_upstream_terminology branch from 5940328 to 1b834d0 Compare October 7, 2024 13:24
Copy link
Contributor

@Lennonka Lennonka left a comment

Choose a reason for hiding this comment

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

This prefix needs to be changed to Katello.

guides/common/modules/proc_calling-the-api-in-python.adoc Outdated Show resolved Hide resolved
guides/common/modules/proc_calling-the-api-in-python.adoc Outdated Show resolved Hide resolved
@pr-processor pr-processor bot added the Waiting on contributor Requires an action from the author label Oct 7, 2024
@pr-processor pr-processor bot added Needs re-review and removed Waiting on contributor Requires an action from the author labels Oct 7, 2024
Copy link
Contributor Author

@maximiliankolb maximiliankolb left a comment

Choose a reason for hiding this comment

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

Thanks for checking; I've applied both your suggestions. @Lennonka

guides/common/modules/proc_calling-the-api-in-python.adoc Outdated Show resolved Hide resolved
guides/common/modules/proc_calling-the-api-in-python.adoc Outdated Show resolved Hide resolved
Copy link
Contributor

@Lennonka Lennonka left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!

SATID=$(hammer --csv template list --per-page=1000 | grep "provision" | grep ",Kickstart default" | cut -d, -f1)
PARTID=$(hammer --csv partition-table list | grep "{client-provisioning-template-type} default," | cut -d, -f1)
PXEID=$(hammer --csv template list --per-page=1000 | grep "{client-provisioning-template-type} default PXELinux" | cut -d, -f1)
{project-allcaps}_ID=$(hammer --csv template list --per-page=1000 | grep "provision" | grep ",{client-provisioning-template-type} default" | cut -d, -f1)
Copy link
Member

Choose a reason for hiding this comment

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

Previously it was named SAT_ID but, isn't this really the TEMPLATE_ID or even PROVISION_TEMPLATE_ID?

Also, this really goes beyond the scope of this PR but I really dislike that it's using grep to "search" in combination with a very large per page number.

I don't have a setup at hand to test it and there there may be a better way, but I'd suggest to try

Suggested change
{project-allcaps}_ID=$(hammer --csv template list --per-page=1000 | grep "provision" | grep ",{client-provisioning-template-type} default" | cut -d, -f1)
PROVISION_TEMPLATE_ID=$(hammer --csv --no-headers template list --search 'name = "{client-provisioning-template-type} default"' --fields=Id --per-page 1)

Perhaps @ofedoren has some better recommendation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Input on improving the templates is very much appreciated. For this PR, it is out of scope but I will keep this thread open and apply feedback later if necessary.

I have two possible follow-up changes in mind:

  • Extract the actual code into snippets with a specific naming scheme, for example, snip_code_x-y.adoc and write some minor automation to at least lint the code using flake8/black/rubocop. Next step would be to automatically run this code on a Foreman/Katello instance.
  • Deliver this code, similar to bin/katello-certs-check in foreman-installer, via RPM. We actually spoke about automating a procedure, I believe it was Salt or Ubuntu-related, in the past @ekohl.

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to recommend foreman-ansible-modules (or Red Hat's commercially supported branded equivalent). If you look at theforeman/forklift#1856 you can see it's way easier to maintain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, FAM works great. We use that downstream/internally quite a bit. However, as part of the Foreman API guide, I don't think we want to show FAM examples (even though FAM also uses the Foreman/Katello API internally). I think a FAM example would be nice in https://docs.theforeman.org/nightly/Administering_Project/index-katello.html#Managing_Project_with_Ansible_Collections_admin

Is it OK to open an issue and move this discussion/implementation to another issue/PR?

Copy link
Member

Choose a reason for hiding this comment

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

Hammer and FAM both use the API. If you're take that position, I think Hammer shouldn't be in the API guide either. But it's not: https://docs.theforeman.org/nightly/Provisioning_Hosts/index-katello.html#updating-the-details-of-multiple-operating-systems_provisioning

I think guiding users to FAM instead of writing shell scripts is a better solution, but agree it's out of scope for this PR.

@maximiliankolb maximiliankolb added the style review done No issues from docs style/grammar perspective label Oct 9, 2024
@maximiliankolb maximiliankolb merged commit e063255 into theforeman:master Oct 9, 2024
9 checks passed
@maximiliankolb maximiliankolb deleted the use_upstream_terminology branch October 9, 2024 13:01
maximiliankolb added a commit that referenced this pull request Oct 9, 2024
* Use attributes in favor of branded variable names
* Use attribute in favor of Kickstart
* Rename variable in Python script
* Fix Foreman API URL for Python example script
* Fix attribute for Katello API URL

Possible follow-up tasks:

* Rename more variables in Python scripts
* Use buillt-in search in Hammer in favor of grep in the result

(cherry picked from commit e063255)
@maximiliankolb
Copy link
Contributor Author

Merged to "master" and cherry-picked:
2378756..9bd717a 3.12 -> 3.12

Did not cherry-pick to 3.11 because a) one file is not even present and b) build fails due to a missing attribute.

@maximiliankolb maximiliankolb mentioned this pull request Oct 18, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
style review done No issues from docs style/grammar perspective
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants