katello 3.4.2 → 3.4.4
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/rhsm/candlepin_proxies_controller.rb +1 -1
- data/app/controllers/katello/api/v2/api_controller.rb +10 -2
- data/app/controllers/katello/api/v2/capsule_content_controller.rb +1 -1
- data/app/controllers/katello/api/v2/docker_manifests_controller.rb +4 -0
- data/app/controllers/katello/api/v2/docker_tags_controller.rb +4 -5
- data/app/controllers/katello/api/v2/errata_controller.rb +3 -2
- data/app/controllers/katello/api/v2/host_packages_controller.rb +1 -1
- data/app/controllers/katello/api/v2/hosts_bulk_actions_controller.rb +2 -2
- data/app/controllers/katello/api/v2/repositories_controller.rb +1 -1
- data/app/controllers/katello/application_controller.rb +9 -501
- data/app/controllers/katello/concerns/api/v2/repository_content_controller.rb +8 -10
- data/app/helpers/katello/hosts_and_hostgroups_helper.rb +3 -3
- data/app/helpers/katello/layout_helper.rb +2 -0
- data/app/lib/actions/candlepin/consumer/update.rb +1 -0
- data/app/lib/actions/candlepin/import_pool_handler.rb +1 -1
- data/app/lib/actions/katello/capsule_content/remove_unneeded_repos.rb +1 -1
- data/app/lib/actions/katello/capsule_content/sync.rb +24 -14
- data/app/lib/actions/katello/content_view/capsule_generate_and_sync.rb +5 -4
- data/app/lib/actions/katello/content_view/errata_mail.rb +1 -1
- data/app/lib/actions/katello/content_view_puppet_environment/create.rb +3 -1
- data/app/lib/actions/katello/host/update.rb +18 -10
- data/app/lib/actions/katello/host/upload_package_profile.rb +4 -2
- data/app/lib/actions/katello/organization/manifest_refresh.rb +16 -9
- data/app/lib/actions/katello/repository/capsule_generate_and_sync.rb +5 -3
- data/app/lib/actions/katello/repository/errata_mail.rb +1 -1
- data/app/lib/actions/katello/repository/refresh_repository.rb +3 -3
- data/app/lib/actions/pulp/abstract_async_task_group.rb +18 -0
- data/app/lib/actions/pulp/consumer/sync_capsule.rb +2 -1
- data/app/lib/katello/resources/candlepin.rb +9 -6
- data/app/lib/katello/util/support.rb +1 -1
- data/app/models/katello/authorization/repository.rb +3 -3
- data/app/models/katello/concerns/operatingsystem_extensions.rb +2 -2
- data/app/models/katello/concerns/pulp_database_unit.rb +1 -1
- data/app/models/katello/docker_manifest.rb +5 -1
- data/app/models/katello/docker_meta_tag.rb +108 -0
- data/app/models/katello/docker_tag.rb +19 -1
- data/app/models/katello/erratum.rb +16 -6
- data/app/models/katello/glue/candlepin/candlepin_object.rb +12 -11
- data/app/models/katello/glue/candlepin/subscription.rb +3 -1
- data/app/models/katello/glue/provider.rb +4 -4
- data/app/models/katello/glue/pulp/repo.rb +25 -0
- data/app/models/katello/host/content_facet.rb +1 -1
- data/app/models/katello/host/subscription_facet.rb +1 -1
- data/app/models/katello/pool.rb +1 -1
- data/app/models/katello/repository.rb +8 -0
- data/app/models/katello/sync_plan.rb +2 -2
- data/app/models/setting/content.rb +1 -0
- data/app/overrides/add_about_page.rb +0 -7
- data/app/views/common/400.html +9 -0
- data/app/views/katello/api/v2/content_views/base.json.rabl +1 -1
- data/app/views/katello/api/v2/docker_tags/_base.json.rabl +11 -1
- data/app/views/katello/api/v2/repositories/base.json.rabl +1 -1
- data/config/routes/api/rhsm.rb +1 -0
- data/db/migrate/20170523182831_create_docker_meta_tag.rb +13 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-host-modal-helper.service.js +71 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts.controller.js +13 -56
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/content-hosts.routes.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-details-info.controller.js +6 -4
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html +2 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/content-views.routes.js +9 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-copy.html +3 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/docker-tags/details/views/docker-tag-info.html +27 -16
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/docker-tags/docker-tags.controller.js +12 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/docker-tags/views/docker-tags.html +4 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/details/erratum-content-hosts.controller.js +10 -4
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/errata.controller.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/host-collections/details/host-collection-details.controller.js +41 -6
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/host-collections/details/views/host-collection-info.html +11 -5
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/details/repositories/details/views/repository-manage-docker-manifests.html +4 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/products/discovery/discovery-create.controller.js +9 -11
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/subscription-content-hosts.controller.js +4 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/views/subscription-content-hosts.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/manifest/manifest-import.controller.js +26 -20
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/manifest/views/manifest-import.html +16 -12
- data/lib/katello/tasks/delete_orphaned_content.rake +8 -1
- data/lib/katello/tasks/repository.rake +20 -0
- data/lib/katello/version.rb +1 -1
- metadata +6 -6
- data/app/controllers/katello/errors_controller.rb +0 -23
- data/app/controllers/katello/failed_authentication_controller.rb +0 -51
- data/app/controllers/katello/sort_column_list.rb +0 -19
- data/app/views/overrides/about/_support_documentation.html.erb +0 -7
@@ -76,7 +76,7 @@ module Katello
|
|
76
76
|
# RecordNotUnique exceptions
|
77
77
|
def self.active_record_retry(retries = 3)
|
78
78
|
yield
|
79
|
-
rescue ActiveRecord::RecordNotUnique => e
|
79
|
+
rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid => e
|
80
80
|
retries -= 1
|
81
81
|
if retries == 0
|
82
82
|
raise e
|
@@ -22,9 +22,9 @@ module Katello
|
|
22
22
|
|
23
23
|
module ClassMethods
|
24
24
|
def readable
|
25
|
-
in_products = Repository.where(:product_id => Katello::Product.authorized(:view_products)).
|
26
|
-
in_content_views = Repository.joins(:content_view_repositories).where("#{ContentViewRepository.table_name}.content_view_id" => Katello::ContentView.readable).
|
27
|
-
in_versions = Repository.joins(:content_view_version).where("#{Katello::ContentViewVersion.table_name}.content_view_id" => Katello::ContentView.readable).
|
25
|
+
in_products = Repository.where(:product_id => Katello::Product.authorized(:view_products)).select(:id)
|
26
|
+
in_content_views = Repository.joins(:content_view_repositories).where("#{ContentViewRepository.table_name}.content_view_id" => Katello::ContentView.readable).select(:id)
|
27
|
+
in_versions = Repository.joins(:content_view_version).where("#{Katello::ContentViewVersion.table_name}.content_view_id" => Katello::ContentView.readable).select(:id)
|
28
28
|
where("#{self.table_name}.id in (?) or #{self.table_name}.id in (?) or #{self.table_name}.id in (?)", in_products, in_content_views, in_versions)
|
29
29
|
end
|
30
30
|
|
@@ -21,7 +21,7 @@ module Katello
|
|
21
21
|
provisioning_template_name = Setting["katello_default_#{kind.name}"]
|
22
22
|
end
|
23
23
|
|
24
|
-
if (template = ProvisioningTemplate.find_by_name(provisioning_template_name))
|
24
|
+
if (template = ProvisioningTemplate.unscoped.find_by_name(provisioning_template_name))
|
25
25
|
provisioning_templates << template unless provisioning_templates.include?(template)
|
26
26
|
if OsDefaultTemplate.where(:template_kind_id => kind.id, :operatingsystem_id => id).empty?
|
27
27
|
OsDefaultTemplate.create(:template_kind_id => kind.id, :provisioning_template_id => template.id, :operatingsystem_id => id)
|
@@ -29,7 +29,7 @@ module Katello
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
if (ptable = Ptable.find_by_name(Setting["katello_default_ptable"]))
|
32
|
+
if (ptable = Ptable.unscoped.find_by_name(Setting["katello_default_ptable"]))
|
33
33
|
ptables << ptable unless ptables.include?(ptable)
|
34
34
|
end
|
35
35
|
end
|
@@ -32,7 +32,7 @@ module Katello
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def in_repositories(repos)
|
35
|
-
|
35
|
+
where(:id => repository_association_class.where(:repository_id => repos).select(unit_id_field))
|
36
36
|
end
|
37
37
|
|
38
38
|
def pulp_data(uuid)
|
@@ -2,7 +2,7 @@ module Katello
|
|
2
2
|
class DockerManifest < Katello::Model
|
3
3
|
include Concerns::PulpDatabaseUnit
|
4
4
|
|
5
|
-
has_many :docker_tags, :dependent => :destroy, :class_name => "Katello::DockerTag"
|
5
|
+
has_many :docker_tags, :dependent => :destroy, :class_name => "Katello::DockerTag", :foreign_key => :docker_manifest_id
|
6
6
|
has_many :repository_docker_manifests, :dependent => :destroy
|
7
7
|
has_many :repositories, :through => :repository_docker_manifests, :inverse_of => :docker_manifests
|
8
8
|
|
@@ -21,5 +21,9 @@ module Katello
|
|
21
21
|
:downloaded => json[:downloaded]
|
22
22
|
)
|
23
23
|
end
|
24
|
+
|
25
|
+
def self.default_sort
|
26
|
+
order(:name).order(:schema_version)
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
module Katello
|
2
|
+
class DockerMetaTag < Katello::Model
|
3
|
+
include ScopedSearchExtensions
|
4
|
+
belongs_to :repository, :inverse_of => :docker_meta_tags, :class_name => "Katello::Repository"
|
5
|
+
|
6
|
+
belongs_to :schema1, :class_name => "Katello::DockerTag",
|
7
|
+
:inverse_of => :schema1_meta_tag
|
8
|
+
|
9
|
+
belongs_to :schema2, :class_name => "Katello::DockerTag",
|
10
|
+
:inverse_of => :schema2_meta_tag
|
11
|
+
|
12
|
+
def self.delegate_to_tags(*names)
|
13
|
+
names.each do |name|
|
14
|
+
define_method(name) do
|
15
|
+
if schema2
|
16
|
+
schema2.send(name)
|
17
|
+
else
|
18
|
+
schema1.send(name)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
delegate_to_tags :full_name, :docker_manifest
|
25
|
+
delegate_to_tags :product, :environment, :content_view_version
|
26
|
+
|
27
|
+
def repositories
|
28
|
+
[self.repository]
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.in_repositories(repos, grouped = false)
|
32
|
+
if grouped
|
33
|
+
search_in_tags(DockerTag.in_repositories(repos).grouped)
|
34
|
+
else
|
35
|
+
search_in_tags(DockerTag.in_repositories(repos))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.search_in_tags(tags)
|
40
|
+
sql = tags.select("#{::Katello::DockerTag.table_name}.id").to_sql
|
41
|
+
self.where("#{self.table_name}.schema1_id in (#{sql}) or #{self.table_name}.schema2_id in (#{sql})")
|
42
|
+
end
|
43
|
+
|
44
|
+
def schema1_manifest
|
45
|
+
schema1.try(:docker_manifest)
|
46
|
+
end
|
47
|
+
|
48
|
+
def schema2_manifest
|
49
|
+
schema2.try(:docker_manifest)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.with_identifiers(ids)
|
53
|
+
self.where(:id => ids)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.cleanup_tags
|
57
|
+
self.where(:schema2_id => nil, :schema1_id => nil).delete_all
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.import_meta_tags(repositories)
|
61
|
+
repositories.each do |repo|
|
62
|
+
tag_table_values = get_tag_table_values(repo)
|
63
|
+
meta_tag_table_values = DockerMetaTag.where(:repository => repo).
|
64
|
+
select(:schema1_id, :schema2_id, :name).map do |meta_tag|
|
65
|
+
[meta_tag.schema1_id, meta_tag.schema2_id, meta_tag.name]
|
66
|
+
end
|
67
|
+
|
68
|
+
# Delete [meta_tag_table_values - tag_table_values], insert [tag_table_values - meta_tag_table_values]
|
69
|
+
|
70
|
+
docker_meta_tag_arel_table = ::Katello::DockerMetaTag.arel_table
|
71
|
+
params_to_query_for_delete = (meta_tag_table_values - tag_table_values).map do |schema1, schema2, name|
|
72
|
+
conditional = docker_meta_tag_arel_table[:schema1_id].eq(schema1).and(
|
73
|
+
docker_meta_tag_arel_table[:schema2_id].eq(schema2)).and(
|
74
|
+
docker_meta_tag_arel_table[:name].eq(name)).to_sql
|
75
|
+
|
76
|
+
"(#{conditional})"
|
77
|
+
end
|
78
|
+
|
79
|
+
unless params_to_query_for_delete.empty?
|
80
|
+
::Katello::DockerMetaTag.where(:repository => repo).
|
81
|
+
where(params_to_query_for_delete.join(" OR ")).delete_all
|
82
|
+
end
|
83
|
+
|
84
|
+
(tag_table_values - meta_tag_table_values).each do |schema1, schema2, name|
|
85
|
+
DockerMetaTag.where(:schema1_id => schema1,
|
86
|
+
:schema2_id => schema2,
|
87
|
+
:name => name,
|
88
|
+
:repository => repo).create!
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.get_tag_table_values(repo)
|
94
|
+
# queries DockerTags for a repo and retuns a [schema1, schema2 , name] tuple combination
|
95
|
+
tags = ::Katello::DockerTag.where(:repository_id => repo.id)
|
96
|
+
dups = tags.group_by(&:name)
|
97
|
+
|
98
|
+
dups.map do |name, values|
|
99
|
+
if values.first.docker_manifest.schema_version == 1
|
100
|
+
schema1, schema2 = values
|
101
|
+
else
|
102
|
+
schema2, schema1 = values
|
103
|
+
end
|
104
|
+
[schema1.try(:id), schema2.try(:id), name]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -2,14 +2,22 @@ module Katello
|
|
2
2
|
class DockerTag < Katello::Model
|
3
3
|
include Concerns::PulpDatabaseUnit
|
4
4
|
include ScopedSearchExtensions
|
5
|
-
belongs_to :docker_manifest, :inverse_of => :docker_tags
|
5
|
+
belongs_to :docker_manifest, :inverse_of => :docker_tags, :class_name => "Katello::DockerManifest"
|
6
6
|
belongs_to :repository, :inverse_of => :docker_tags, :class_name => "Katello::Repository"
|
7
7
|
|
8
|
+
has_one :schema1_meta_tag, :class_name => "Katello::DockerMetaTag", :foreign_key => "schema1_id",
|
9
|
+
:inverse_of => :schema1, :dependent => :nullify
|
10
|
+
|
11
|
+
has_one :schema2_meta_tag, :class_name => "Katello::DockerMetaTag", :foreign_key => "schema2_id",
|
12
|
+
:inverse_of => :schema2, :dependent => :nullify
|
13
|
+
|
8
14
|
scoped_search :on => :name, :complete_value => true, :rename => :tag
|
9
15
|
scoped_search :relation => :docker_manifest, :on => :name, :rename => :manifest,
|
10
16
|
:complete_value => true, :only_explicit => false
|
11
17
|
scoped_search :relation => :docker_manifest, :on => :digest, :rename => :digest,
|
12
18
|
:complete_value => false, :only_explicit => true
|
19
|
+
scoped_search :relation => :docker_manifest, :on => :schema_version, :rename => :schema_version,
|
20
|
+
:complete_value => false, :only_explicit => true
|
13
21
|
scoped_search :relation => :repository, :on => :name, :rename => :repository,
|
14
22
|
:complete_value => true, :only_explicit => true
|
15
23
|
|
@@ -30,6 +38,16 @@ module Katello
|
|
30
38
|
self.save!
|
31
39
|
end
|
32
40
|
|
41
|
+
def self.import_all(uuids = nil, options = {})
|
42
|
+
super
|
43
|
+
if uuids
|
44
|
+
repos = ::Katello::Repository.joins(:docker_tags).where("katello_docker_tags.uuid" => uuids).uniq
|
45
|
+
::Katello::DockerMetaTag.import_meta_tags(repos)
|
46
|
+
else
|
47
|
+
::Katello::DockerMetaTag.import_meta_tags(::Katello::Repository.docker_type)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
33
51
|
def self.manage_repository_association
|
34
52
|
false
|
35
53
|
end
|
@@ -52,7 +52,7 @@ module Katello
|
|
52
52
|
# which is calculated elsewhere.
|
53
53
|
|
54
54
|
self.joins(:content_facets).
|
55
|
-
where("#{Katello::Host::ContentFacet.table_name}.host_id" => hosts)
|
55
|
+
where("#{Katello::Host::ContentFacet.table_name}.host_id" => hosts)
|
56
56
|
end
|
57
57
|
|
58
58
|
def self.applicable_to_hosts_dashboard(hosts)
|
@@ -89,21 +89,31 @@ module Katello
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def self.installable_for_hosts(hosts = nil)
|
92
|
+
self.where(:id => ids_installable_for_hosts(hosts))
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.ids_installable_for_hosts(hosts = nil)
|
96
|
+
hosts = ::Host.where(:id => hosts) if hosts && hosts.is_a?(Array)
|
97
|
+
|
92
98
|
# Main goal of this query
|
93
99
|
# 1) Get me the applicable errata for these set of hosts
|
94
100
|
# 2) Now further prune this list. Only include errata from repos that have been "enabled" on those hosts.
|
95
101
|
# In other words, prune the list to only include the errate in the "bound" repositories signified by
|
96
102
|
# the inner join between ContentFacetRepository and RepositoryErratum
|
97
|
-
query = self.
|
103
|
+
query = self.joins(:content_facet_errata).
|
98
104
|
joins("INNER JOIN #{Katello::ContentFacetRepository.table_name} on \
|
99
105
|
#{Katello::ContentFacetRepository.table_name}.content_facet_id = #{Katello::ContentFacetErratum.table_name}.content_facet_id").
|
100
106
|
joins("INNER JOIN #{Katello::RepositoryErratum.table_name} AS host_repo_errata ON \
|
101
107
|
host_repo_errata.erratum_id = #{Katello::Erratum.table_name}.id AND \
|
102
108
|
#{Katello::ContentFacetRepository.table_name}.repository_id = host_repo_errata.repository_id")
|
103
|
-
query = query.joins(:content_facet_errata) unless hosts
|
104
109
|
|
105
|
-
|
106
|
-
|
110
|
+
if hosts
|
111
|
+
query = query.where("#{Katello::ContentFacetRepository.table_name}.content_facet_id" => hosts.joins(:content_facet))
|
112
|
+
else
|
113
|
+
query = query.joins(:content_facet_errata)
|
114
|
+
end
|
115
|
+
|
116
|
+
query
|
107
117
|
end
|
108
118
|
|
109
119
|
def update_from_json(json)
|
@@ -113,7 +123,7 @@ module Katello
|
|
113
123
|
if self.updated.blank? || (custom_json['updated'].to_datetime != self.updated.to_datetime)
|
114
124
|
custom_json['errata_id'] = custom_json.delete('id')
|
115
125
|
custom_json['errata_type'] = custom_json.delete('type')
|
116
|
-
|
126
|
+
custom_json['updated'] = custom_json['updated'].blank? ? custom_json['issued'] : custom_json['updated']
|
117
127
|
self.update_attributes!(custom_json)
|
118
128
|
|
119
129
|
unless json['references'].blank?
|
@@ -31,19 +31,20 @@ module Katello
|
|
31
31
|
where("#{self.table_name}.id = (?) or #{self.table_name}.cp_id = (?)", id_integers, ids)
|
32
32
|
end
|
33
33
|
|
34
|
-
def import_all
|
35
|
-
|
34
|
+
def import_all(organization = nil)
|
35
|
+
organizations = organization ? [organization] : Organization.all
|
36
36
|
|
37
|
-
|
37
|
+
organizations.each do |org|
|
38
38
|
import_candlepin_ids(org.label)
|
39
|
-
candlepin_ids
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
candlepin_ids = get_candlepin_ids(org.label)
|
40
|
+
|
41
|
+
objects = self.in_organization(org) + self.where(:cp_id => candlepin_ids)
|
42
|
+
objects.uniq.each do |item|
|
43
|
+
if candlepin_ids.include?(item.cp_id)
|
44
|
+
item.import_data
|
45
|
+
else
|
46
|
+
item.destroy
|
47
|
+
end
|
47
48
|
end
|
48
49
|
end
|
49
50
|
end
|
@@ -49,7 +49,9 @@ module Katello
|
|
49
49
|
cp_product_ids.each do |cp_id|
|
50
50
|
product = ::Katello::Product.where(:cp_id => cp_id, :organization_id => self.organization_id)
|
51
51
|
if product.any?
|
52
|
-
::Katello::
|
52
|
+
::Katello::Util::Support.active_record_retry do
|
53
|
+
::Katello::SubscriptionProduct.where(:subscription_id => self.id, :product_id => product.first.id).first_or_create
|
54
|
+
end
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -191,13 +191,13 @@ module Katello
|
|
191
191
|
Rails.logger.warn "Orphaned Product id #{product.id} found while refreshing/importing manifest."
|
192
192
|
end
|
193
193
|
|
194
|
-
self.index_subscriptions
|
194
|
+
self.index_subscriptions(self.organization)
|
195
195
|
true
|
196
196
|
end
|
197
197
|
|
198
|
-
def index_subscriptions
|
199
|
-
Katello::Subscription.import_all
|
200
|
-
Katello::Pool.import_all
|
198
|
+
def index_subscriptions(organization = nil)
|
199
|
+
Katello::Subscription.import_all(organization)
|
200
|
+
Katello::Pool.import_all(organization)
|
201
201
|
end
|
202
202
|
|
203
203
|
def rules_source
|
@@ -654,6 +654,31 @@ module Katello
|
|
654
654
|
end
|
655
655
|
end
|
656
656
|
|
657
|
+
def needs_metadata_publish?
|
658
|
+
last_publish = last_publish_task.try(:[], 'finish_time')
|
659
|
+
last_sync = last_sync_task.try(:[], 'finish_time')
|
660
|
+
return false if last_sync.nil?
|
661
|
+
return true if last_publish.nil?
|
662
|
+
|
663
|
+
DateTime.parse(last_sync) >= DateTime.parse(last_publish)
|
664
|
+
end
|
665
|
+
|
666
|
+
def last_sync_task
|
667
|
+
tasks = Katello.pulp_server.extensions.repository.sync_status(self.pulp_id)
|
668
|
+
most_recent_task(tasks)
|
669
|
+
end
|
670
|
+
|
671
|
+
def last_publish_task
|
672
|
+
tasks = Katello.pulp_server.extensions.repository.publish_status(self.pulp_id)
|
673
|
+
most_recent_task(tasks, true)
|
674
|
+
end
|
675
|
+
|
676
|
+
def most_recent_task(tasks, only_successful = false)
|
677
|
+
tasks = tasks.select { |t| t['finish_time'] }.sort_by { |t| t['finish_time'] }
|
678
|
+
tasks = tasks.select { |task| task['error'].nil? } if only_successful
|
679
|
+
tasks.last
|
680
|
+
end
|
681
|
+
|
657
682
|
def filtered_distribution_config_equal?(generated_config, actual_config)
|
658
683
|
generated = generated_config.clone
|
659
684
|
actual = actual_config.clone
|
@@ -125,7 +125,7 @@ module Katello
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def self.with_non_installable_errata(errata)
|
128
|
-
subquery = Katello::Erratum.select("#{Katello::Erratum.table_name}.id").
|
128
|
+
subquery = Katello::Erratum.select("#{Katello::Erratum.table_name}.id").ids_installable_for_hosts
|
129
129
|
.where("#{Katello::ContentFacetRepository.table_name}.content_facet_id = #{Katello::Host::ContentFacet.table_name}.id").to_sql
|
130
130
|
self.joins(:applicable_errata).where("#{Katello::Erratum.table_name}.id" => errata).where("#{Katello::Erratum.table_name}.id NOT IN (#{subquery})").uniq
|
131
131
|
end
|
@@ -28,7 +28,7 @@ module Katello
|
|
28
28
|
update_guests(consumer_params)
|
29
29
|
|
30
30
|
self.autoheal = consumer_params['autoheal'] unless consumer_params['autoheal'].blank?
|
31
|
-
self.service_level = consumer_params['serviceLevel'] unless consumer_params['serviceLevel'].
|
31
|
+
self.service_level = consumer_params['serviceLevel'] unless consumer_params['serviceLevel'].nil?
|
32
32
|
self.registered_at = consumer_params['created'] unless consumer_params['created'].blank?
|
33
33
|
self.last_checkin = consumer_params['lastCheckin'] unless consumer_params['lastCheckin'].blank?
|
34
34
|
|
data/app/models/katello/pool.rb
CHANGED
@@ -7,7 +7,7 @@ module Katello
|
|
7
7
|
has_many :activation_keys, :through => :pool_activation_keys, :class_name => "Katello::ActivationKey"
|
8
8
|
has_many :pool_activation_keys, :class_name => "Katello::PoolActivationKey", :dependent => :destroy, :inverse_of => :pool
|
9
9
|
|
10
|
-
scope :
|
10
|
+
scope :in_organization, ->(org_id) { joins(:subscription).where("#{Katello::Subscription.table_name}.organization_id = ?", org_id) }
|
11
11
|
scope :for_activation_key, ->(ak) { joins(:activation_keys).where("#{Katello::ActivationKey.table_name}.id" => ak.id) }
|
12
12
|
|
13
13
|
self.include_root_in_json = false
|
@@ -64,6 +64,8 @@ module Katello
|
|
64
64
|
|
65
65
|
has_many :docker_tags, :dependent => :destroy, :class_name => "Katello::DockerTag"
|
66
66
|
|
67
|
+
has_many :docker_meta_tags, :dependent => :destroy, :class_name => "Katello::DockerMetaTag"
|
68
|
+
|
67
69
|
has_many :repository_ostree_branches, :class_name => "Katello::RepositoryOstreeBranch", :dependent => :delete_all
|
68
70
|
has_many :ostree_branches, :through => :repository_ostree_branches
|
69
71
|
|
@@ -646,6 +648,10 @@ module Katello
|
|
646
648
|
::Host.joins(:content_facet => :bound_repositories).where("#{Katello::Repository.table_name}.id" => (self.clones.pluck(:id) + [self.id]))
|
647
649
|
end
|
648
650
|
|
651
|
+
def docker_meta_tag_count
|
652
|
+
DockerMetaTag.in_repositories(self.id).count
|
653
|
+
end
|
654
|
+
|
649
655
|
protected
|
650
656
|
|
651
657
|
def removable_unit_association
|
@@ -704,7 +710,9 @@ module Katello
|
|
704
710
|
|
705
711
|
def remove_docker_content(manifests)
|
706
712
|
self.docker_tags.where(:docker_manifest_id => manifests.map(&:id)).destroy_all
|
713
|
+
DockerMetaTag.cleanup_tags
|
707
714
|
self.docker_manifests -= manifests
|
715
|
+
|
708
716
|
# destroy any orphan docker manifests
|
709
717
|
manifests.each do |manifest|
|
710
718
|
manifest.destroy if manifest.repositories.empty?
|
@@ -54,7 +54,7 @@ module Katello
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def plan_date_time
|
57
|
-
self.sync_date.strftime('%Y/%m/%d %H:%M:%S %
|
57
|
+
self.sync_date.strftime('%Y/%m/%d %H:%M:%S %z')
|
58
58
|
end
|
59
59
|
|
60
60
|
def schedule_format
|
@@ -105,7 +105,7 @@ module Katello
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def next_sync
|
108
|
-
next_sync_date.try(:strftime, '%Y/%m/%d %H:%M:%S %
|
108
|
+
next_sync_date.try(:strftime, '%Y/%m/%d %H:%M:%S %z')
|
109
109
|
end
|
110
110
|
|
111
111
|
def self.humanize_class_name(_name = nil)
|