Actions
Bug #27632
closedActivation Key create API is lacking parameters that are possible during update
Difficulty:
trivial
Triaged:
Yes
Pull request:
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
Actions