Sha256: 0f982b924471aa1ff5bea79b77c80a5b73ce6c0a8cab372993e738babe161001

Contents?: true

Size: 1.71 KB

Versions: 22

Compression:

Stored size: 1.71 KB

Contents

module Actions
  module Katello
    module Applicability
      module Hosts
        class BulkGenerate < Actions::EntryAction
          input_format do
            param :host_ids, Array
          end

          def run
            error = false
            input[:host_ids].each do |host_id|
              content_facet = ::Katello::Host::ContentFacet.find_by_host_id(host_id)
              if content_facet.present?
                # Catch errors and log them, but continue processing the rest of the hosts
                content_facet.calculate_and_import_applicability
              else
                Rails.logger.warn(_("Content Facet for host with id %s is non-existent. Skipping applicability calculation.") % host_id)
              end
            rescue NoMethodError, PG::Error => e
              Rails.logger.error("Error calculating applicability for host #{host_id}: #{e.message}")
              error = true
            end
            fail "Error calculating applicability for one or more hosts" if error
          end

          def rescue_strategy
            Dynflow::Action::Rescue::Skip
          end

          def queue
            ::Katello::HOST_TASKS_QUEUE
          end

          def resource_locks
            :link
          end

          def hostname(host_id)
            content_facet = ::Katello::Host::ContentFacet.find_by_host_id(host_id)
            content_facet&.host&.name
          end

          def humanized_name
            if input && input[:host_ids]&.length == 1
              _("Bulk generate applicability for host %s" % hostname(input[:host_ids]&.first))
            else
              _("Bulk generate applicability for hosts")
            end
          end
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
katello-4.14.2 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.15.0 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.15.0.rc2 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.15.0.rc1 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.14.1 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.14.0 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.14.0.rc3 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.14.0.rc2 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.14.0.rc1.1 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.14.0.rc1 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.13.1 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.13.0 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.12.1 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.13.0.rc1 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.12.0 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.12.0.rc3 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.12.0.rc2 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.12.0.rc1 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.11.1 app/lib/actions/katello/applicability/hosts/bulk_generate.rb
katello-4.11.0 app/lib/actions/katello/applicability/hosts/bulk_generate.rb