Skip to content

Commit

Permalink
Fixes #36878 - Override host bulk destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz committed Nov 1, 2023
1 parent a261146 commit 6bf778d
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Concerns
module Api::V2::HostsControllerExtensions
extend ActiveSupport::Concern
include ForemanTasks::Triggers
require 'active_support/core_ext/string/inflections'

module Overrides
def action_permission
Expand All @@ -24,6 +25,14 @@ def destroy
process_response(:object => @host)
end

def bulk_destroy
destroyed_count = @hosts.count
@hosts.in_batches.each_record do |host|
Katello::RegistrationManager.unregister_host(host, :unregistering => false)
end
process_response(true, { :message => _("Deleted %{host_count} %{hosts}") % { :host_count => destroyed_count, :hosts => 'host'.pluralize(destroyed_count) }})
end

api :PUT, "/hosts/:host_id/host_collections", N_("Alter a host's host collections")
param :host_id, :number, :required => true, :desc => N_("The id of the host to alter")
param :host_collection_ids, Array, :required => true, :desc => N_("List of host collection ids to update")
Expand Down

0 comments on commit 6bf778d

Please sign in to comment.