Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def get_content_view_environments(label = nil, organization = nil)
end

def rhsm_params
params.slice(:name, :type, :facts, :installedProducts, :autoheal, :releaseVer, :usage, :role, :serviceLevel, :uuid, :capabilities, :guestIds, :lastCheckin).to_h
params.slice(:name, :type, :facts, :installedProducts, :releaseVer, :usage, :role, :serviceLevel, :uuid, :capabilities, :guestIds, :lastCheckin).to_h
end

def logger
Expand Down
7 changes: 2 additions & 5 deletions app/controllers/katello/api/v2/activation_keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Api::V2::ActivationKeysController < Api::V2::ApiController # rubocop:disa
before_action :verify_simple_content_access_disabled, :only => [:add_subscriptions]
before_action :validate_release_version, :only => [:create, :update]

wrap_parameters :include => (ActivationKey.attribute_names + %w(host_collection_ids service_level auto_attach purpose_role purpose_usage content_view_environments))
wrap_parameters :include => (ActivationKey.attribute_names + %w(host_collection_ids service_level purpose_role purpose_usage content_view_environments))

def_param_group :activation_key do
param :organization_id, :number, :desc => N_("organization identifier"), :required => true
Expand All @@ -22,7 +22,6 @@ class Api::V2::ActivationKeysController < Api::V2::ApiController # rubocop:disa
param :unlimited_hosts, :bool, :desc => N_("can the activation key have unlimited hosts")
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"), deprecated: true
param :purpose_usage, String, :desc => N_("Sets the system purpose usage")
param :purpose_role, String, :desc => N_("Sets the system purpose usage")

Expand Down Expand Up @@ -125,8 +124,7 @@ def copy
@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
:release_version => @activation_key.release_version
)
@activation_key.pools.each do |pool|
@new_activation_key.subscribe(pool[:id])
Expand Down Expand Up @@ -379,7 +377,6 @@ def permitted_params
:content_view_id,
:release_version,
:service_level,
:auto_attach,
:max_hosts,
:unlimited_hosts,
:purpose_role,
Expand Down
61 changes: 2 additions & 59 deletions app/controllers/katello/api/v2/host_subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Katello
class Api::V2::HostSubscriptionsController < Katello::Api::V2::ApiController
include Katello::Concerns::Api::V2::ContentOverridesController
before_action :find_host, :except => :create
before_action :check_subscriptions, :only => [:add_subscriptions, :remove_subscriptions]
before_action :find_content_view_environment, :only => :create
before_action :check_registration_services, :only => [:destroy, :create]
before_action :find_content_overrides, :only => [:content_override]
Expand All @@ -17,10 +16,9 @@ class Api::V2::HostSubscriptionsController < Katello::Api::V2::ApiController

def_param_group :subscription_facet_attributes do
param :release_version, String, :desc => N_("Release version for this Host to use (7Server, 7.1, etc)")
param :autoheal, :bool, :desc => N_("Sets whether the Host will autoheal subscriptions upon checkin")
param :purpose_usage, String, :desc => N_("Sets the system purpose usage")
param :purpose_role, String, :desc => N_("Sets the system purpose usage")
param :service_level, String, :desc => N_("Service level to be used for autoheal")
param :service_level, String, :desc => N_("Service level")
param :hypervisor_guest_uuids, Array, :desc => N_("List of hypervisor guest uuids")
param :installed_products_attributes, Array, :desc => N_("List of products installed on the host") do
param_group :installed_products, Api::V2::HostSubscriptionsController
Expand Down Expand Up @@ -51,18 +49,6 @@ def index_response(reload_host: false)
full_result_response(presenter.subscriptions)
end

api :PUT, "/hosts/:host_id/subscriptions/auto_attach", N_("Trigger an auto-attach of subscriptions"), deprecated: true
param :host_id, Integer, :desc => N_("Id of the host"), :required => true
def auto_attach
deprecate_entitlement_mode_endpoint
if @host.organization.simple_content_access?
fail ::Katello::HttpErrors::BadRequest, _("This host's organization is in Simple Content Access mode. Auto-attach is disabled")
end

sync_task(::Actions::Katello::Host::AutoAttachSubscriptions, @host)
respond_for_index(:collection => index_response(reload_host: true), :template => "index")
end

api :DELETE, "/hosts/:host_id/subscriptions/", N_("Unregister the host as a subscription consumer")
param :host_id, Integer, :desc => N_("Id of the host"), :required => true
def destroy
Expand Down Expand Up @@ -115,45 +101,6 @@ def params_to_rhsm_params
rhsm_params
end

api :PUT, "/hosts/:host_id/subscriptions/remove_subscriptions", N_("Remove subscriptions from a host"), deprecated: true
param :host_id, Integer, :desc => N_("Id of the host"), :required => true
param :subscriptions, Array, :desc => N_("Array of subscriptions to remove") do
param :id, String, :desc => N_("Subscription Pool id"), :required => true
param :quantity, Integer, :desc => N_("If specified, remove the first instance of a subscription with matching id and quantity"), :required => false
end
def remove_subscriptions
deprecate_entitlement_mode_endpoint
#combine the quantities for duplicate pools into PoolWithQuantities objects
pool_id_quantities = params.require(:subscriptions).inject({}) do |new_hash, subscription|
new_hash[subscription['id']] ||= PoolWithQuantities.new(Pool.with_identifier(subscription['id']))
new_hash[subscription['id']].quantities << subscription['quantity']
new_hash
end

sync_task(::Actions::Katello::Host::RemoveSubscriptions, @host, pool_id_quantities.values)
respond_for_index(:collection => index_response(reload_host: true), :template => "index")
end

api :PUT, "/hosts/:host_id/subscriptions/add_subscriptions", N_("Add a subscription to a host"), deprecated: true
param :host_id, Integer, :desc => N_("Id of the host"), :required => true
param :subscriptions, Array, :desc => N_("Array of subscriptions to add"), :required => true do
param :id, String, :desc => N_("Subscription Pool id"), :required => true
param :quantity, :number, :desc => N_("Quantity of this subscriptions to add"), :required => true
end
def add_subscriptions
deprecate_entitlement_mode_endpoint
if @host.organization.simple_content_access?
fail ::Katello::HttpErrors::BadRequest, _("This host's organization is in Simple Content Access mode. Attaching subscriptions is disabled.")
end

pools_with_quantities = params.require(:subscriptions).map do |sub_params|
PoolWithQuantities.new(Pool.with_identifier(sub_params['id']), sub_params['quantity'].to_i)
end

sync_task(::Actions::Katello::Host::AttachSubscriptions, @host, pools_with_quantities)
respond_for_index(:collection => index_response(reload_host: true), :template => "index")
end

api :GET, "/hosts/:host_id/subscriptions/product_content", N_("Get content and overrides for the host")
param :host_id, String, :desc => N_("Id of the host"), :required => true
param :content_access_mode_all, :bool, :desc => N_("Get all content available, not just that provided by subscriptions")
Expand Down Expand Up @@ -215,10 +162,6 @@ def find_content_view_environment
fail HttpErrors::NotFound, _("Couldn't find specified content view and lifecycle environment.") if @content_view_environment.nil?
end

def check_subscriptions
fail HttpErrors::BadRequest, _("subscriptions not specified") if params[:subscriptions].blank?
end

def check_registration_services
fail "Unable to register system, not all services available" unless Katello::RegistrationManager.check_registration_services
end
Expand All @@ -228,7 +171,7 @@ def find_host
end

def action_permission
if ['add_subscriptions', 'destroy', 'remove_subscriptions', 'auto_attach', 'content_override'].include?(params[:action])
if ['destroy', 'content_override'].include?(params[:action])
:edit
elsif ['index', 'events', 'product_content', 'available_release_versions', 'enabled_repositories'].include?(params[:action])
:view
Expand Down
43 changes: 0 additions & 43 deletions app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,49 +106,6 @@ def destroy_hosts
respond_for_async :resource => task
end

api :PUT, "/hosts/bulk/remove_subscriptions", N_("Remove subscriptions from one or more hosts"), deprecated: true
param_group :bulk_params
param :subscriptions, Array, :desc => N_("Array of subscriptions to remove") do
param :id, String, :desc => N_("Subscription Pool id"), :required => true
param :quantity, Integer, :desc => N_("Quantity of specified subscription to remove"), :required => false
end
def remove_subscriptions
#combine the quantities for duplicate pools into PoolWithQuantities objects
pool_id_quantities = params.require(:subscriptions).inject({}) do |new_hash, subscription|
new_hash[subscription['id']] ||= PoolWithQuantities.new(Pool.find(subscription['id']))
new_hash[subscription['id']].quantities << subscription['quantity']
new_hash
end
task = async_task(::Actions::BulkAction, ::Actions::Katello::Host::RemoveSubscriptions, @hosts, pool_id_quantities.values)
respond_for_async :resource => task
end

api :PUT, "/hosts/bulk/add_subscriptions", N_("Add subscriptions to one or more hosts"), deprecated: true
param_group :bulk_params
param :subscriptions, Array, :desc => N_("Array of subscriptions to add"), :required => true do
param :id, String, :desc => N_("Subscription Pool id"), :required => true
param :quantity, :number, :desc => N_("Quantity of this subscriptions to add"), :required => true
end
def add_subscriptions
if @organization.simple_content_access?
fail HttpErrors::BadRequest, _("The specified organization is in Simple Content Access mode. Attaching subscriptions is disabled")
end

pools_with_quantities = params.require(:subscriptions).map do |sub_params|
PoolWithQuantities.new(Pool.find(sub_params['id']), sub_params['quantity'])
end

task = async_task(::Actions::BulkAction, ::Actions::Katello::Host::AttachSubscriptions, @hosts, pools_with_quantities)
respond_for_async :resource => task
end

api :PUT, "/hosts/bulk/auto_attach", N_("Trigger an auto-attach of subscriptions on one or more hosts"), deprecated: true
param_group :bulk_params
def auto_attach
task = async_task(::Actions::BulkAction, ::Actions::Katello::Host::AutoAttachSubscriptions, @hosts)
respond_for_async :resource => task
end

api :PUT, "/hosts/bulk/content_overrides", N_("Set content overrides to one or more hosts")
param_group :bulk_params
param :content_overrides, Array, :desc => N_("Array of Content override parameters") do
Expand Down
2 changes: 0 additions & 2 deletions app/lib/actions/candlepin/activation_key/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module Candlepin
class ActivationKey::Create < Candlepin::Abstract
input_format do
param :organization_label
param :auto_attach
param :service_level
param :release_version
param :purpose_role
Expand All @@ -13,7 +12,6 @@ class ActivationKey::Create < Candlepin::Abstract
def run
output[:response] = ::Katello::Resources::Candlepin::ActivationKey.create(::Katello::Util::Model.uuid,
input[:organization_label],
input[:auto_attach],
input[:service_level],
input[:release_version],
input[:purpose_role],
Expand Down
2 changes: 0 additions & 2 deletions app/lib/actions/candlepin/activation_key/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class Update < Candlepin::Abstract
param :cp_id
param :release_version
param :service_level
param :auto_attach
param :purpose_role
param :purpose_usage
end
Expand All @@ -16,7 +15,6 @@ def run
input[:cp_id],
input[:release_version],
input[:service_level],
input[:auto_attach],
input[:purpose_role],
input[:purpose_usage])
end
Expand Down
1 change: 0 additions & 1 deletion app/lib/actions/katello/activation_key/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ def plan(activation_key, params = {})
activation_key.save!
cp_create = plan_action(Candlepin::ActivationKey::Create,
organization_label: activation_key.organization.label,
auto_attach: activation_key.auto_attach,
service_level: params[:service_level],
release_version: activation_key.release_version,
purpose_role: activation_key.purpose_role,
Expand Down
2 changes: 0 additions & 2 deletions app/lib/actions/katello/activation_key/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ def plan(activation_key, activation_key_params)
cp_id: activation_key.cp_id,
release_version: activation_key.release_version,
service_level: activation_key.service_level,
auto_attach: activation_key.auto_attach,
purpose_role: activation_key.purpose_role,
purpose_usage: activation_key.purpose_usage)
end
end

def update_candlepin?(activation_key, activation_key_params)
cp_changed?(activation_key.auto_attach, activation_key_params[:auto_attach]) ||
cp_changed?(activation_key.service_level, activation_key_params[:service_level]) ||
cp_changed?(activation_key.release_version, activation_key_params[:release_version]) ||
cp_changed?(activation_key.purpose_role, activation_key_params[:purpose_role]) ||
Expand Down
59 changes: 0 additions & 59 deletions app/lib/actions/katello/host/attach_subscriptions.rb

This file was deleted.

22 changes: 0 additions & 22 deletions app/lib/actions/katello/host/auto_attach_subscriptions.rb

This file was deleted.

50 changes: 0 additions & 50 deletions app/lib/actions/katello/host/remove_subscriptions.rb

This file was deleted.

Loading
Loading