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

feat: support registering specifying environments with activation keys #3459

Merged
merged 1 commit into from
Sep 30, 2024

Conversation

rverdile
Copy link
Contributor

Open questions:

  • If the user specifies an activation key with one environment, and manually specifies a different environment, what should happen? Should this PR handle that case?
  • Should the validation be removed from the CLI too? Or just the internal DBus method?
  • Card-ID: CCT-762
  • Removes validation to prevent specifying environment during registration with activation key

@ptoscano
Copy link
Contributor

If the user specifies an activation key with one environment, and manually specifies a different environment, what should happen?

Nothing, since activation keys in Candlepin do not carry environments. In Katello/Satellite they work because Katello proxies the communication between systems and the actual Candlepin service.

Should the validation be removed from the CLI too? Or just the internal DBus method?

From the D-Bus service only, no CLI support in subscription-manager for now.

@rverdile
Copy link
Contributor Author

Tested this by modifying an example from here: https://github.com/jirihnidek/rhsm-dbus-examples/tree/main

Includes activation key and environment ID in registration method args

source ./library.sh

export org_id="content-sources-test"
export activation_key="mykey"
export my_addr="unix:path=/run/dbus-rIhS58MIjS,guid=46be0444115fb5cd960c4e8b66f5b542"
export env_id="ddff3bed5e0b4b59b83739d7bf5ab965"

start_register_server

# Try to register using username and password
echo "Registering using org, username and password..."
dbus-send --address=${my_addr} --print-reply --dest='com.redhat.RHSM1.Register' \
        '/com/redhat/RHSM1/Register' \
        com.redhat.RHSM1.Register.RegisterWithActivationKeys \
        string:"${org_id}" \
        array:string:"${activation_key}" \
        dict:string:string:"environments",${env_id} \
        dict:string:string:"","" \
        string:"" | gawk '/string/{ $1 = ""; print $0; }' | sed 's/\"//' | sed 's/\(.*\)\"/\1/' > /root/register_output.json

print_registration_result $?

stop_register_server

With my changes I see:

Registering using org, username and password...
Registration SUCCESS
Stopping RegisterServer..

And I can see the repo in my environment after running subscription-manager repos

Without my changes I see:

Error com.redhat.RHSM1.Error: {"exception": "ValidationError", "severity": "error", "message": "Error: Activation keys do not allow environments to be specified."}
Registration SUCCESS
Stopping RegisterServer...

@rverdile rverdile marked this pull request as ready for review September 26, 2024 20:23
* Card-ID: CCT-762
* Removes validation to prevent specifying environment during
  registration with activation key
Copy link
Contributor

@ptoscano ptoscano left a comment

Choose a reason for hiding this comment

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

Thanks!

@ptoscano ptoscano merged commit f222b57 into candlepin:main Sep 30, 2024
16 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.

2 participants