Class: Actions::Katello::Applicability::Hosts::BulkGenerate
- Inherits:
-
EntryAction
- Object
- EntryAction
- Actions::Katello::Applicability::Hosts::BulkGenerate
- Defined in:
- app/lib/actions/katello/applicability/hosts/bulk_generate.rb
Instance Method Summary collapse
- #hostname(host_id) ⇒ Object
- #humanized_name ⇒ Object
- #queue ⇒ Object
- #rescue_strategy ⇒ Object
- #resource_locks ⇒ Object
- #run ⇒ Object
Instance Method Details
#hostname(host_id) ⇒ Object
39 40 41 42 |
# File 'app/lib/actions/katello/applicability/hosts/bulk_generate.rb', line 39 def hostname(host_id) content_facet = ::Katello::Host::ContentFacet.find_by_host_id(host_id) content_facet&.host&.name end |
#humanized_name ⇒ Object
44 45 46 47 48 49 50 |
# File 'app/lib/actions/katello/applicability/hosts/bulk_generate.rb', line 44 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 |
#queue ⇒ Object
31 32 33 |
# File 'app/lib/actions/katello/applicability/hosts/bulk_generate.rb', line 31 def queue ::Katello::HOST_TASKS_QUEUE end |
#rescue_strategy ⇒ Object
27 28 29 |
# File 'app/lib/actions/katello/applicability/hosts/bulk_generate.rb', line 27 def rescue_strategy Dynflow::Action::Rescue::Skip end |
#resource_locks ⇒ Object
35 36 37 |
# File 'app/lib/actions/katello/applicability/hosts/bulk_generate.rb', line 35 def resource_locks :link end |
#run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/lib/actions/katello/applicability/hosts/bulk_generate.rb', line 10 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.}") error = true end fail "Error calculating applicability for one or more hosts" if error end |