Sha256: 173802b9954713deb17535a58692679c0a6cf1e3d2251ba9fe554dca4d1ac719

Contents?: true

Size: 1.5 KB

Versions: 4

Compression:

Stored size: 1.5 KB

Contents

module Actions
  module Katello
    module AlternateContentSource
      class Update < Actions::EntryAction
        # smart_proxies ALWAYS represents the smart proxies to remain associated
        # after the action runs.  If smart_proxies == [], there will be none afterwards.
        def plan(acs, smart_proxies, acs_params)
          action_subject(acs)
          acs.update!(acs_params)

          smart_proxies = smart_proxies.uniq
          smart_proxies_to_add = smart_proxies - acs.smart_proxies
          smart_proxies_to_delete = acs.smart_proxies - smart_proxies
          smart_proxies_to_update = smart_proxies & acs.smart_proxies

          concurrence do
            smart_proxies_to_add&.each do |smart_proxy|
              ::Katello::SmartProxyAlternateContentSource.create(alternate_content_source_id: acs.id, smart_proxy_id: smart_proxy.id)
              plan_action(Pulp3::Orchestration::AlternateContentSource::Create,
                          acs, smart_proxy)
            end

            smart_proxies_to_delete&.each do |smart_proxy|
              plan_action(Pulp3::Orchestration::AlternateContentSource::Delete,
                          acs, smart_proxy)
            end

            smart_proxies_to_update&.each do |smart_proxy|
              plan_action(Pulp3::Orchestration::AlternateContentSource::Update,
                          acs, smart_proxy)
            end
          end
        end

        def humanized_name
          _("Update Alternate Content Source")
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
katello-4.5.1 app/lib/actions/katello/alternate_content_source/update.rb
katello-4.5.0 app/lib/actions/katello/alternate_content_source/update.rb
katello-4.5.0.rc2 app/lib/actions/katello/alternate_content_source/update.rb
katello-4.5.0.rc1 app/lib/actions/katello/alternate_content_source/update.rb