Sha256: 2e2c4462564d031c866398413f76681b9f53c3cbde397d781cb6359f5312ff6a

Contents?: true

Size: 1.65 KB

Versions: 13

Compression:

Stored size: 1.65 KB

Contents

module Actions
  module Katello
    module Host
      class UpdateContentOverrides < Actions::EntryAction
        middleware.use Actions::Middleware::KeepCurrentUser

        def plan(host, content_override_params, prune_invalid_content_overrides = true)
          action_subject(host)
          fail _("This Host is not currently registered with subscription-manager.") unless host.subscription_facet
          plan_self(:host_id => host.id, :host_name => host.name, :content_overrides => content_override_params,
                    :prune_invalid_content_overrides => prune_invalid_content_overrides)
        end

        def run
          content_overrides = input[:content_overrides].map do |override|
            ::Katello::ContentOverride.fetch(override)
          end
          prune_invalid_content_overrides = input[:prune_invalid_content_overrides]
          host = ::Host.find(input[:host_id])
          if prune_invalid_content_overrides
            content_overrides = content_overrides.select do |override|
              host.valid_content_override_label?(override.content_label)
            end
          end

          ::Katello::Resources::Candlepin::Consumer.update_content_overrides(host.subscription_facet.uuid,
                                                                            content_overrides.map(&:to_entitlement_hash))
        end

        def humanized_name
          if input.try(:[], :host_name)
            _('Update Content Overrides to %s') % (input[:host_name] || _('Unknown'))
          else
            _('Update Content Overrides')
          end
        end

        def resource_locks
          :link
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
katello-3.9.1 app/lib/actions/katello/host/update_content_overrides.rb
katello-3.9.0 app/lib/actions/katello/host/update_content_overrides.rb
katello-3.8.1 app/lib/actions/katello/host/update_content_overrides.rb
katello-3.9.0.rc2 app/lib/actions/katello/host/update_content_overrides.rb
katello-3.9.0.rc1 app/lib/actions/katello/host/update_content_overrides.rb
katello-3.7.1.1 app/lib/actions/katello/host/update_content_overrides.rb
katello-3.7.1 app/lib/actions/katello/host/update_content_overrides.rb
katello-3.8.0 app/lib/actions/katello/host/update_content_overrides.rb
katello-3.8.0.rc3 app/lib/actions/katello/host/update_content_overrides.rb
katello-3.8.0.rc2 app/lib/actions/katello/host/update_content_overrides.rb
katello-3.7.0 app/lib/actions/katello/host/update_content_overrides.rb
katello-3.8.0.rc1 app/lib/actions/katello/host/update_content_overrides.rb
katello-3.7.0.rc2 app/lib/actions/katello/host/update_content_overrides.rb