katello 4.1.0.rc2.2 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of katello might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/controllers/katello/api/v2/content_export_incrementals_controller.rb +1 -1
- data/app/controllers/katello/api/v2/content_exports_controller.rb +1 -1
- data/app/controllers/katello/api/v2/content_imports_controller.rb +2 -2
- data/app/controllers/katello/api/v2/errata_controller.rb +2 -23
- data/app/controllers/katello/api/v2/host_errata_controller.rb +5 -32
- data/app/controllers/katello/api/v2/host_packages_controller.rb +1 -1
- data/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb +1 -1
- data/app/controllers/katello/api/v2/products_bulk_actions_controller.rb +0 -1
- data/app/controllers/katello/api/v2/repositories_controller.rb +1 -1
- data/app/controllers/katello/concerns/api/v2/host_errata_extensions.rb +41 -0
- data/app/controllers/katello/remote_execution_controller.rb +5 -9
- data/app/lib/actions/candlepin/abstract_async_task.rb +9 -1
- data/app/lib/actions/katello/agent_action.rb +2 -0
- data/app/lib/actions/katello/applicability/repository/regenerate.rb +10 -10
- data/app/lib/actions/katello/capsule_content/sync.rb +1 -1
- data/app/lib/actions/katello/host/upload_package_profile.rb +1 -6
- data/app/lib/actions/katello/host/upload_profiles.rb +2 -41
- data/app/lib/actions/katello/orphan_cleanup/remove_orphans.rb +2 -2
- data/app/lib/actions/katello/repository/check_matching_content.rb +13 -14
- data/app/lib/actions/katello/repository/sync.rb +3 -14
- data/app/lib/actions/katello/repository/verify_checksum.rb +1 -1
- data/app/lib/actions/katello/sync_plan/run.rb +7 -2
- data/app/lib/actions/pulp3/content_guard/refresh.rb +6 -10
- data/app/lib/actions/pulp3/orchestration/orphan_cleanup/remove_orphans.rb +1 -1
- data/app/lib/actions/pulp3/repository/save_version.rb +1 -0
- data/app/lib/katello/errors.rb +1 -1
- data/app/lib/katello/event_daemon/monitor.rb +1 -0
- data/app/lib/katello/event_daemon/services/agent_event_receiver.rb +6 -10
- data/app/lib/katello/util/hostgroup_facets_helper.rb +126 -0
- data/app/models/katello/authorization/content_view.rb +5 -9
- data/app/models/katello/authorization/organization.rb +4 -4
- data/app/models/katello/concerns/hostgroup_extensions.rb +3 -1
- data/app/models/katello/concerns/pulp_database_unit.rb +42 -0
- data/app/models/katello/concerns/redhat_extensions.rb +18 -10
- data/app/models/katello/erratum.rb +0 -4
- data/app/models/katello/glue/pulp/repo.rb +0 -19
- data/app/models/katello/host/content_facet.rb +11 -20
- data/app/models/katello/host_available_module_stream.rb +4 -4
- data/app/models/katello/module_stream.rb +0 -4
- data/app/models/katello/ping.rb +2 -9
- data/app/models/katello/repository.rb +14 -4
- data/app/models/katello/root_repository.rb +4 -0
- data/app/models/katello/rpm.rb +0 -4
- data/app/services/cert/certs.rb +4 -0
- data/app/services/katello/applicable_host_queue.rb +2 -2
- data/app/services/katello/pulp/yum_metadata_file.rb +6 -2
- data/app/services/katello/pulp3/api/content_guard.rb +39 -5
- data/app/services/katello/pulp3/repository/ansible_collection.rb +1 -1
- data/app/services/katello/pulp3/repository/yum.rb +1 -0
- data/app/services/katello/registration_manager.rb +4 -24
- data/app/services/katello/ui_notifications/pulp/proxy_disk_space.rb +1 -0
- data/app/views/katello/api/v2/repository_sets/show.json.rabl +9 -5
- data/config/katello.yaml.example +0 -13
- data/config/routes/api/v2.rb +0 -1
- data/db/migrate/20200514092553_move_katello_fields_from_hostgroups.katello.rb +15 -1
- data/db/migrate/20210119162528_delete_puppet_and_ostree_repos.rb +18 -22
- data/db/migrate/20210512170039_add_repo_timestamps.rb +6 -0
- data/db/migrate/20210512192745_fix_red_hat_root_repository_arch.rb +11 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-errata-modal.controller.js +26 -27
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-module-streams-modal.controller.js +1 -3
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/content-hosts-bulk-packages-modal.controller.js +1 -5
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-host-bulk-module-streams-modal.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-errata-modal.html +2 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/bulk/views/content-hosts-bulk-packages-modal.html +7 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-errata.controller.js +5 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-module-streams.controller.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/content-host-packages.controller.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-errata.html +2 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-module-streams.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-packages-actions.html +7 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content/views/content-host-packages.html +2 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/i18n/bastion_katello.pot +5 -10
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/new/new-repository.controller.js +3 -5
- data/lib/katello.rb +1 -1
- data/lib/katello/engine.rb +0 -2
- data/lib/katello/permission_creator.rb +7 -14
- data/lib/katello/plugin.rb +9 -0
- data/lib/katello/tasks/fix_hostgroup_facets.rake +8 -0
- data/lib/katello/tasks/upgrades/4.1/update_content_import_export_perms.rake +33 -0
- data/lib/katello/version.rb +1 -1
- data/locale/action_names.rb +39 -39
- data/locale/bn/katello.edit.po +114 -107
- data/locale/bn/katello.po +12 -6
- data/locale/cs/katello.edit.po +118 -115
- data/locale/cs/katello.po +12 -6
- data/locale/de/katello.edit.po +126 -136
- data/locale/de/katello.po +12 -6
- data/locale/en/katello.edit.po +114 -106
- data/locale/en/katello.po +12 -6
- data/locale/es/katello.edit.po +129 -165
- data/locale/es/katello.po +12 -6
- data/locale/fr/katello.edit.po +143 -247
- data/locale/fr/katello.po +13 -9
- data/locale/gu/katello.edit.po +114 -107
- data/locale/gu/katello.po +12 -6
- data/locale/hi/katello.edit.po +114 -107
- data/locale/hi/katello.po +12 -6
- data/locale/it/katello.edit.po +121 -131
- data/locale/it/katello.po +12 -6
- data/locale/ja/katello.edit.po +141 -229
- data/locale/ja/katello.po +13 -9
- data/locale/katello.pot +124 -114
- data/locale/kn/katello.edit.po +114 -107
- data/locale/kn/katello.po +12 -6
- data/locale/ko/katello.edit.po +126 -136
- data/locale/ko/katello.po +12 -6
- data/locale/mr/katello.edit.po +114 -107
- data/locale/mr/katello.po +12 -6
- data/locale/or/katello.edit.po +114 -107
- data/locale/or/katello.po +12 -6
- data/locale/pa/katello.edit.po +114 -107
- data/locale/pa/katello.po +12 -6
- data/locale/pt/katello.edit.po +114 -107
- data/locale/pt/katello.po +12 -6
- data/locale/pt_BR/katello.edit.po +129 -165
- data/locale/pt_BR/katello.po +12 -6
- data/locale/ru/katello.edit.po +126 -136
- data/locale/ru/katello.po +12 -6
- data/locale/ta/katello.edit.po +114 -107
- data/locale/ta/katello.po +12 -6
- data/locale/te/katello.edit.po +114 -107
- data/locale/te/katello.po +12 -6
- data/locale/zh_CN/katello.edit.po +140 -229
- data/locale/zh_CN/katello.po +13 -9
- data/locale/zh_TW/katello.edit.po +127 -153
- data/locale/zh_TW/katello.po +12 -6
- data/webpack/components/react-bootstrap-select/index.js +1 -1
- metadata +26 -18
- data/app/lib/actions/katello/host/generate_applicability.rb +0 -41
- data/app/lib/actions/katello/repository/import_applicability.rb +0 -25
- data/app/lib/actions/pulp/consumer.rb +0 -100
- data/app/lib/actions/pulp/consumer/create.rb +0 -19
- data/app/lib/actions/pulp/consumer/destroy.rb +0 -17
- data/app/lib/actions/pulp/consumer/generate_applicability.rb +0 -24
- data/app/lib/actions/pulp/consumer/update.rb +0 -20
- data/app/lib/actions/pulp3/capsule_content/refresh_content_guard.rb +0 -17
- data/app/models/katello/events/import_host_applicability.rb +0 -16
- data/app/services/katello/applicable_content_helper.rb +0 -111
- data/app/services/katello/pulp/consumer.rb +0 -83
- data/app/services/katello/pulp/consumer_group.rb +0 -95
@@ -10,8 +10,15 @@ module Katello
|
|
10
10
|
minor ||= '' # treat minor versions as empty string to not confuse with nil
|
11
11
|
os = ::Redhat.where(:name => os_name, :major => major, :minor => minor).try(:first)
|
12
12
|
return os if os
|
13
|
-
|
14
|
-
|
13
|
+
|
14
|
+
if ::Redhat.where(:title => "#{os_name} #{repo.distribution_version}").present?
|
15
|
+
description = "#{os_name} #{repo.distribution_version} #{SecureRandom.uuid}"
|
16
|
+
create_os = lambda do
|
17
|
+
::Redhat.create!(:name => os_name, :major => major, :minor => minor, :description => description)
|
18
|
+
end
|
19
|
+
else
|
20
|
+
create_os = lambda { ::Redhat.create!(:name => os_name, :major => major, :minor => minor) }
|
21
|
+
end
|
15
22
|
|
16
23
|
begin
|
17
24
|
create_os.call
|
@@ -42,10 +49,11 @@ module Katello
|
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
45
|
-
def kickstart_repos(host)
|
46
|
-
distros = distribution_repositories(host).where(distribution_bootable: true)
|
47
|
-
|
48
|
-
|
52
|
+
def kickstart_repos(host, content_facet: nil)
|
53
|
+
distros = distribution_repositories(host, content_facet: content_facet).where(distribution_bootable: true)
|
54
|
+
content_facet ||= host.content_facet
|
55
|
+
if distros && content_facet&.content_source
|
56
|
+
distros.map { |distro| distro.to_hash(content_facet.content_source) }
|
49
57
|
else
|
50
58
|
[]
|
51
59
|
end
|
@@ -62,10 +70,10 @@ module Katello
|
|
62
70
|
end
|
63
71
|
end
|
64
72
|
|
65
|
-
def distribution_repositories(host)
|
66
|
-
|
67
|
-
|
68
|
-
|
73
|
+
def distribution_repositories(host, content_facet: nil)
|
74
|
+
content_facet ||= host.content_facet
|
75
|
+
content_view = content_facet.try(:content_view) || host.try(:content_view)
|
76
|
+
lifecycle_environment = content_facet.try(:lifecycle_environment) || host.try(:lifecycle_environment)
|
69
77
|
if content_view && lifecycle_environment && host.os && host.architecture
|
70
78
|
Katello::Repository.in_environment(lifecycle_environment).in_content_views([content_view]).
|
71
79
|
where(:distribution_arch => host.architecture.name).
|
@@ -98,10 +98,6 @@ module Katello
|
|
98
98
|
where("#{Katello::ContentFacetRepository.table_name}.repository_id = #{Katello::RepositoryErratum.table_name}.repository_id")
|
99
99
|
end
|
100
100
|
|
101
|
-
def self.installable_for_hosts(hosts = nil)
|
102
|
-
ApplicableContentHelper.new(Erratum).installable_for_hosts(hosts)
|
103
|
-
end
|
104
|
-
|
105
101
|
def self.ids_installable_for_hosts(hosts = nil)
|
106
102
|
installable_for_hosts(hosts).select(:id)
|
107
103
|
end
|
@@ -73,11 +73,6 @@ module Katello
|
|
73
73
|
pulp_repo_facts['content_unit_counts']['srpm']
|
74
74
|
end
|
75
75
|
|
76
|
-
def uri
|
77
|
-
uri = URI.parse(SETTINGS[:katello][:pulp][:url])
|
78
|
-
"https://#{uri.host}/pulp/content/#{relative_path}"
|
79
|
-
end
|
80
|
-
|
81
76
|
def to_hash
|
82
77
|
pulp_repo_facts.merge(as_json).merge(:sync_state => sync_state)
|
83
78
|
end
|
@@ -355,19 +350,5 @@ module Katello
|
|
355
350
|
end
|
356
351
|
end
|
357
352
|
end
|
358
|
-
|
359
|
-
def full_path(smart_proxy = nil, force_http = false)
|
360
|
-
pulp_uri = URI.parse(smart_proxy ? smart_proxy.url : SETTINGS[:katello][:pulp][:url])
|
361
|
-
scheme = force_http ? 'http' : 'https'
|
362
|
-
if docker?
|
363
|
-
"#{pulp_uri.host.downcase}/#{container_repository_name}"
|
364
|
-
elsif ostree?
|
365
|
-
"#{scheme}://#{pulp_uri.host.downcase}/pulp/content/web/#{relative_path}"
|
366
|
-
elsif ansible_collection?
|
367
|
-
"#{scheme}://#{pulp_uri.host.downcase}/pulp_ansible/galaxy/#{relative_path}/api"
|
368
|
-
else
|
369
|
-
"#{scheme}://#{pulp_uri.host.downcase}/pulp/content/#{relative_path}/"
|
370
|
-
end
|
371
|
-
end
|
372
353
|
end
|
373
354
|
end
|
@@ -54,37 +54,22 @@ module Katello
|
|
54
54
|
end
|
55
55
|
|
56
56
|
unless self.bound_repositories.sort == repos.sort
|
57
|
-
|
57
|
+
self.bound_repositories = repos
|
58
|
+
self.save!
|
58
59
|
end
|
59
60
|
self.bound_repositories.pluck(:relative_path)
|
60
61
|
end
|
61
62
|
|
62
|
-
def propagate_yum_repos
|
63
|
-
pulp_ids = self.bound_repositories.includes(:library_instance).map { |repo| repo.library_instance.try(:pulp_id) || repo.pulp_id }
|
64
|
-
Katello::Pulp::Consumer.new(self.uuid).bind_yum_repositories(pulp_ids)
|
65
|
-
end
|
66
|
-
|
67
|
-
def update_bound_repositories(repos)
|
68
|
-
self.bound_repositories = repos
|
69
|
-
self.save!
|
70
|
-
if SETTINGS[:katello][:katello_applicability]
|
71
|
-
::Katello::EventQueue.push_event(::Katello::Events::GenerateHostApplicability::EVENT_TYPE, self.host.id)
|
72
|
-
else
|
73
|
-
self.propagate_yum_repos
|
74
|
-
ForemanTasks.async_task(Actions::Katello::Host::GenerateApplicability, [self.host])
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
63
|
def installable_errata(env = nil, content_view = nil)
|
79
|
-
|
64
|
+
Erratum.installable_for_content_facet(self, env, content_view)
|
80
65
|
end
|
81
66
|
|
82
67
|
def installable_rpms(env = nil, content_view = nil)
|
83
|
-
|
68
|
+
Rpm.installable_for_content_facet(self, env, content_view)
|
84
69
|
end
|
85
70
|
|
86
71
|
def installable_module_streams(env = nil, content_view = nil)
|
87
|
-
|
72
|
+
ModuleStream.installable_for_content_facet(self, env, content_view)
|
88
73
|
end
|
89
74
|
|
90
75
|
def errata_counts
|
@@ -97,6 +82,12 @@ module Katello
|
|
97
82
|
hash
|
98
83
|
end
|
99
84
|
|
85
|
+
def self.trigger_applicability_generation(host_ids)
|
86
|
+
host_ids = [host_ids] unless host_ids.is_a?(Array)
|
87
|
+
::Katello::ApplicableHostQueue.push_hosts(host_ids)
|
88
|
+
::Katello::EventQueue.push_event(::Katello::Events::GenerateHostApplicability::EVENT_TYPE, 0)
|
89
|
+
end
|
90
|
+
|
100
91
|
# Katello applicability
|
101
92
|
def calculate_and_import_applicability
|
102
93
|
bound_repos = bound_repositories.collect do |repo|
|
@@ -32,13 +32,13 @@ module Katello
|
|
32
32
|
def upgradable?
|
33
33
|
return false if status != ENABLED
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
ModuleStream.installable_for_hosts([host_id]).
|
36
|
+
where(ModuleStream.table_name => {:name => available_module_stream.name,
|
37
|
+
:stream => available_module_stream.stream}).exists?
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.upgradable(host)
|
41
|
-
upgradable_module_name_streams =
|
41
|
+
upgradable_module_name_streams = ModuleStream.installable_for_hosts([host]).select(:name, :stream)
|
42
42
|
|
43
43
|
enabled.joins(:available_module_stream).where(:host_id => host).
|
44
44
|
where("(#{AvailableModuleStream.table_name}.name, #{AvailableModuleStream.table_name}.stream) in (#{upgradable_module_name_streams.to_sql})")
|
@@ -41,10 +41,6 @@ module Katello
|
|
41
41
|
ContentFacetApplicableModuleStream
|
42
42
|
end
|
43
43
|
|
44
|
-
def self.installable_for_hosts(hosts = nil)
|
45
|
-
ApplicableContentHelper.new(ModuleStream).installable_for_hosts(hosts)
|
46
|
-
end
|
47
|
-
|
48
44
|
def self.available_for_hosts(hosts)
|
49
45
|
where("#{table_name}.id" => ::Katello::ModuleStream.joins(repositories: :content_facets).
|
50
46
|
select("#{table_name}.id").
|
data/app/models/katello/ping.rb
CHANGED
@@ -5,17 +5,10 @@ module Katello
|
|
5
5
|
PACKAGES = %w(katello candlepin pulp qpid foreman tfm hammer).freeze
|
6
6
|
|
7
7
|
class << self
|
8
|
-
def pulpcore_enabled # for downstream 6.9, remove in 6.10
|
9
|
-
SETTINGS[:katello][:use_pulp_2_for_content_type].nil? || (!SETTINGS[:katello][:use_pulp_2_for_content_type][:yum] &&
|
10
|
-
!SETTINGS[:katello][:use_pulp_2_for_content_type][:docker] &&
|
11
|
-
!SETTINGS[:katello][:use_pulp_2_for_content_type][:file]) ||
|
12
|
-
system('systemctl is-enabled pulpcore-api.service &>/dev/null')
|
13
|
-
end
|
14
|
-
|
15
8
|
def services(capsule_id = nil)
|
16
9
|
proxy = fetch_proxy(capsule_id)
|
17
10
|
services = [:candlepin, :candlepin_auth, :foreman_tasks, :katello_events, :candlepin_events]
|
18
|
-
services += [:pulp3] if proxy&.pulp3_enabled?
|
11
|
+
services += [:pulp3] if proxy&.pulp3_enabled?
|
19
12
|
services += [:katello_agent] if ::Katello.with_katello_agent?
|
20
13
|
if proxy.nil? || proxy.has_feature?(SmartProxy::PULP_NODE_FEATURE) || proxy.has_feature?(SmartProxy::PULP_FEATURE)
|
21
14
|
services += [:pulp, :pulp_auth]
|
@@ -73,7 +66,7 @@ module Katello
|
|
73
66
|
|
74
67
|
def ping_katello_agent(result)
|
75
68
|
exception_watch(result) do
|
76
|
-
status = Katello::EventDaemon::
|
69
|
+
status = Katello::EventDaemon::Runner.service_status(:katello_agent_events)
|
77
70
|
event_daemon_status(status, result)
|
78
71
|
end
|
79
72
|
end
|
@@ -399,6 +399,20 @@ module Katello
|
|
399
399
|
all_instances
|
400
400
|
end
|
401
401
|
|
402
|
+
def full_path(smart_proxy = nil, force_http = false)
|
403
|
+
pulp_uri = URI.parse(smart_proxy ? smart_proxy.url : ::SmartProxy.pulp_primary.url)
|
404
|
+
scheme = force_http ? 'http' : 'https'
|
405
|
+
if docker?
|
406
|
+
"#{pulp_uri.host.downcase}/#{container_repository_name}"
|
407
|
+
elsif ostree?
|
408
|
+
"#{scheme}://#{pulp_uri.host.downcase}/pulp/content/web/#{relative_path}"
|
409
|
+
elsif ansible_collection?
|
410
|
+
"#{scheme}://#{pulp_uri.host.downcase}/pulp_ansible/galaxy/#{relative_path}/api"
|
411
|
+
else
|
412
|
+
"#{scheme}://#{pulp_uri.host.downcase}/pulp/content/#{relative_path}/"
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
402
416
|
def to_hash(content_source = nil, force_http = false)
|
403
417
|
{id: id, name: label, url: full_path(content_source, force_http)}
|
404
418
|
end
|
@@ -740,10 +754,6 @@ module Katello
|
|
740
754
|
throw :abort unless destroyable?
|
741
755
|
end
|
742
756
|
|
743
|
-
def hosts_with_applicability
|
744
|
-
::Host.joins(:content_facet => :bound_repositories).where("#{Katello::Repository.table_name}.id" => (self.clones.pluck(:id) + [self.id]))
|
745
|
-
end
|
746
|
-
|
747
757
|
def docker_meta_tag_count
|
748
758
|
DockerMetaTag.in_repositories(self.id).count
|
749
759
|
end
|
@@ -156,6 +156,10 @@ module Katello
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
+
def self.hosts_with_applicability
|
160
|
+
::Host.joins(:content_facet => :bound_repositories).where("#{Katello::Repository.table_name}.root_id" => self.select(:id))
|
161
|
+
end
|
162
|
+
|
159
163
|
def ensure_no_download_policy
|
160
164
|
if !yum? && download_policy.present?
|
161
165
|
errors.add(:download_policy, _("cannot be set for non-yum repositories."))
|
data/app/models/katello/rpm.rb
CHANGED
@@ -210,10 +210,6 @@ module Katello
|
|
210
210
|
where("#{Katello::ContentFacetRepository.table_name}.repository_id = #{Katello::RepositoryRpm.table_name}.repository_id").uniq
|
211
211
|
end
|
212
212
|
|
213
|
-
def self.installable_for_hosts(hosts = nil)
|
214
|
-
ApplicableContentHelper.new(Rpm).installable_for_hosts(hosts)
|
215
|
-
end
|
216
|
-
|
217
213
|
def self.applicable_to_hosts(hosts)
|
218
214
|
self.joins(:content_facets).
|
219
215
|
where("#{Katello::Host::ContentFacet.table_name}.host_id" => hosts).distinct
|
data/app/services/cert/certs.rb
CHANGED
@@ -8,6 +8,10 @@ module Cert
|
|
8
8
|
File.read(Setting[:ssl_ca_file])
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.candlepin_client_ca_cert
|
12
|
+
File.read(SETTINGS[:katello][:candlepin][:ca_cert_file])
|
13
|
+
end
|
14
|
+
|
11
15
|
def self.ssl_client_cert
|
12
16
|
@ssl_client_cert ||= OpenSSL::X509::Certificate.new(File.read(ssl_client_cert_filename))
|
13
17
|
end
|
@@ -8,8 +8,8 @@ module Katello
|
|
8
8
|
::Katello::HostQueueElement.all.size
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.
|
12
|
-
HostQueueElement.
|
11
|
+
def self.push_hosts(ids)
|
12
|
+
HostQueueElement.import ids.map { |host_id| { host_id: host_id } }, validate: false
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.pop_hosts(amount = self.batch_size)
|
@@ -7,8 +7,12 @@ module Katello
|
|
7
7
|
shared_attributes = backend_data.keys & model.class.column_names
|
8
8
|
shared_json = backend_data.select { |key, _v| shared_attributes.include?(key) }
|
9
9
|
repo = ::Katello::Repository.find_by(:pulp_id => backend_data['repo_id']).try(:id)
|
10
|
-
|
11
|
-
|
10
|
+
filename = find_name_from_json(backend_data)
|
11
|
+
model.update!(shared_json.merge(repository_id: repo, name: filename))
|
12
|
+
if repo
|
13
|
+
Katello::YumMetadataFile.where("id != ? AND repository_id = ? AND name = ? AND checksum = ?",
|
14
|
+
model.id, repo, filename, model.checksum).delete_all
|
15
|
+
end
|
12
16
|
end
|
13
17
|
|
14
18
|
def find_name_from_json(json)
|
@@ -4,6 +4,10 @@ module Katello
|
|
4
4
|
module Pulp3
|
5
5
|
module Api
|
6
6
|
class ContentGuard < Core
|
7
|
+
def default_name
|
8
|
+
'RHSMCertGuard'
|
9
|
+
end
|
10
|
+
|
7
11
|
def self.client_module
|
8
12
|
PulpCertguardClient
|
9
13
|
end
|
@@ -20,19 +24,49 @@ module Katello
|
|
20
24
|
PulpCertguardClient::ContentguardsRhsmApi.new(api_client)
|
21
25
|
end
|
22
26
|
|
23
|
-
def
|
24
|
-
|
27
|
+
def ca_cert
|
28
|
+
Cert::Certs.candlepin_client_ca_cert
|
29
|
+
end
|
30
|
+
|
31
|
+
def refresh
|
32
|
+
found = list(name: default_name).results.first
|
33
|
+
if found && found.ca_certificate != ca_cert
|
34
|
+
partial_update(found.pulp_href)
|
35
|
+
else
|
36
|
+
found = create
|
37
|
+
end
|
38
|
+
persist_if_needed(found.pulp_href)
|
39
|
+
end
|
40
|
+
|
41
|
+
def persist_if_needed(href)
|
42
|
+
return if self.smart_proxy.pulp_mirror?
|
43
|
+
Katello::Util::Support.active_record_retry do
|
44
|
+
found = Katello::Pulp3::ContentGuard.find_by(:name => default_name)
|
45
|
+
if found
|
46
|
+
found.update(pulp_href: href)
|
47
|
+
else
|
48
|
+
Katello::Pulp3::ContentGuard.create(name: default_name, pulp_href: href)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def create(name = default_name)
|
54
|
+
data = PulpCertguardClient::CertguardRHSMCertGuard.new(name: name, ca_certificate: ca_cert)
|
25
55
|
rhsm_api_client.create(data)
|
26
56
|
rescue self.class.api_exception_class => e
|
27
|
-
|
57
|
+
if (found = list&.results&.first) #check for possible race condition
|
58
|
+
found
|
59
|
+
else
|
60
|
+
raise e
|
61
|
+
end
|
28
62
|
end
|
29
63
|
|
30
64
|
def list(options = {})
|
31
65
|
rhsm_api_client.list options
|
32
66
|
end
|
33
67
|
|
34
|
-
def partial_update(href
|
35
|
-
data = PulpCertguardClient::CertguardRHSMCertGuard.new(ca_certificate:
|
68
|
+
def partial_update(href)
|
69
|
+
data = PulpCertguardClient::CertguardRHSMCertGuard.new(ca_certificate: ca_cert)
|
36
70
|
rhsm_api_client.partial_update(href, data)
|
37
71
|
end
|
38
72
|
|
@@ -113,7 +113,6 @@ module Katello
|
|
113
113
|
|
114
114
|
# if this fails, there is not much to do about it right now. We can't really re-create the candlepin consumer.
|
115
115
|
# This can be cleaned up later via clean_backend_objects.
|
116
|
-
pulp_consumer_destory(host.content_facet.uuid) if host.content_facet.try(:uuid) && pulp2_supported?
|
117
116
|
|
118
117
|
delete_agent_queue(host) if host.content_facet.try(:uuid)
|
119
118
|
|
@@ -156,9 +155,9 @@ module Katello
|
|
156
155
|
|
157
156
|
User.as_anonymous_admin do
|
158
157
|
begin
|
159
|
-
|
158
|
+
create_in_candlepin(host, content_view_environment, consumer_params, activation_keys)
|
160
159
|
rescue StandardError => e
|
161
|
-
# we can't call CP
|
160
|
+
# we can't call CP here since something bad already happened. Just clean up our DB as best as we can.
|
162
161
|
host.subscription_facet.try(:destroy!)
|
163
162
|
new_host ? remove_partially_registered_new_host(host) : remove_host_artifacts(host)
|
164
163
|
raise e
|
@@ -174,8 +173,7 @@ module Katello
|
|
174
173
|
ping_results = Katello::Ping.ping
|
175
174
|
end
|
176
175
|
candlepin_ok = ping_results[:services][:candlepin][:status] == "ok"
|
177
|
-
|
178
|
-
candlepin_ok && pulp_ok
|
176
|
+
candlepin_ok
|
179
177
|
end
|
180
178
|
|
181
179
|
private
|
@@ -187,10 +185,6 @@ module Katello
|
|
187
185
|
Rails.logger.warn("Attempted to destroy host %s but host is already gone." % host_id)
|
188
186
|
end
|
189
187
|
|
190
|
-
def pulp2_supported?
|
191
|
-
SmartProxy.pulp_primary.has_feature?(SmartProxy::PULP_FEATURE)
|
192
|
-
end
|
193
|
-
|
194
188
|
def get_uuid(params)
|
195
189
|
params.key?(:uuid) ? params[:uuid] : SecureRandom.uuid
|
196
190
|
end
|
@@ -204,18 +198,10 @@ module Katello
|
|
204
198
|
host.subscription_facet.update_subscription_status(::Katello::SubscriptionStatus::UNKNOWN)
|
205
199
|
end
|
206
200
|
|
207
|
-
def
|
201
|
+
def create_in_candlepin(host, content_view_environment, consumer_params, activation_keys)
|
208
202
|
# if CP fails, nothing to clean up yet w.r.t. backend services
|
209
203
|
cp_create = ::Katello::Resources::Candlepin::Consumer.create(content_view_environment.cp_id, consumer_params, activation_keys.map(&:cp_name))
|
210
204
|
::Katello::Host::SubscriptionFacet.update_facts(host, consumer_params[:facts]) unless consumer_params[:facts].blank?
|
211
|
-
|
212
|
-
# if pulp fails, remove the CP consumer we just made
|
213
|
-
begin
|
214
|
-
::Katello.pulp_server.extensions.consumer.create(cp_create[:uuid], display_name: host.name) if pulp2_supported?
|
215
|
-
rescue StandardError => e
|
216
|
-
::Katello::Resources::Candlepin::Consumer.destroy(cp_create[:uuid])
|
217
|
-
raise e
|
218
|
-
end
|
219
205
|
cp_create[:uuid]
|
220
206
|
end
|
221
207
|
|
@@ -262,12 +248,6 @@ module Katello
|
|
262
248
|
Rails.logger.warn(_("Candlepin consumer %s has already been removed") % host_uuid)
|
263
249
|
end
|
264
250
|
|
265
|
-
def pulp_consumer_destory(host_uuid)
|
266
|
-
::Katello.pulp_server.extensions.consumer.delete(host_uuid)
|
267
|
-
rescue RestClient::ResourceNotFound
|
268
|
-
Rails.logger.warn(_("Pulp Consumer %s has already been removed") % host_uuid)
|
269
|
-
end
|
270
|
-
|
271
251
|
def delete_agent_queue(host)
|
272
252
|
queue_name = Katello::Agent::Dispatcher.host_queue_name(host)
|
273
253
|
Katello::EventQueue.push_event(::Katello::Events::DeleteHostAgentQueue::EVENT_TYPE, host.id) do |attrs|
|