Project

General

Profile

Bug #27632

Activation Key create API is lacking parameters that are possible during update

Added by Evgeni Golov almost 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Category:
API
Target version:
Difficulty:
trivial
Triaged:
Yes
Bugzilla link:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:

Description

When creating a new Activation Key, the following params are missing (compared to updating an existing one)

    param :release_version, String, :desc => N_("content release version")
    param :service_level, String, :desc => N_("service level")
    param :auto_attach, :bool, :desc => N_("auto attach subscriptions upon registration")

If I read the underlying Katello/Candlepin code correctly, this is because Candlepin cannot set these on create. I think Katello should "fix" that for the user and execute an update after create itself, like we already do in copy:

    api :POST, "/activation_keys/:id/copy", N_("Copy an activation key")
    param :new_name, String, :desc => N_("Name of new activation key"), :required => true
    param :id, :number, :desc => N_("ID of the activation key"), :required => true
    param :organization_id, :number, :desc => N_("organization identifier"), :required => false
    def copy
      fail HttpErrors::BadRequest, _("New name cannot be blank") unless params[:new_name]
      @new_activation_key = @activation_key.copy(params[:new_name])
      @new_activation_key.user = current_user
      sync_task(::Actions::Katello::ActivationKey::Create, @new_activation_key)
      @new_activation_key.reload
      sync_task(::Actions::Katello::ActivationKey::Update, @new_activation_key,
                  :service_level   => @activation_key.service_level,
                  :release_version => @activation_key.release_version,
                  :auto_attach     => @activation_key.auto_attach
               )
      @activation_key.pools.each do |pool|
        @new_activation_key.subscribe(pool[:id])
      end
      @new_activation_key.set_content_overrides(@activation_key.content_overrides) unless @activation_key.content_overrides.blank?
      respond_for_create(:resource => @new_activation_key)
    end

Related issues

Related to Foreman - Tracker #27680: API bugs that need workarounds in foreman-ansible-modulesNew

Associated revisions

Revision 38356ed2 (diff)
Added by Jonathon Turel over 2 years ago

Fixes #27632 - Add missing Key Create API params

History

#1 Updated by Samir Jha almost 3 years ago

  • Triaged changed from No to Yes
  • Difficulty set to trivial
  • Target version set to Katello Backlog

#2 Updated by The Foreman Bot over 2 years ago

  • Assignee set to Jonathon Turel
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/8313 added

#3 Updated by The Foreman Bot over 2 years ago

  • Fixed in Releases Katello 3.14.0 added

#4 Updated by Jonathon Turel over 2 years ago

  • Status changed from Ready For Testing to Closed

#5 Updated by Evgeni Golov over 2 years ago

  • Related to Tracker #27680: API bugs that need workarounds in foreman-ansible-modules added

Also available in: Atom PDF