Class: Actions::Katello::CapsuleContent::SyncCapsule
- Inherits:
-
EntryAction
- Object
- EntryAction
- Actions::Katello::CapsuleContent::SyncCapsule
- Defined in:
- app/lib/actions/katello/capsule_content/sync_capsule.rb
Instance Method Summary collapse
- #plan(smart_proxy, options = {}) ⇒ Object
-
#repos_to_sync(smart_proxy, environment, content_view, repository, skip_metatadata_check = false) ⇒ Object
rubocop:enable Metrics/MethodLength.
- #rescue_strategy ⇒ Object
- #resource_locks ⇒ Object
- #run ⇒ Object
- #update_content_counts(_execution_plan) ⇒ Object
Instance Method Details
#plan(smart_proxy, options = {}) ⇒ Object
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 |
# File 'app/lib/actions/katello/capsule_content/sync_capsule.rb', line 7 def plan(smart_proxy, = {}) plan_self(:smart_proxy_id => smart_proxy.id, :environment_id => [:environment_id], :content_view_id => [:content_view_id], :repository_id => [:repository_id], :skip_content_counts_update => [:skip_content_counts_update]) action_subject(smart_proxy) environment = [:environment] content_view = [:content_view] repository = [:repository] = .fetch(:skip_metadata_check, false) sequence do repos = repos_to_sync(smart_proxy, environment, content_view, repository, ) return nil if repos.empty? if environment.nil? && content_view.nil? && repository.nil? [:repository_ids_list] = repos.pluck(:id) end if smart_proxy.has_feature?(SmartProxy::PULP3_FEATURE) plan_action(Actions::Pulp3::Orchestration::Repository::RefreshRepos, smart_proxy, ) end repos.in_groups_of(Setting[:foreman_proxy_content_batch_size], false) do |repo_batch| concurrence do repo_batch.each do |repo| if smart_proxy.pulp3_support?(repo) plan_action(Actions::Pulp3::CapsuleContent::Sync, repo, smart_proxy, skip_metadata_check: ) end end end concurrence do repo_batch.each do |repo| if repo.is_a?(::Katello::Repository) && repo.distribution_bootable? && repo.download_policy == ::Katello::RootRepository::DOWNLOAD_ON_DEMAND plan_action(Katello::Repository::FetchPxeFiles, id: repo.id, capsule_id: smart_proxy.id) end end end end end end |
#repos_to_sync(smart_proxy, environment, content_view, repository, skip_metatadata_check = false) ⇒ Object
rubocop:enable Metrics/MethodLength
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/lib/actions/katello/capsule_content/sync_capsule.rb', line 56 def repos_to_sync(smart_proxy, environment, content_view, repository, = false) smart_proxy_helper = ::Katello::SmartProxyHelper.new(smart_proxy) smart_proxy_helper.lifecycle_environment_check(environment, repository) if repository if || !repository.smart_proxy_sync_histories.where(:smart_proxy_id => smart_proxy).any? { |sph| !sph.finished_at.nil? } [repository] end else repositories = smart_proxy_helper.repositories_available_to_capsule(environment, content_view).by_rpm_count repositories_to_skip = [] if smart_proxy_helper.clear_smart_proxy_sync_histories repositories else repositories_to_skip = ::Katello::Repository.synced_on_capsule smart_proxy end repositories - repositories_to_skip end end |
#rescue_strategy ⇒ Object
95 96 97 |
# File 'app/lib/actions/katello/capsule_content/sync_capsule.rb', line 95 def rescue_strategy Dynflow::Action::Rescue::Skip end |
#resource_locks ⇒ Object
86 87 88 |
# File 'app/lib/actions/katello/capsule_content/sync_capsule.rb', line 86 def resource_locks :link end |
#run ⇒ Object
90 91 92 93 |
# File 'app/lib/actions/katello/capsule_content/sync_capsule.rb', line 90 def run smart_proxy = ::SmartProxy.unscoped.find(input[:smart_proxy_id]) smart_proxy.sync_container_gateway end |
#update_content_counts(_execution_plan) ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'app/lib/actions/katello/capsule_content/sync_capsule.rb', line 75 def update_content_counts(_execution_plan) if Setting[:automatic_content_count_updates] && !input[:skip_content_counts_update] smart_proxy = ::SmartProxy.unscoped.find(input[:smart_proxy_id]) = {environment_id: input[:environment_id], content_view_id: input[:content_view_id], repository_id: input[:repository_id]} ::ForemanTasks.async_task(::Actions::Katello::CapsuleContent::UpdateContentCounts, smart_proxy, ) else Rails.logger.info "Skipping content counts update as automatic content count updates are disabled. To enable automatic content count updates, set the 'automatic_content_count_updates' setting to true. To update content counts manually, run the 'Update Content Counts' action." end end |