5
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
|
# File 'app/lib/actions/katello/content_view_puppet_module/destroy.rb', line 5
def plan(repository)
action_subject(repository)
repository.puppet_modules.each do |puppet_module|
library_repos = ::Katello::Repository.in_environment(repository.organization.library).
where(:pulp_id => puppet_module.repositories.map(&:pulp_id))
if library_repos.length == 1
content_view_puppet_modules = ::Katello::ContentViewPuppetModule.joins(:content_view).
where("#{::Katello::ContentView.table_name}.organization_id" => repository.organization.id).
where(:uuid => puppet_module.id.to_s)
content_view_puppet_modules.destroy_all
end
content_view_puppet_modules = ::Katello::ContentViewPuppetModule.joins(:content_view).
where("#{::Katello::ContentView.table_name}.organization_id" => repository.organization.id).
where(:name => puppet_module.name).where(:author => puppet_module.author)
if content_view_puppet_modules.any?
puppet_repoids = ::Katello::Repository.puppet_type.in_environment(repository.organization.library).
pluck(:pulp_id).reject { |repoid| repoid == repository.pulp_id }
found_puppet_module = ::Katello::PuppetModule.
latest_module(puppet_module.name, puppet_module.author, puppet_repoids)
content_view_puppet_modules.destroy_all unless found_puppet_module
end
end
end
|