Class: Actions::Katello::ContentView::RemoveRollingRepoClone

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

Instance Method Summary collapse

Instance Method Details

#plan(content_view, repository_ids, environment_ids) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/lib/actions/katello/content_view/remove_rolling_repo_clone.rb', line 5

def plan(content_view, repository_ids, environment_ids)
  clone_ids = []
  environments = ::Katello::KTEnvironment.where(id: environment_ids)
  repositories = ::Katello::Repository.where(id: repository_ids)

  sequence do
    environments.each do |environment|
      concurrence do
        repositories.each do |repository|
          clone_repo = content_view.get_repo_clone(environment, repository).first
          next if clone_repo.nil?

          clone_ids << clone_repo.id
          plan_action(Actions::Pulp3::Repository::DeleteDistributions, clone_repo.id, SmartProxy.pulp_primary)
        end
        plan_action(Candlepin::Environment::SetContent, content_view, environment, content_view.content_view_environment(environment))
      end
    end
    plan_self(repository_ids: clone_ids)
  end
end

#runObject



27
28
29
30
31
32
33
34
35
36
37
# File 'app/lib/actions/katello/content_view/remove_rolling_repo_clone.rb', line 27

def run
  ::Katello::Repository.where(id: input[:repository_ids]).each do |repository|
    SmartProxy.unscoped.with_repo(repository).each do |smart_proxy|
      next if smart_proxy.pulp_primary?

      smart_proxy.content_counts&.dig("content_view_versions", repository.content_view_version_id.to_s, "repositories")&.delete(repository.id.to_s)
      smart_proxy.save
    end
    repository.destroy!
  end
end