Class: Actions::Katello::Repository::Update

Inherits:
EntryAction
  • Object
show all
Defined in:
app/lib/actions/katello/repository/update.rb

Instance Method Summary collapse

Instance Method Details

#plan(root, repo_params) ⇒ Object

rubocop:disable Metrics/MethodLength



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/lib/actions/katello/repository/update.rb', line 6

def plan(root, repo_params)
  repository = root.library_instance
  action_subject root.library_instance

  repo_params[:url] = nil if repo_params[:url] == ''
  repo_params[:checksum_type] = nil if repo_params[:download_policy] == ::Katello::RootRepository::DOWNLOAD_ON_DEMAND
  update_cv_cert_protected = repo_params.key?(:unprotected) && (repo_params[:unprotected] != repository.unprotected)
  create_acs = create_acs?(repository.url, repo_params[:url])
  delete_acs = delete_acs?(repository.url, repo_params[:url])

  # Keep the old URL for RPM vs ULN remote cleanup
  old_url = root.url
  root.update!(repo_params)

  if update_content?(repository)
    content = root.content

    plan_action(::Actions::Candlepin::Product::ContentUpdate,
                :owner => repository.organization.label,
                :content_id => root.content_id,
                :name => root.name,
                :content_url => root.custom_content_path,
                :gpg_key_url => repository.yum_gpg_key_url,
                :label => content.label,
                :type => root.content_type,
                :arches => root.format_arches,
                :os_versions => root.os_versions&.join(',')
              )

    content.update!(name: root.name,
                               content_url: root.custom_content_path,
                               content_type: repository.content_type,
                               label: content.label,
                               gpg_url: repository.yum_gpg_key_url)
  end
  if root.pulp_update_needed?
    sequence do
      plan_action(::Actions::Pulp3::Orchestration::Repository::Update,
                       repository,
                       SmartProxy.pulp_primary)
      plan_self(:repository_id => root.library_instance.id)
      if update_cv_cert_protected
        smart_proxy = ::SmartProxy.pulp_primary
        if smart_proxy.pulp3_support?(repository)
          plan_action(::Actions::Pulp3::Orchestration::Repository::TriggerUpdateRepoCertGuard, repository, smart_proxy)
        end
      end

      handle_alternate_content_sources(repository, create_acs, delete_acs, old_url)
    end
  end
end

#runObject



59
60
61
62
63
# File 'app/lib/actions/katello/repository/update.rb', line 59

def run
  repository = ::Katello::Repository.find(input[:repository_id])
  ForemanTasks.async_task(Katello::Repository::MetadataGenerate, repository)
  repository.clear_smart_proxy_sync_histories
end