katello 3.5.0.1 → 3.5.1
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/README.md +5 -5
- data/app/controllers/katello/api/v2/activation_keys_controller.rb +1 -1
- data/app/controllers/katello/api/v2/docker_tags_controller.rb +1 -1
- data/app/lib/actions/katello/host/register.rb +2 -1
- data/app/lib/actions/katello/repository/check_matching_content.rb +1 -1
- data/app/lib/actions/katello/repository/sync.rb +3 -2
- data/app/lib/katello/util/package_clause_generator.rb +0 -1
- data/app/lib/katello/validators/content_view_environment_validator.rb +3 -3
- data/app/models/katello/activation_key.rb +3 -2
- data/app/models/katello/concerns/content_facet_host_extensions.rb +1 -1
- data/app/models/katello/concerns/host_managed_extensions.rb +13 -22
- data/app/models/katello/concerns/smart_proxy_extensions.rb +3 -0
- data/app/models/katello/content_view.rb +8 -0
- data/app/models/katello/content_view_erratum_filter.rb +44 -28
- data/app/models/katello/erratum.rb +7 -3
- data/app/models/katello/glue/candlepin/pool.rb +9 -5
- data/app/models/katello/glue/provider.rb +0 -10
- data/app/models/katello/glue/pulp/repo.rb +4 -23
- data/app/models/katello/glue/pulp/repos.rb +0 -20
- data/app/models/katello/pool.rb +0 -4
- data/app/models/setting/content.rb +0 -2
- data/app/views/dashboard/_host_collection_widget.html.erb +3 -3
- data/app/views/katello/api/v2/content_views/base.json.rabl +2 -1
- data/app/views/katello/api/v2/subscriptions/base.json.rabl +7 -0
- data/db/migrate/20171114150937_cleanup_installed_packages.rb +55 -0
- data/db/migrate/20171114183353_add_hypervisor_id_to_katello_pools.rb +9 -0
- data/db/migrate/20171211124439_add_uuid_index_to_katello_subscription_facets.rb +5 -0
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/activation-keys.routes.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/activation-keys/details/activation-key-host-collections.controller.js +3 -2
- 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/content/content-host-traces.controller.js +18 -4
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/content-host-add-host-collections.controller.js +3 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-hosts/details/views/content-host-info.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/filters/views/filter-repositories.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-details-tasks.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-repositories.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/versions/views/content-view-version-yum.html +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/host-collections/details/host-collection-add-hosts.controller.js +3 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/details/views/subscription-info.html +2 -2
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/subscriptions.routes.js +1 -1
- data/engines/bastion_katello/app/assets/javascripts/bastion_katello/subscriptions/views/subscription-type.html +4 -4
- data/lib/katello/permissions/host_permissions.rb +4 -4
- data/lib/katello/tasks/update_subscription_facet_backend_data.rake +4 -3
- data/lib/katello/tasks/upgrades/3.0/update_subscription_facet_backend_data.rake +2 -58
- data/lib/katello/tasks/upgrades/3.4/reindex_docker_tags.rake +12 -0
- data/lib/katello/version.rb +1 -1
- metadata +15 -12
- data/lib/katello/tasks/clean_installed_packages.rake +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a0751952f0fbdb40851ce737b113a3fbd77e811
|
4
|
+
data.tar.gz: 3ae959a2dd6903caed983427538d90bc01f4a307
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97c9319edd494495ffb46c60f9d03304203960668f00b140fcf404a1533104cf8d48124c74349a780ec6a06a5aedbcea5686fc4f6a28ecf9bc9ca8db0f3b48b1
|
7
|
+
data.tar.gz: e79aa09e6fc0e61654e047d0bfda6c390e345e1565ede7a97095f016c6523c5965a52df91406f1deee88d2f12f7688d07b33106586abc69678f3dc9fb134f9d5
|
data/README.md
CHANGED
@@ -4,11 +4,11 @@
|
|
4
4
|
[![Code Climate](https://codeclimate.com/github/Katello/katello/badges/gpa.svg)](https://codeclimate.com/github/Katello/katello)
|
5
5
|
[![Dependency Status](https://gemnasium.com/Katello/katello.svg)](https://gemnasium.com/Katello/katello)
|
6
6
|
|
7
|
-
Full documentation is at
|
7
|
+
Full documentation is at https://www.theforeman.org/plugins/katello/
|
8
8
|
|
9
9
|
## About
|
10
10
|
|
11
|
-
[Katello](
|
11
|
+
[Katello](https://www.theforeman.org/plugins/katello/) is a systems life cycle management
|
12
12
|
plugin to [Foreman](http://www.theforeman.org). Katello allows you to manage
|
13
13
|
thousands of machines with one click. Katello can pull content
|
14
14
|
from remote repositories into isolated environments, and make subscriptions
|
@@ -65,7 +65,7 @@ That's rather unfortunate. But don't worry! We can help. Just file a bug
|
|
65
65
|
|
66
66
|
## Contributing
|
67
67
|
|
68
|
-
See the [developer documentation](
|
68
|
+
See the [developer documentation](https://www.theforeman.org/plugins/katello/developers).
|
69
69
|
|
70
70
|
## Annotated Pulp and Candlepin Workflows and test Scenarios
|
71
71
|
|
@@ -73,7 +73,7 @@ See the [annotation docs](./test/scenarios/README.md) for more information.
|
|
73
73
|
|
74
74
|
## Contact & Resources
|
75
75
|
|
76
|
-
* [
|
76
|
+
* [theforeman.org](https://theforeman.org/plugins/katello)
|
77
77
|
* [Foreman User Mailing List](https://groups.google.com/forum/?fromgroups#!forum/foreman-users)
|
78
78
|
* [Foreman Developer mailing list](https://groups.google.com/forum/?fromgroups#!forum/foreman-dev)
|
79
79
|
* [IRC Freenode](http://freenode.net/using_the_network.shtml): #theforeman-dev
|
@@ -81,4 +81,4 @@ See the [annotation docs](./test/scenarios/README.md) for more information.
|
|
81
81
|
## Documentation
|
82
82
|
|
83
83
|
Most of our documentation (both for users and developers) can be found at
|
84
|
-
[
|
84
|
+
[theforeman.org](https://www.theforeman.org/plugins/katello).
|
@@ -215,7 +215,7 @@ module Katello
|
|
215
215
|
param :content_overrides, Array, :desc => N_("Array of Content override parameters") do
|
216
216
|
param :content_label, String, :desc => N_("Label of the content"), :required => true
|
217
217
|
param :value, String, :desc => N_("Override value. Provide a boolean value if name is 'enabled'"), :required => false
|
218
|
-
param :name, String, :desc => N_("Override key or name. Note if name is not provided the default name will be 'enabled'"), :required => false
|
218
|
+
param :name, String, :desc => N_("Override parameter key or name. Note if name is not provided the default name will be 'enabled'"), :required => false
|
219
219
|
param :remove, :bool, :desc => N_("Set true to remove an override and reset it to 'default'"), :required => false
|
220
220
|
end
|
221
221
|
def content_override
|
@@ -9,7 +9,7 @@ module Katello
|
|
9
9
|
page_size = Katello::Concerns::FilteredAutoCompleteSearch::PAGE_SIZE
|
10
10
|
tags = Katello::DockerMetaTag.in_repositories(@repositories)
|
11
11
|
col = "#{Katello::DockerMetaTag.table_name}.name"
|
12
|
-
tags = tags.where("#{
|
12
|
+
tags = tags.where("#{col} ILIKE ?", "#{params[:term]}%").select(col).group(col).order(col).limit(page_size)
|
13
13
|
render :json => tags.pluck(col)
|
14
14
|
end
|
15
15
|
|
@@ -83,7 +83,8 @@ module Actions
|
|
83
83
|
|
84
84
|
host_collection_ids.each do |host_collection_id|
|
85
85
|
host_collection = ::Katello::HostCollection.find(host_collection_id)
|
86
|
-
if !host_collection.unlimited_hosts && host_collection.max_hosts >= 0
|
86
|
+
if !host_collection.unlimited_hosts && host_collection.max_hosts >= 0 &&
|
87
|
+
host_collection.hosts.length >= host_collection.max_hosts
|
87
88
|
fail _("Host collection '%{name}' exceeds maximum usage limit of '%{limit}'") %
|
88
89
|
{:limit => host_collection.max_hosts, :name => host_collection.name}
|
89
90
|
end
|
@@ -19,7 +19,7 @@ module Actions
|
|
19
19
|
package_groups = package_groups_match?(source_repo, target_repo)
|
20
20
|
distributions = distributions_match?(source_repo, target_repo)
|
21
21
|
|
22
|
-
output[:matching_content] = rpms && errata && package_groups && distributions
|
22
|
+
output[:matching_content] = rpms && errata && package_groups && distributions && target_repo.published?
|
23
23
|
end
|
24
24
|
|
25
25
|
def rpms_match?(source_repo, target_repo)
|
@@ -22,6 +22,7 @@ module Actions
|
|
22
22
|
incremental = options.fetch(:incremental, false)
|
23
23
|
validate_contents = options.fetch(:validate_contents, false)
|
24
24
|
skip_metadata_check = options.fetch(:skip_metadata_check, false) || validate_contents
|
25
|
+
generate_applicability = repo.yum?
|
25
26
|
|
26
27
|
pulp_sync_options = {}
|
27
28
|
pulp_sync_options[:download_policy] = ::Runcible::Models::YumImporter::DOWNLOAD_ON_DEMAND if validate_contents
|
@@ -44,11 +45,11 @@ module Actions
|
|
44
45
|
plan_action(Pulp::Repository::Download, :pulp_id => repo.pulp_id, :options => {:verify_all_units => true}) if validate_contents
|
45
46
|
plan_action(Katello::Repository::MetadataGenerate, repo, :force => true) if skip_metadata_check
|
46
47
|
plan_action(Katello::Repository::ErrataMail, repo, nil, contents_changed)
|
47
|
-
plan_action(Pulp::Repository::RegenerateApplicability, :pulp_id => repo.pulp_id, :contents_changed => contents_changed)
|
48
|
+
plan_action(Pulp::Repository::RegenerateApplicability, :pulp_id => repo.pulp_id, :contents_changed => contents_changed) if generate_applicability
|
48
49
|
end
|
49
50
|
plan_self(:id => repo.id, :sync_result => output, :skip_metadata_check => skip_metadata_check, :validate_contents => validate_contents,
|
50
51
|
:contents_changed => contents_changed)
|
51
|
-
plan_action(Katello::Repository::ImportApplicability, :repo_id => repo.id, :contents_changed => contents_changed)
|
52
|
+
plan_action(Katello::Repository::ImportApplicability, :repo_id => repo.id, :contents_changed => contents_changed) if generate_applicability
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
@@ -51,7 +51,6 @@ module Katello
|
|
51
51
|
# input -> [{"type"=>{"$in"=>[:bugfix, :security]}}] <- Errata Pulp Clauses
|
52
52
|
# output -> {"filename" => {"$in" => {"foo.el6.noarch", "..."}}} <- Packages belonging to those errata
|
53
53
|
def package_clauses_for_errata(errata_clauses = [])
|
54
|
-
errata_clauses = {"$or" => errata_clauses}
|
55
54
|
pkg_filenames = Katello::Erratum.list_filenames_by_clauses(@repo, errata_clauses)
|
56
55
|
{'filename' => {"$in" => pkg_filenames}} unless pkg_filenames.empty?
|
57
56
|
end
|
@@ -6,9 +6,9 @@ module Katello
|
|
6
6
|
environment_id = record.respond_to?(:lifecycle_environment_id) ? record.lifecycle_environment_id : record.environment_id
|
7
7
|
|
8
8
|
if record.content_view_id && environment_id
|
9
|
-
view = ContentView.
|
10
|
-
env = KTEnvironment.
|
11
|
-
unless view.in_environment?(env)
|
9
|
+
view = ContentView.where(:id => record.content_view_id).first
|
10
|
+
env = KTEnvironment.where(:id => environment_id).first
|
11
|
+
unless view.blank? || env.blank? || view.in_environment?(env)
|
12
12
|
record.errors[:base] << _("Content view '%{view}' is not in environment '%{env}'") %
|
13
13
|
{:view => view.name, :env => env.name}
|
14
14
|
end
|
@@ -145,8 +145,9 @@ module Katello
|
|
145
145
|
end
|
146
146
|
|
147
147
|
def self.find_by_subscription_id(_key, operator, value)
|
148
|
-
|
149
|
-
|
148
|
+
# What we refer to as "subscriptions" is really Pools, so we search based on Pool id.
|
149
|
+
conditions = sanitize_sql_for_conditions(["#{Katello::Pool.table_name}.id #{operator} ?", value_to_sql(operator, value)])
|
150
|
+
activation_keys = ::Katello::ActivationKey.joins(:pools).where(conditions)
|
150
151
|
return_activation_keys_by_id(activation_keys.pluck(:id))
|
151
152
|
end
|
152
153
|
|
@@ -5,6 +5,18 @@ module Katello
|
|
5
5
|
include Katello::KatelloUrlsHelper
|
6
6
|
include ForemanTasks::Concerns::ActionSubject
|
7
7
|
|
8
|
+
module Overrides
|
9
|
+
def validate_media?
|
10
|
+
(content_source_id.blank? || (content_facet && content_facet.kickstart_repository.blank?)) && super
|
11
|
+
end
|
12
|
+
|
13
|
+
def smart_proxy_ids
|
14
|
+
ids = super
|
15
|
+
ids << content_source_id
|
16
|
+
ids.uniq.compact
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
8
20
|
included do
|
9
21
|
alias_method_chain :validate_media?, :capsule
|
10
22
|
alias_method_chain :smart_proxy_ids, :katello
|
@@ -63,13 +75,7 @@ module Katello
|
|
63
75
|
end
|
64
76
|
|
65
77
|
def import_package_profile(simple_packages)
|
66
|
-
|
67
|
-
#this method is slow if the clean_installed_packages rake task has not been run, but faster if it has
|
68
|
-
found = import_package_profile_in_bulk(simple_packages)
|
69
|
-
else
|
70
|
-
found = import_package_profile_individually(simple_packages)
|
71
|
-
end
|
72
|
-
|
78
|
+
found = import_package_profile_in_bulk(simple_packages)
|
73
79
|
sync_package_associations(found.map(&:id))
|
74
80
|
end
|
75
81
|
|
@@ -87,21 +93,6 @@ module Katello
|
|
87
93
|
found
|
88
94
|
end
|
89
95
|
|
90
|
-
def import_package_profile_individually(simple_packages)
|
91
|
-
found = []
|
92
|
-
simple_packages.each do |simple_package|
|
93
|
-
::Katello::Util::Support.active_record_retry do
|
94
|
-
#use limit(1)[0] here to avoid a sort by id
|
95
|
-
pkg = InstalledPackage.where(:nvra => simple_package.nvra, :name => simple_package.name).limit(1)[0]
|
96
|
-
if pkg.nil?
|
97
|
-
pkg = InstalledPackage.create!(:nvra => simple_package.nvra, :name => simple_package.name)
|
98
|
-
end
|
99
|
-
found << pkg
|
100
|
-
end
|
101
|
-
end
|
102
|
-
found
|
103
|
-
end
|
104
|
-
|
105
96
|
def sync_package_associations(new_installed_package_ids)
|
106
97
|
old_associated_ids = self.installed_package_ids
|
107
98
|
table_name = self.host_installed_packages.table_name
|
@@ -80,6 +80,10 @@ module Katello
|
|
80
80
|
hosts.count
|
81
81
|
end
|
82
82
|
|
83
|
+
def component_ids
|
84
|
+
components.map(&:id)
|
85
|
+
end
|
86
|
+
|
83
87
|
def components
|
84
88
|
content_view_components.map(&:latest_version).compact.freeze
|
85
89
|
end
|
@@ -316,6 +320,10 @@ module Katello
|
|
316
320
|
components.map(&:archived_repos).flatten
|
317
321
|
end
|
318
322
|
|
323
|
+
def component_repository_ids
|
324
|
+
component_repositories.map(&:id)
|
325
|
+
end
|
326
|
+
|
319
327
|
def repos_in_product(env, product)
|
320
328
|
version = version(env)
|
321
329
|
if version
|
@@ -16,40 +16,56 @@ module Katello
|
|
16
16
|
|
17
17
|
if filter_by_id?
|
18
18
|
errata_ids = erratum_rules.map(&:errata_id)
|
19
|
-
|
20
|
-
|
19
|
+
errata_in(errata_ids) unless errata_ids.empty?
|
21
20
|
else # filtering by date/type
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
unless start_date.blank? && end_date.blank?
|
28
|
-
date_range = {}
|
29
|
-
date_range["$gte"] = start_date.to_time.utc.as_json unless start_date.blank?
|
30
|
-
date_range["$lte"] = end_date.to_time.utc.as_json unless end_date.blank?
|
31
|
-
rule_clauses << { erratum_rules.first.pulp_date_type => date_range }
|
32
|
-
end
|
33
|
-
unless types.blank?
|
34
|
-
# {"type": {"$in": ["security", "enhancement", "bugfix"]}
|
35
|
-
rule_clauses << { "type" => { "$in" => types } }
|
36
|
-
end
|
37
|
-
|
38
|
-
# Currently, an errata filter that specifies a date/type, will only have
|
39
|
-
# single rule; therefore, we can return from here.
|
40
|
-
case rule_clauses.size
|
41
|
-
when 0
|
42
|
-
return
|
43
|
-
when 1
|
44
|
-
return rule_clauses.first
|
45
|
-
else
|
46
|
-
return { '$and' => rule_clauses }
|
47
|
-
end
|
21
|
+
clauses = []
|
22
|
+
clauses << errata_from
|
23
|
+
clauses << errata_to
|
24
|
+
clauses << types_clause
|
25
|
+
clauses.compact.inject(&:and)
|
48
26
|
end
|
49
27
|
end
|
50
28
|
|
29
|
+
private
|
30
|
+
|
31
|
+
def erratum_arel
|
32
|
+
::Katello::Erratum.arel_table
|
33
|
+
end
|
34
|
+
|
35
|
+
def types_clause
|
36
|
+
types = erratum_rules.first.types
|
37
|
+
return if types.blank?
|
38
|
+
errata_types_in(types)
|
39
|
+
end
|
40
|
+
|
51
41
|
def filter_by_id?
|
52
42
|
!erratum_rules.blank? && !erratum_rules.first.errata_id.blank?
|
53
43
|
end
|
44
|
+
|
45
|
+
def errata_types_in(types)
|
46
|
+
erratum_arel[:errata_type].in(types)
|
47
|
+
end
|
48
|
+
|
49
|
+
def errata_in(ids)
|
50
|
+
erratum_arel[:errata_id].in(ids)
|
51
|
+
end
|
52
|
+
|
53
|
+
def errata_from
|
54
|
+
start_date = erratum_rules.first.start_date
|
55
|
+
return if start_date.blank?
|
56
|
+
date_type = erratum_rules.first.pulp_date_type.to_sym
|
57
|
+
|
58
|
+
# "katello_errata"."issued" >= '2017-11-23'
|
59
|
+
erratum_arel[date_type].gteq(start_date)
|
60
|
+
end
|
61
|
+
|
62
|
+
def errata_to
|
63
|
+
end_date = erratum_rules.first.end_date
|
64
|
+
return if end_date.blank?
|
65
|
+
date_type = erratum_rules.first.pulp_date_type.to_sym
|
66
|
+
|
67
|
+
# "katello_errata"."issued" <= '2017-11-23'
|
68
|
+
erratum_arel[date_type].lteq(end_date)
|
69
|
+
end
|
54
70
|
end
|
55
71
|
end
|
@@ -134,10 +134,14 @@ module Katello
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def self.list_filenames_by_clauses(repo, clauses)
|
137
|
-
|
137
|
+
query_clauses = clauses.map do |clause|
|
138
|
+
"(#{clause.to_sql})"
|
139
|
+
end
|
140
|
+
statement = query_clauses.join(" OR ")
|
141
|
+
|
138
142
|
Katello::ErratumPackage.joins(:erratum => :repository_errata).
|
139
|
-
where("#{RepositoryErratum.table_name}.repository_id" => repo.id
|
140
|
-
|
143
|
+
where("#{RepositoryErratum.table_name}.repository_id" => repo.id).
|
144
|
+
where(statement).pluck(:filename)
|
141
145
|
end
|
142
146
|
|
143
147
|
private
|
@@ -9,7 +9,7 @@ module Katello
|
|
9
9
|
lazy_accessor :pool_facts, :initializer => lambda { |_s| self.import_lazy_attributes }
|
10
10
|
lazy_accessor :subscription_facts, :initializer => lambda { |_s| self.subscription ? self.subscription.attributes : {} }
|
11
11
|
|
12
|
-
lazy_accessor :pool_derived, :owner, :source_pool_id, :
|
12
|
+
lazy_accessor :pool_derived, :owner, :source_pool_id, :virt_limit, :arch, :description,
|
13
13
|
:product_family, :variant, :suggested_quantity, :support_type, :product_id, :type,
|
14
14
|
:initializer => :pool_facts
|
15
15
|
|
@@ -49,8 +49,6 @@ module Katello
|
|
49
49
|
pool_attributes.each do |attr|
|
50
50
|
json[attr["name"]] = attr["value"]
|
51
51
|
case attr["name"]
|
52
|
-
when 'requires_host'
|
53
|
-
json["host_id"] = attr['value']
|
54
52
|
when 'virt_limit'
|
55
53
|
json["virt_limit"] = attr['value'].to_i
|
56
54
|
when 'support_type'
|
@@ -93,6 +91,7 @@ module Katello
|
|
93
91
|
subscription
|
94
92
|
end
|
95
93
|
|
94
|
+
# rubocop:disable MethodLength
|
96
95
|
def import_data(index_hosts = true)
|
97
96
|
pool_attributes = {}.with_indifferent_access
|
98
97
|
pool_json = self.backend_data
|
@@ -120,7 +119,11 @@ module Katello
|
|
120
119
|
if pool_attributes.key?(:virtual)
|
121
120
|
pool_attributes[:virt_only] = pool_attributes["virtual"] == 'true' ? true : false
|
122
121
|
end
|
123
|
-
|
122
|
+
|
123
|
+
if pool_attributes.key?("requires_host")
|
124
|
+
pool_attributes[:hypervisor_id] = ::Katello::Host::SubscriptionFacet.find_by(:uuid => pool_attributes["requires_host"])
|
125
|
+
.try(:host_id)
|
126
|
+
end
|
124
127
|
|
125
128
|
if pool_attributes.key?(:unmapped_guests_only) && pool_attributes[:unmapped_guests_only] == 'true'
|
126
129
|
pool_attributes[:unmapped_guest] = true
|
@@ -134,6 +137,7 @@ module Katello
|
|
134
137
|
self.create_activation_key_associations
|
135
138
|
self.import_hosts if index_hosts
|
136
139
|
end
|
140
|
+
# rubocop:enable MethodLength
|
137
141
|
|
138
142
|
def import_hosts
|
139
143
|
entitlements = Resources::Candlepin::Pool.entitlements(self.cp_id, ["consumer.uuid"])
|
@@ -164,7 +168,7 @@ module Katello
|
|
164
168
|
end
|
165
169
|
|
166
170
|
def hypervisor
|
167
|
-
::
|
171
|
+
::Host.find_by(id: self.hypervisor_id) if self.hypervisor_id
|
168
172
|
end
|
169
173
|
end
|
170
174
|
end
|
@@ -38,16 +38,6 @@ module Katello
|
|
38
38
|
self.sync_status[:state]
|
39
39
|
end
|
40
40
|
|
41
|
-
def sync_finish
|
42
|
-
finish_times = []
|
43
|
-
self.products.each do |r|
|
44
|
-
finish = r.sync_finish
|
45
|
-
finish_times << finish unless finish.nil?
|
46
|
-
end
|
47
|
-
finish_times.sort!
|
48
|
-
finish_times.last
|
49
|
-
end
|
50
|
-
|
51
41
|
def sync_size
|
52
42
|
self.products.inject(0) { |sum, v| sum + v.sync_status.progress.total_size }
|
53
43
|
end
|
@@ -489,29 +489,6 @@ module Katello
|
|
489
489
|
]
|
490
490
|
end
|
491
491
|
|
492
|
-
def sync_start
|
493
|
-
status = self.sync_status
|
494
|
-
retval = nil
|
495
|
-
if status.nil? || status['progress']['start_time'].nil?
|
496
|
-
retval = nil
|
497
|
-
else
|
498
|
-
retval = status['progress']['start_time']
|
499
|
-
# retval = date.strftime("%H:%M:%S %Y-%m-%d")
|
500
|
-
end
|
501
|
-
retval
|
502
|
-
end
|
503
|
-
|
504
|
-
def sync_finish
|
505
|
-
status = self.sync_status
|
506
|
-
retval = nil
|
507
|
-
if status.nil? || status['progress']['finish_time'].nil?
|
508
|
-
retval = nil
|
509
|
-
else
|
510
|
-
retval = status['progress']['finish_time']
|
511
|
-
end
|
512
|
-
retval
|
513
|
-
end
|
514
|
-
|
515
492
|
def sync_status
|
516
493
|
self._get_most_recent_sync_status if @sync_status.nil?
|
517
494
|
end
|
@@ -641,6 +618,10 @@ module Katello
|
|
641
618
|
self.content_type == Repository::OSTREE_TYPE
|
642
619
|
end
|
643
620
|
|
621
|
+
def published?
|
622
|
+
distributors.map { |dist| dist['last_publish'] }.compact.any?
|
623
|
+
end
|
624
|
+
|
644
625
|
def capsule_download_policy(capsule)
|
645
626
|
policy = capsule.download_policy || Setting[:default_proxy_download_policy]
|
646
627
|
if self.yum?
|
@@ -179,26 +179,6 @@ module Katello
|
|
179
179
|
self.sync_status[:state]
|
180
180
|
end
|
181
181
|
|
182
|
-
def sync_start
|
183
|
-
start_times = []
|
184
|
-
repos(library).each do |r|
|
185
|
-
start = r.sync_start
|
186
|
-
start_times << start unless start.nil?
|
187
|
-
end
|
188
|
-
start_times.sort!
|
189
|
-
start_times.last
|
190
|
-
end
|
191
|
-
|
192
|
-
def sync_finish
|
193
|
-
finish_times = []
|
194
|
-
repos(library).each do |r|
|
195
|
-
finish = r.sync_finish
|
196
|
-
finish_times << finish unless finish.nil?
|
197
|
-
end
|
198
|
-
finish_times.sort!
|
199
|
-
finish_times.last
|
200
|
-
end
|
201
|
-
|
202
182
|
def sync_size
|
203
183
|
self.repos(library).inject(0) do |sum, v|
|
204
184
|
sum + v.sync_status.progress.total_size
|
data/app/models/katello/pool.rb
CHANGED
@@ -40,8 +40,6 @@ class Setting::Content < Setting
|
|
40
40
|
false, N_('Restrict Composite Content View promotion')),
|
41
41
|
self.set('check_services_before_actions', N_("Whether or not to check the status of backend services such as pulp and candlepin prior to performing some actions."),
|
42
42
|
true, N_('Check services before actions')),
|
43
|
-
self.set('bulk_query_installed_packages', N_("Use a bulk query when looking up installed packages."),
|
44
|
-
false, N_('Bulk query for installed packages.')),
|
45
43
|
self.set('force_post_sync_actions', N_("Force post sync actions such as indexing and email even if no content was available."),
|
46
44
|
false, N_('Force post-sync actions')),
|
47
45
|
self.set('default_download_policy', N_("Default download policy for repositories (either 'immediate', 'on_demand', or 'background')"), "on_demand",
|
@@ -22,11 +22,11 @@
|
|
22
22
|
<tr>
|
23
23
|
<td>
|
24
24
|
<% if host_collection.security_updates? %>
|
25
|
-
<a href="/host_collections/<%= host_collection.id
|
25
|
+
<a href="/host_collections/<%= host_collection.id %>" style="text-align: center"><i class="label label-danger"> </i></a>
|
26
26
|
<% elsif host_collection.bugzilla_updates? || host_collection.enhancement_updates? %>
|
27
|
-
<a href="/host_collections/<%= host_collection.id
|
27
|
+
<a href="/host_collections/<%= host_collection.id %>" style="text-align: center"><i class="label label-warning"> </i></a>
|
28
28
|
<% else %>
|
29
|
-
<a href="/host_collections/<%= host_collection.id
|
29
|
+
<a href="/host_collections/<%= host_collection.id %>" style="text-align: center"><i class="label label-success"> </i></a>
|
30
30
|
<% end %>
|
31
31
|
</td>
|
32
32
|
<td class='ellipsis'><%= host_collection.name %></td>
|
@@ -2,7 +2,6 @@ extends 'katello/api/v2/common/identifier'
|
|
2
2
|
extends 'katello/api/v2/common/org_reference'
|
3
3
|
|
4
4
|
attributes :composite
|
5
|
-
attributes :repository_ids
|
6
5
|
attributes :component_ids
|
7
6
|
attributes :default
|
8
7
|
attributes :force_puppet_environment
|
@@ -32,10 +31,12 @@ if @object.composite?
|
|
32
31
|
child :component_repositories => :repositories do
|
33
32
|
attributes :id, :name, :label, :content_type
|
34
33
|
end
|
34
|
+
attributes :component_repository_ids => :repository_ids
|
35
35
|
else
|
36
36
|
child :repositories => :repositories do
|
37
37
|
attributes :id, :name, :label, :content_type
|
38
38
|
end
|
39
|
+
attributes :repository_ids
|
39
40
|
end
|
40
41
|
|
41
42
|
child :puppet_modules => :puppet_modules do
|
@@ -16,3 +16,10 @@ attributes :name => :product_name
|
|
16
16
|
attributes :unmapped_guest
|
17
17
|
attributes :virt_only
|
18
18
|
attributes :virt_who
|
19
|
+
|
20
|
+
node :hypervisor, :if => lambda { |sub| sub && sub.respond_to?(:hypervisor) && sub.hypervisor_id } do |subscription|
|
21
|
+
{
|
22
|
+
id: subscription.hypervisor.id,
|
23
|
+
name: subscription.hypervisor.name
|
24
|
+
}
|
25
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class CleanupInstalledPackages < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
create_table "katello_installed_packages_new", force: :cascade do |t|
|
4
|
+
t.string "name", limit: 255, null: false
|
5
|
+
t.string "nvra", limit: 255, null: false
|
6
|
+
end
|
7
|
+
|
8
|
+
create_table "katello_host_installed_packages_new", force: :cascade do |t|
|
9
|
+
t.integer "host_id", null: false
|
10
|
+
t.integer "installed_package_id", null: false
|
11
|
+
end
|
12
|
+
|
13
|
+
#Copy unique entires to new table
|
14
|
+
execute('insert into katello_installed_packages_new(nvra, name)
|
15
|
+
select distinct(nvra) as nvra, name from katello_installed_packages')
|
16
|
+
|
17
|
+
#copy associations
|
18
|
+
execute('
|
19
|
+
insert into katello_host_installed_packages_new (host_id, installed_package_id)
|
20
|
+
select distinct katello_host_installed_packages.host_id, katello_installed_packages_new.id
|
21
|
+
from katello_installed_packages
|
22
|
+
inner join katello_host_installed_packages on katello_host_installed_packages.installed_package_id = katello_installed_packages.id
|
23
|
+
inner join katello_installed_packages_new on katello_installed_packages_new.nvra = katello_installed_packages.nvra')
|
24
|
+
|
25
|
+
remove_foreign_key :katello_host_installed_packages, name: "katello_host_installed_packages_installed_package_id"
|
26
|
+
remove_foreign_key :katello_host_installed_packages, name: "katello_host_installed_packages_host_id"
|
27
|
+
|
28
|
+
drop_table "katello_installed_packages"
|
29
|
+
drop_table "katello_host_installed_packages"
|
30
|
+
|
31
|
+
rename_table "katello_installed_packages_new", "katello_installed_packages"
|
32
|
+
rename_table "katello_host_installed_packages_new", "katello_host_installed_packages"
|
33
|
+
|
34
|
+
add_index :katello_installed_packages, [:name, :nvra]
|
35
|
+
|
36
|
+
add_foreign_key "katello_host_installed_packages", "hosts",
|
37
|
+
:name => "katello_host_installed_packages_host_id", :column => "host_id"
|
38
|
+
|
39
|
+
add_foreign_key "katello_host_installed_packages", "katello_installed_packages",
|
40
|
+
:name => "katello_host_installed_packages_installed_package_id", :column => "installed_package_id"
|
41
|
+
|
42
|
+
#At this point, everything should be back to where it was (sans-duplicates)
|
43
|
+
# Now do new things
|
44
|
+
add_index :katello_installed_packages, [:nvra], :unique => true
|
45
|
+
add_index :katello_host_installed_packages, [:host_id, :installed_package_id], :unique => true, :name => :katello_host_installed_packages_h_id_ip_id
|
46
|
+
Setting.where(:name => 'bulk_query_installed_packages', :category => 'Setting::Content').delete_all
|
47
|
+
end
|
48
|
+
|
49
|
+
def down
|
50
|
+
#only revert new things
|
51
|
+
remove_index :katello_installed_packages, [:nvra]
|
52
|
+
remove_index :katello_host_installed_packages, :name => :katello_host_installed_packages_h_id_ip_id
|
53
|
+
#Setting will be recreated on startup
|
54
|
+
end
|
55
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
angular.module('Bastion.activation-keys').config(['$stateProvider', function ($stateProvider) {
|
2
2
|
$stateProvider.state('activation-keys', {
|
3
|
-
url: '/activation_keys
|
3
|
+
url: '/activation_keys',
|
4
4
|
permission: 'view_activation_keys',
|
5
5
|
template: '<div ui-view></div>',
|
6
6
|
views: {
|
@@ -8,13 +8,14 @@
|
|
8
8
|
* @requires translate
|
9
9
|
* @requires ActivationKey
|
10
10
|
* @requires Nutupane
|
11
|
+
* @requires Notification
|
11
12
|
*
|
12
13
|
* @description
|
13
14
|
* Provides the functionality for the list host collections details action pane.
|
14
15
|
*/
|
15
16
|
angular.module('Bastion.activation-keys').controller('ActivationKeyHostCollectionsController',
|
16
|
-
['$scope', '$q', '$location', 'translate', 'ActivationKey', 'Nutupane',
|
17
|
-
function ($scope, $q, $location, translate, ActivationKey, Nutupane) {
|
17
|
+
['$scope', '$q', '$location', 'translate', 'ActivationKey', 'Nutupane', 'Notification',
|
18
|
+
function ($scope, $q, $location, translate, ActivationKey, Nutupane, Notification) {
|
18
19
|
var hostCollectionsPane, params;
|
19
20
|
|
20
21
|
params = {
|
@@ -40,10 +40,24 @@ angular.module('Bastion.content-hosts').controller('ContentHostTracesController'
|
|
40
40
|
}
|
41
41
|
});
|
42
42
|
|
43
|
-
$scope.selectedTraceHelpers = function
|
44
|
-
var traceHelpers = [],
|
45
|
-
|
46
|
-
|
43
|
+
$scope.selectedTraceHelpers = function() {
|
44
|
+
var traceHelpers = [],
|
45
|
+
selected = $scope.table.getSelected();
|
46
|
+
|
47
|
+
var reboot = selected.some(function(value) {
|
48
|
+
return value.app_type === "static";
|
49
|
+
});
|
50
|
+
|
51
|
+
if (reboot) {
|
52
|
+
return ["reboot"];
|
53
|
+
}
|
54
|
+
|
55
|
+
selected.forEach(function(value) {
|
56
|
+
if (value.app_type !== "session") {
|
57
|
+
if (traceHelpers.indexOf(value.helper) === -1) {
|
58
|
+
traceHelpers.push(value.helper);
|
59
|
+
}
|
60
|
+
}
|
47
61
|
});
|
48
62
|
return traceHelpers;
|
49
63
|
};
|
@@ -10,13 +10,14 @@
|
|
10
10
|
* @requires Host
|
11
11
|
* @requires CurrentOrganization
|
12
12
|
* @requires Nutupane
|
13
|
+
* @requires Notification
|
13
14
|
*
|
14
15
|
* @description
|
15
16
|
* Provides the functionality for adding host collections to a content host.
|
16
17
|
*/
|
17
18
|
angular.module('Bastion.content-hosts').controller('ContentHostAddHostCollectionsController',
|
18
|
-
['$scope', '$q', '$location', 'translate', 'HostCollection', 'Host', 'CurrentOrganization', 'Nutupane',
|
19
|
-
function ($scope, $q, $location, translate, HostCollection, Host, CurrentOrganization, Nutupane) {
|
19
|
+
['$scope', '$q', '$location', 'translate', 'HostCollection', 'Host', 'CurrentOrganization', 'Nutupane', 'Notification',
|
20
|
+
function ($scope, $q, $location, translate, HostCollection, Host, CurrentOrganization, Nutupane, Notification) {
|
20
21
|
var params, nutupane;
|
21
22
|
|
22
23
|
params = {
|
@@ -44,7 +44,7 @@
|
|
44
44
|
|
45
45
|
<dt ng-show="host.subscription_facet_attributes.virtual_guests" translate>Virtual Guests</dt>
|
46
46
|
<dd ng-show="host.subscription_facet_attributes.virtual_guests">
|
47
|
-
<a
|
47
|
+
<a ng-href="/content_hosts?search={{virtualGuestIds(host)}}"
|
48
48
|
translate translate-n="host.subscription_facet_attributes.virtual_guests.length"
|
49
49
|
translate-plural="{{ host.subscription_facet_attributes.virtual_guests.length }} Content Hosts">
|
50
50
|
1 Content Host
|
@@ -94,7 +94,7 @@
|
|
94
94
|
</td>
|
95
95
|
<td bst-table-cell>
|
96
96
|
<div ng-if="repository.content_counts.rpm && repository.content_counts.rpm > 0">
|
97
|
-
<a ui-sref="
|
97
|
+
<a ui-sref="product.repository.manage-content.packages({productId: repository.product.id, repositoryId: repository.id})"
|
98
98
|
ng-show="repository.content_type == 'yum'"
|
99
99
|
translate>
|
100
100
|
{{ repository.content_counts.rpm }} Packages
|
@@ -86,7 +86,7 @@
|
|
86
86
|
</td>
|
87
87
|
<td bst-table-cell>
|
88
88
|
<div>
|
89
|
-
<a ui-sref="
|
89
|
+
<a ui-sref="product.repository.manage-content.packages({productId: repository.product.id, repositoryId: repository.id})"
|
90
90
|
ng-show="repository.content_type == 'yum'"
|
91
91
|
translate>
|
92
92
|
{{ repository.content_counts.rpm }} Packages
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<td bst-table-cell>{{ repository.product.name }}</td>
|
15
15
|
<td bst-table-cell>
|
16
16
|
<div>
|
17
|
-
<a ui-sref="
|
17
|
+
<a ui-sref="product.repository.manage-content.packages({productId: repository.product.id, repositoryId: repository.id})" translate>
|
18
18
|
{{ repository.content_counts.rpm }} Packages
|
19
19
|
</a>
|
20
20
|
</div>
|
@@ -9,13 +9,14 @@
|
|
9
9
|
* @requires CurrentOrganization
|
10
10
|
* @requires Host
|
11
11
|
* @requires HostCollection
|
12
|
+
* @requires Notification
|
12
13
|
*
|
13
14
|
* @description
|
14
15
|
* Provides the functionality for the host collection add content hosts pane.
|
15
16
|
*/
|
16
17
|
angular.module('Bastion.host-collections').controller('HostCollectionAddHostsController',
|
17
|
-
['$scope', '$state', '$location', 'translate', 'Nutupane', 'CurrentOrganization', 'Host', 'HostCollection',
|
18
|
-
function ($scope, $state, $location, translate, Nutupane, CurrentOrganization, Host, HostCollection) {
|
18
|
+
['$scope', '$state', '$location', 'translate', 'Nutupane', 'CurrentOrganization', 'Host', 'HostCollection', 'Notification',
|
19
|
+
function ($scope, $state, $location, translate, Nutupane, CurrentOrganization, Host, HostCollection, Notification) {
|
19
20
|
var contentNutupane, params, nutupaneParams;
|
20
21
|
|
21
22
|
params = {
|
@@ -86,7 +86,7 @@
|
|
86
86
|
<tr>
|
87
87
|
<td>Content Hosts</td>
|
88
88
|
<td>
|
89
|
-
<a
|
89
|
+
<a ng-href="/content_hosts?search={{searchQuery(subscription)}}">
|
90
90
|
{{ subscription.host_count }}
|
91
91
|
</a>
|
92
92
|
</td>
|
@@ -94,7 +94,7 @@
|
|
94
94
|
<tr>
|
95
95
|
<td>Activation Keys</td>
|
96
96
|
<td>
|
97
|
-
<a
|
97
|
+
<a ng-href="/activation_keys?search={{searchQuery(subscription)}}">
|
98
98
|
{{ subscription.activation_keys.length }}
|
99
99
|
</a>
|
100
100
|
</td>
|
@@ -60,7 +60,7 @@ angular.module('Bastion.subscriptions').config(['$stateProvider', function ($sta
|
|
60
60
|
}
|
61
61
|
})
|
62
62
|
.state('subscription.content-hosts', {
|
63
|
-
url: '/content-hosts
|
63
|
+
url: '/content-hosts',
|
64
64
|
permission: 'view_subscriptions',
|
65
65
|
controller: 'SubscriptionContentHostsController',
|
66
66
|
templateUrl: 'subscriptions/details/views/subscription-content-hosts.html',
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<div ng-if="subscription.virt_only === false">
|
3
3
|
{{ 'Physical' | translate }}
|
4
4
|
</div>
|
5
|
-
<div ng-if="subscription.virt_only === true && !subscription.
|
5
|
+
<div ng-if="subscription.virt_only === true && !subscription.hypervisor">
|
6
6
|
<div ng-if="subscription.unmapped_guest !== true">
|
7
7
|
{{ 'Virtual' | translate }}
|
8
8
|
</div>
|
@@ -10,9 +10,9 @@
|
|
10
10
|
{{ 'Temporary' | translate }}
|
11
11
|
</div>
|
12
12
|
</div>
|
13
|
-
<div ng-if="subscription.virt_only === true && subscription.
|
13
|
+
<div ng-if="subscription.virt_only === true && subscription.hypervisor">
|
14
14
|
<span translate> Guests of </span>
|
15
|
-
<a ui-sref="content-
|
16
|
-
{{ subscription.
|
15
|
+
<a ui-sref="content-host.info({hostId: subscription.hypervisor.id })">
|
16
|
+
{{ subscription.hypervisor.name }}
|
17
17
|
</a>
|
18
18
|
</div>
|
@@ -29,9 +29,7 @@ Foreman::AccessControl.permission(:edit_hosts).actions.concat [
|
|
29
29
|
'katello/api/rhsm/candlepin_proxies/regenerate_identity_certificates',
|
30
30
|
'katello/api/rhsm/candlepin_proxies/hypervisors_update',
|
31
31
|
'katello/api/rhsm/candlepin_proxies/async_hypervisors_update',
|
32
|
-
'katello/api/rhsm/candlepin_proxies/upload_tracer_profile'
|
33
|
-
'katello/remote_execution/new',
|
34
|
-
'katello/remote_execution/create'
|
32
|
+
'katello/api/rhsm/candlepin_proxies/upload_tracer_profile'
|
35
33
|
]
|
36
34
|
|
37
35
|
Foreman::AccessControl.permission(:view_hosts).actions.concat [
|
@@ -47,7 +45,9 @@ Foreman::AccessControl.permission(:view_hosts).actions.concat [
|
|
47
45
|
'katello/api/v2/hosts_bulk_actions/installable_errata',
|
48
46
|
'katello/api/v2/hosts_bulk_actions/available_incremental_updates',
|
49
47
|
'katello/api/v2/host_packages/index',
|
50
|
-
'katello/api/v2/host_tracer/index'
|
48
|
+
'katello/api/v2/host_tracer/index',
|
49
|
+
'katello/remote_execution/new',
|
50
|
+
'katello/remote_execution/create'
|
51
51
|
]
|
52
52
|
|
53
53
|
Foreman::AccessControl.permission(:destroy_hosts).actions.concat [
|
@@ -7,9 +7,10 @@ namespace :katello do
|
|
7
7
|
|
8
8
|
def report_errors
|
9
9
|
if @errors.any?
|
10
|
+
path = "/var/log/foreman/"
|
11
|
+
path = "/tmp/" unless File.writable?(path)
|
10
12
|
filename = "subscription_facet_upgrade-#{Time.now.to_i}.log"
|
11
|
-
path =
|
12
|
-
path = "/tmp/#{filename}" unless File.writable?(path)
|
13
|
+
path = File.join(path, filename)
|
13
14
|
|
14
15
|
file = File.open(path, 'w')
|
15
16
|
@errors.each { |error| file.write(error) }
|
@@ -36,7 +37,7 @@ namespace :katello do
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
|
-
Katello::Host::SubscriptionFacet.find_each do |subscription_facet|
|
40
|
+
Katello::Host::SubscriptionFacet.where.not(:uuid => nil).find_each do |subscription_facet|
|
40
41
|
begin
|
41
42
|
candlepin_attrs = subscription_facet.candlepin_consumer.consumer_attributes
|
42
43
|
subscription_facet.import_database_attributes(candlepin_attrs)
|
@@ -1,64 +1,8 @@
|
|
1
1
|
namespace :katello do
|
2
2
|
namespace :upgrades do
|
3
3
|
namespace '3.0' do
|
4
|
-
task :update_subscription_facet_backend_data => ["environment"] do
|
5
|
-
|
6
|
-
@errors << message
|
7
|
-
@errors << "\n"
|
8
|
-
end
|
9
|
-
|
10
|
-
def report_errors
|
11
|
-
if @errors.any?
|
12
|
-
filename = "subscription_facet_upgrade-#{Time.now.to_i}.log"
|
13
|
-
path = "/var/log/foreman/#{filename}"
|
14
|
-
path = "/tmp/#{filename}" unless File.writable?(path)
|
15
|
-
|
16
|
-
file = File.open(path, 'w')
|
17
|
-
@errors.each { |error| file.write(error) }
|
18
|
-
file.close
|
19
|
-
$stderr.print "***********************************\n"
|
20
|
-
$stderr.print "*************WARNING***************\n"
|
21
|
-
$stderr.print "Errors detected during upgrade step.\n"
|
22
|
-
$stderr.print "Details saved to: #{file.path}\n"
|
23
|
-
$stderr.print "This step can be rerun with:\n"
|
24
|
-
$stderr.print " foreman-rake katello:upgrades:3.0:update_subscription_facet_backend_data\n"
|
25
|
-
$stderr.print "You are likely encountering a bug.\n"
|
26
|
-
$stderr.print "***********************************\n"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
@errors ||= []
|
31
|
-
User.current = User.anonymous_api_admin
|
32
|
-
puts _("Updating backend data for subscription facets")
|
33
|
-
|
34
|
-
#there may be some invalid hosts, if there are create a primary interface
|
35
|
-
::Host.includes(:interfaces).find_each do |host|
|
36
|
-
if host.primary_interface.nil?
|
37
|
-
host.interfaces.create!(:primary => true)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
Katello::Host::SubscriptionFacet.where.not(:uuid => nil).find_each do |subscription_facet|
|
42
|
-
begin
|
43
|
-
candlepin_attrs = subscription_facet.candlepin_consumer.consumer_attributes
|
44
|
-
subscription_facet.import_database_attributes(candlepin_attrs)
|
45
|
-
subscription_facet.host = ::Host::Managed.find(subscription_facet.host_id)
|
46
|
-
subscription_facet.save!
|
47
|
-
|
48
|
-
host = subscription_facet.host
|
49
|
-
host.name = ::Katello::Host::SubscriptionFacet.sanitize_name(host.name)
|
50
|
-
host.save! if host.name_changed?
|
51
|
-
|
52
|
-
Katello::Host::SubscriptionFacet.update_facts(subscription_facet.host, candlepin_attrs[:facts])
|
53
|
-
rescue StandardError => exception
|
54
|
-
error("Error: #{subscription_facet.host.name} - #{subscription_facet.host.id}")
|
55
|
-
error(candlepin_attrs)
|
56
|
-
error(exception.message)
|
57
|
-
error(exception.backtrace.join("\n"))
|
58
|
-
error("\n")
|
59
|
-
end
|
60
|
-
end
|
61
|
-
report_errors
|
4
|
+
task :update_subscription_facet_backend_data => ["environment", "katello:update_subscription_facet_backend_data"] do
|
5
|
+
#noop task
|
62
6
|
end
|
63
7
|
end
|
64
8
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
namespace :katello do
|
2
|
+
namespace :upgrades do
|
3
|
+
namespace '3.4' do
|
4
|
+
desc "Reindex docker tags to account for schema 1 and schema 2"
|
5
|
+
task :reindex_docker_tags => ["environment"] do
|
6
|
+
User.current = User.anonymous_admin
|
7
|
+
::Katello::DockerManifest.import_all
|
8
|
+
::Katello::DockerTag.import_all
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/katello/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katello
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- N/A
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -84,30 +84,30 @@ dependencies:
|
|
84
84
|
name: foreman-tasks
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "<"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
89
|
+
version: '0.11'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "<"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
96
|
+
version: '0.11'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: foreman_docker
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "<"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: '4'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "<"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: '4'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: qpid_messaging
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -1420,6 +1420,9 @@ files:
|
|
1420
1420
|
- db/migrate/20170822104447_add_katello_content_to_image.rb
|
1421
1421
|
- db/migrate/20170913183848_add_errata_counts.rb
|
1422
1422
|
- db/migrate/20171010170443_add_index_to_katello_content_facet_errata.rb
|
1423
|
+
- db/migrate/20171114150937_cleanup_installed_packages.rb
|
1424
|
+
- db/migrate/20171114183353_add_hypervisor_id_to_katello_pools.rb
|
1425
|
+
- db/migrate/20171211124439_add_uuid_index_to_katello_subscription_facets.rb
|
1423
1426
|
- db/seeds.d/101-locations.rb
|
1424
1427
|
- db/seeds.d/102-organizations.rb
|
1425
1428
|
- db/seeds.d/103-provisioning_templates.rb
|
@@ -1960,7 +1963,6 @@ files:
|
|
1960
1963
|
- lib/katello/repository_types/puppet.rb
|
1961
1964
|
- lib/katello/repository_types/yum.rb
|
1962
1965
|
- lib/katello/tasks/clean_backend_objects.rake
|
1963
|
-
- lib/katello/tasks/clean_installed_packages.rake
|
1964
1966
|
- lib/katello/tasks/clean_published_repo_directories.rake
|
1965
1967
|
- lib/katello/tasks/delete_orphaned_content.rake
|
1966
1968
|
- lib/katello/tasks/import_applicability.rake
|
@@ -1984,6 +1986,7 @@ files:
|
|
1984
1986
|
- lib/katello/tasks/upgrades/3.0/update_puppet_repository_distributors.rake
|
1985
1987
|
- lib/katello/tasks/upgrades/3.0/update_subscription_facet_backend_data.rake
|
1986
1988
|
- lib/katello/tasks/upgrades/3.3/hypervisors.rake
|
1989
|
+
- lib/katello/tasks/upgrades/3.4/reindex_docker_tags.rake
|
1987
1990
|
- lib/katello/tasks/upgrades/3.4/remove_unused_products.rake
|
1988
1991
|
- lib/katello/tasks/virt_who_report.rake
|
1989
1992
|
- lib/katello/url_constrained_cookie_store.rb
|
@@ -2097,7 +2100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
2097
2100
|
version: '0'
|
2098
2101
|
requirements: []
|
2099
2102
|
rubyforge_project:
|
2100
|
-
rubygems_version: 2.
|
2103
|
+
rubygems_version: 2.5.2
|
2101
2104
|
signing_key:
|
2102
2105
|
specification_version: 4
|
2103
2106
|
summary: ''
|
@@ -1,71 +0,0 @@
|
|
1
|
-
namespace :katello do
|
2
|
-
desc "Clean duplicate installed packages"
|
3
|
-
task :clean_installed_packages => :environment do
|
4
|
-
User.current = User.anonymous_admin
|
5
|
-
|
6
|
-
puts "Populating cache"
|
7
|
-
cache = PackageCache.new
|
8
|
-
cache.populate
|
9
|
-
|
10
|
-
puts "Cleaning katello_host_installed_packages table.."
|
11
|
-
cleaning_start = Time.now
|
12
|
-
total = ::Host.count
|
13
|
-
count = 1
|
14
|
-
::Host.find_each do |host|
|
15
|
-
puts "Host #{count}/#{total} #{host.name}"
|
16
|
-
|
17
|
-
if host.installed_package_ids.any?
|
18
|
-
nvras = host.installed_packages.pluck(:nvra)
|
19
|
-
ids = nvras.map { |nvra| cache.fetch(nvra) }
|
20
|
-
existing_ids = host.installed_package_ids.to_a
|
21
|
-
unless existing_ids.sort == ids.sort
|
22
|
-
host.sync_package_associations(ids)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
count += 1
|
26
|
-
end
|
27
|
-
|
28
|
-
cleaning_total = sprintf('%.2f', Time.now - cleaning_start)
|
29
|
-
puts "katello_host_installed_packages table has been cleaned, total time was #{cleaning_total} seconds."
|
30
|
-
puts "Removing records from katello_installed_packages that are no longer referenced..."
|
31
|
-
cleaning_start = Time.now
|
32
|
-
|
33
|
-
existing = Katello::HostInstalledPackage.select(:installed_package_id).uniq.pluck(:installed_package_id)
|
34
|
-
|
35
|
-
batch = 20_000
|
36
|
-
until Katello::InstalledPackage.where('id not in (?)', existing).limit(1).count == 0
|
37
|
-
begin
|
38
|
-
deleted = Katello::InstalledPackage.where('id not in (?)', existing).where("id < #{batch}").delete_all
|
39
|
-
sleep(3) if deleted > 0
|
40
|
-
puts "Inspected #{batch} records in katello_host_installed_packages to remove unreferenced entries in katello_installed_packages.."
|
41
|
-
rescue ActiveRecord::InvalidForeignKey
|
42
|
-
puts "Some records in batch #{batch} were unable to be removed. This is usually due to system registrations or updates that occurred after the script started."
|
43
|
-
puts "The script will now exit. Usually, simply re-running the script is sufficient to work through this issue."
|
44
|
-
raise
|
45
|
-
end
|
46
|
-
batch += 20_000
|
47
|
-
end
|
48
|
-
cleaning_total = sprintf('%.2f', Time.now - cleaning_start)
|
49
|
-
puts "katello_installed_packages table has been cleaned to remove unreferenced entries, total time was #{cleaning_total} seconds."
|
50
|
-
|
51
|
-
puts "Script is complete, setting installed package search to updated method. To disable this, set 'bulk query installed packages' to 'false' in Katello settings."
|
52
|
-
Setting[:bulk_query_installed_packages] = true
|
53
|
-
puts "Done!"
|
54
|
-
end
|
55
|
-
|
56
|
-
class PackageCache
|
57
|
-
def initialize
|
58
|
-
@cache = {}
|
59
|
-
end
|
60
|
-
|
61
|
-
def populate
|
62
|
-
Katello::InstalledPackage.select("nvra, MIN(id) as id").group("nvra").each do |pkg|
|
63
|
-
@cache[pkg.nvra] = pkg.id
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def fetch(nvra)
|
68
|
-
@cache[nvra] ||= Katello::InstalledPackage.where(:nvra => nvra).first.id
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|