katello 3.1.0.rc2.1 → 3.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.

Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/katello/providers/provider_redhat.js +1 -1
  3. data/app/controllers/katello/api/v2/content_view_versions_controller.rb +1 -1
  4. data/app/lib/actions/katello/host/destroy.rb +8 -2
  5. data/app/lib/actions/katello/host/register.rb +1 -0
  6. data/app/lib/actions/pulp/consumer/destroy.rb +2 -0
  7. data/app/mailers/katello/errata_mailer.rb +19 -16
  8. data/app/models/katello/erratum.rb +1 -1
  9. data/app/models/katello/glue/candlepin/pool.rb +5 -2
  10. data/app/models/katello/glue/candlepin/product.rb +5 -5
  11. data/app/models/katello/glue/candlepin/subscription.rb +1 -1
  12. data/app/models/katello/glue/pulp/repo.rb +5 -4
  13. data/app/models/katello/host/subscription_facet.rb +1 -1
  14. data/app/models/katello/host_collection.rb +1 -1
  15. data/app/models/katello/repository.rb +6 -6
  16. data/app/services/katello/candlepin/consumer.rb +9 -0
  17. data/db/migrate/20150930183738_migrate_content_hosts.rb +4 -1
  18. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/filters/package-filter.controller.js +1 -1
  19. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/docker-tags/details/views/docker-tags-details.html +1 -1
  20. data/engines/bastion_katello/app/assets/javascripts/bastion_katello/errata/views/apply-errata.html +1 -1
  21. data/lib/katello/engine.rb +1 -1
  22. data/lib/katello/tasks/clean_backend_objects.rake +45 -45
  23. data/lib/katello/tasks/reimport.rake +43 -0
  24. data/lib/katello/tasks/upgrades/3.0/update_subscription_facet_backend_data.rake +46 -10
  25. data/lib/katello/version.rb +1 -1
  26. metadata +16 -11
  27. data/config/katello.yml +0 -49
  28. data/lib/katello/tasks/reindex.rake +0 -157
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 395d8a31c2395972b2f577bb9355592371adfbcc
4
- data.tar.gz: a606dbd1a2f6272f690beb0e88fa3a1557eafddc
3
+ metadata.gz: bd50631ac9473273192b450d75e6833ef15149f3
4
+ data.tar.gz: 78315e486ab9b9c86efba125ae3d3ac2a5ea99e9
5
5
  SHA512:
6
- metadata.gz: 579ca099fa9cf2b6477c8795ccbcdfb37fa2e51bb93975c628a9134191bb9f983d2e6e466af98833213647e62b833c077d7d8000f7e0b0ac89bfe05c706858fe
7
- data.tar.gz: 4f018616bf7be9e2fd7ff9243963728757cdd0ecc183409a32fb2e257907dfc0ede3e078da93bf004b3f01660318456e0a2d507bc63e76074d1b328727854ee4
6
+ metadata.gz: 0f050ea9020c8e7d4403b4c0fc93105fd27d657c57a30f3d9f0da7f394efbe8a992727a2bd9f5246ecc1d939bf54b20d39433820c730b74f4f3b82ca68ba7c63
7
+ data.tar.gz: aeafb3595411a7032a4461853af5a5ed1f940a5dd9635f9993e3a9cc29ea9baa25c535622a3462cade4c4d66116657ee02eaf773d7ef63627fbc680a7fdd1989
@@ -1,5 +1,5 @@
1
1
  $(document).ready(function() {
2
- var spinner = '<i class="icon-spinner inline-icon icon-spin"></i>';
2
+ var spinner = '<i class="fa fa-spinner fa-spin"></i>';
3
3
 
4
4
  $("#content_tabs").tabs({
5
5
  cache: true,
@@ -141,7 +141,7 @@ module Katello
141
141
  restrict_hosts = nil
142
142
  end
143
143
 
144
- find_bulk_hosts(:editable, params[:update_hosts], restrict_hosts)
144
+ find_bulk_hosts(:edit_hosts, params[:update_hosts], restrict_hosts)
145
145
  end
146
146
 
147
147
  def find_content_view_version
@@ -18,8 +18,7 @@ module Actions
18
18
  end
19
19
 
20
20
  if host.content_host
21
- pool_ids = host.content_host.pools.map { |p| p["id"] }
22
- plan_self(:pool_ids => pool_ids)
21
+ plan_self(:pool_ids => pool_ids(host))
23
22
  host.content_host.destroy!
24
23
  end
25
24
 
@@ -42,6 +41,13 @@ module Actions
42
41
  end
43
42
  end
44
43
 
44
+ def pool_ids(host)
45
+ host.content_host.pools.map { |p| p["id"] }
46
+ rescue RestClient::Gone
47
+ Rails.logger.warn("Host #{host.name} (#{host.subscription_facet.uuid}) removed from candlepin.")
48
+ []
49
+ end
50
+
45
51
  def finalize
46
52
  input[:pool_ids].each do |pool_id|
47
53
  pool = ::Katello::Pool.where(:cp_id => pool_id).first
@@ -58,6 +58,7 @@ module Actions
58
58
  consumer_attributes.except(:installedProducts, :guestIds, :facts))
59
59
  host.subscription_facet.save!
60
60
  host.subscription_facet.update_subscription_status
61
+ host.content_facet.update_errata_status
61
62
  host.refresh_global_status!
62
63
 
63
64
  system = ::Katello::System.find(input[:system_id])
@@ -8,6 +8,8 @@ module Actions
8
8
 
9
9
  def run
10
10
  pulp_extensions.consumer.delete(self.input[:uuid])
11
+ rescue RestClient::ResourceNotFound
12
+ Rails.logger.error(_("Pulp Consumer %s has already been removed") % input[:uuid])
11
13
  end
12
14
  end
13
15
  end
@@ -4,12 +4,14 @@ module Katello
4
4
 
5
5
  def host_errata(options)
6
6
  user = ::User.find(options[:user])
7
- @hosts = ::Host::Managed.authorized("view_hosts").reject do |host|
8
- !host.content_facet || host.content_facet.applicable_errata.empty?
9
- end
10
-
11
- set_locale_for(user) do
12
- mail(:to => user.mail, :subject => _("Host Errata Advisory"))
7
+ ::User.as(user.login) do
8
+ @hosts = ::Host::Managed.authorized("view_hosts").reject do |host|
9
+ !host.content_facet || host.content_facet.applicable_errata.empty?
10
+ end
11
+
12
+ set_locale_for(user) do
13
+ mail(:to => user.mail, :subject => _("Host Errata Advisory"))
14
+ end
13
15
  end
14
16
  end
15
17
 
@@ -28,16 +30,17 @@ module Katello
28
30
 
29
31
  def promote_errata(options)
30
32
  user = options[:user]
31
-
32
- @content_view = options[:content_view]
33
- @environment = options[:environment]
34
- @content_facets = Katello::Host::ContentFacet.where(:lifecycle_environment_id => @environment.id,
35
- :content_view_id => @content_view.id)
36
- @hosts = ::Host::Managed.authorized("view_hosts").where(:id => @content_facets.pluck(:host_id))
37
- @errata = @content_facets.map(&:installable_errata).flatten.uniq
38
-
39
- set_locale_for(user) do
40
- mail(:to => user.mail, :subject => (_("Promotion Summary for %{content_view}") % {:content_view => @content_view.name}))
33
+ ::User.as(user.login) do
34
+ @content_view = options[:content_view]
35
+ @environment = options[:environment]
36
+ @content_facets = Katello::Host::ContentFacet.where(:lifecycle_environment_id => @environment.id,
37
+ :content_view_id => @content_view.id)
38
+ @hosts = ::Host::Managed.authorized("view_hosts").where(:id => @content_facets.pluck(:host_id))
39
+ @errata = @content_facets.map(&:installable_errata).flatten.uniq
40
+
41
+ set_locale_for(user) do
42
+ mail(:to => user.mail, :subject => (_("Promotion Summary for %{content_view}") % {:content_view => @content_view.name}))
43
+ end
41
44
  end
42
45
  end
43
46
 
@@ -88,7 +88,7 @@ module Katello
88
88
  host_repo_errata.erratum_id = #{Katello::Erratum.table_name}.id").
89
89
  where("#{Katello::ContentFacetRepository.table_name}.repository_id = host_repo_errata.repository_id")
90
90
 
91
- query = query.joins(:content_facets).where("#{Katello::Host::ContentFacet.table_name}.host_id" => [hosts.map(&:id)]) if hosts
91
+ query = query.joins(:content_facets).where("#{Katello::Host::ContentFacet.table_name}.host_id" => hosts.map(&:id)) if hosts
92
92
  query.uniq
93
93
  end
94
94
 
@@ -32,7 +32,10 @@ module Katello
32
32
  end
33
33
 
34
34
  def import_pool(cp_pool_id)
35
- pool = Katello::Pool.where(:cp_id => cp_pool_id).first_or_create
35
+ pool = nil
36
+ ::Katello::Util::Support.active_record_retry do
37
+ pool = Katello::Pool.where(:cp_id => cp_pool_id).first_or_create
38
+ end
36
39
  pool.import_data
37
40
  end
38
41
  end
@@ -124,7 +127,7 @@ module Katello
124
127
  def create_activation_key_associations
125
128
  keys = Resources::Candlepin::ActivationKey.get(nil, "?include=id&include=pools.pool.id")
126
129
  activation_key_ids = keys.collect do |key|
127
- key['id'] if key['pools'].present? && key['pools'].any? { |pool| pool['pool']['id'] == cp_id }
130
+ key['id'] if key['pools'].present? && key['pools'].any? { |pool| pool['pool'].try(:[], 'id') == cp_id }
128
131
  end
129
132
  related_keys = ::Katello::ActivationKey.where(:cp_id => activation_key_ids.compact)
130
133
  related_keys.each do |key|
@@ -139,13 +139,13 @@ module Katello
139
139
  end
140
140
 
141
141
  def import_subscription(subscription_id)
142
- sub = ::Katello::Subscription.where(:cp_id => subscription_id).first_or_create
142
+ sub = nil
143
+ ::Katello::Util::Support.active_record_retry do
144
+ sub = ::Katello::Subscription.where(:cp_id => subscription_id).first_or_create
145
+ end
143
146
  sub.import_data
144
147
  pools = ::Katello::Resources::Candlepin::Product.pools(self.organization.label, self.cp_id)
145
- pools.each do |pool_json|
146
- pool = ::Katello::Pool.where(:cp_id => pool_json['id']).first_or_create
147
- pool.import_data
148
- end
148
+ pools.each { |pool_json| ::Katello::Pool.import_pool(pool_json['id']) }
149
149
  end
150
150
 
151
151
  protected
@@ -21,7 +21,7 @@ module Katello
21
21
  end
22
22
 
23
23
  def query_products
24
- self.backend_data["providedProducts"]
24
+ self.backend_data["providedProducts"] + self.backend_data["derivedProvidedProducts"]
25
25
  end
26
26
 
27
27
  def import_data
@@ -181,24 +181,25 @@ module Katello
181
181
  def importer_ssl_options(capsule = nil)
182
182
  if capsule
183
183
  ueber_cert = ::Cert::Certs.ueber_cert(organization)
184
- {
184
+ importer_options = {
185
185
  :ssl_client_cert => ueber_cert[:cert],
186
186
  :ssl_client_key => ueber_cert[:key],
187
187
  :ssl_ca_cert => ::Cert::Certs.ca_cert
188
188
  }
189
- elsif redhat? && self.content_view.default?
190
- {
189
+ elsif self.try(:redhat?) && self.content_view.default?
190
+ importer_options = {
191
191
  :ssl_client_cert => self.product.certificate,
192
192
  :ssl_client_key => self.product.key,
193
193
  :ssl_ca_cert => Resources::CDN::CdnResource.ca_file_contents
194
194
  }
195
195
  else
196
- {
196
+ importer_options = {
197
197
  :ssl_client_cert => nil,
198
198
  :ssl_client_key => nil,
199
199
  :ssl_ca_cert => nil
200
200
  }
201
201
  end
202
+ importer_options
202
203
  end
203
204
 
204
205
  def generate_distributors(capsule = false)
@@ -99,7 +99,7 @@ module Katello
99
99
  end
100
100
 
101
101
  def self.find_host(name, organization)
102
- hosts = ::Host.where(:name => name)
102
+ hosts = ::Host.where(:name => name.downcase)
103
103
  return nil if hosts.empty? #no host exists
104
104
  if hosts.where("organization_id = #{organization.id} OR organization_id is NULL").empty? #not in the correct org
105
105
  #TODO: http://projects.theforeman.org/issues/11532
@@ -27,7 +27,7 @@ module Katello
27
27
 
28
28
  scoped_search :on => :name, :complete_value => true
29
29
  scoped_search :on => :organization_id, :complete_value => true, :only_explicit => true
30
- scoped_search :in => :hosts, :complete_value => false
30
+ scoped_search :in => :hosts, :on => :name, :rename => :host, :complete_value => true
31
31
 
32
32
  def max_hosts_check
33
33
  if !unlimited_hosts && (hosts.length > 0 && (hosts.length.to_i > max_hosts.to_i)) && max_hosts_changed?
@@ -37,21 +37,21 @@ module Katello
37
37
  :dependent => :destroy, :inverse_of => :repository
38
38
  has_many :content_views, :through => :content_view_repositories
39
39
 
40
- has_many :repository_errata, :class_name => "Katello::RepositoryErratum", :dependent => :destroy
40
+ has_many :repository_errata, :class_name => "Katello::RepositoryErratum", :dependent => :delete_all
41
41
  has_many :errata, :through => :repository_errata
42
42
 
43
- has_many :repository_rpms, :class_name => "Katello::RepositoryRpm", :dependent => :destroy
43
+ has_many :repository_rpms, :class_name => "Katello::RepositoryRpm", :dependent => :delete_all
44
44
  has_many :rpms, :through => :repository_rpms
45
45
 
46
- has_many :repository_puppet_modules, :class_name => "Katello::RepositoryPuppetModule", :dependent => :destroy
46
+ has_many :repository_puppet_modules, :class_name => "Katello::RepositoryPuppetModule", :dependent => :delete_all
47
47
  has_many :puppet_modules, :through => :repository_puppet_modules
48
48
 
49
- has_many :repository_docker_manifests, :class_name => "Katello::RepositoryDockerManifest", :dependent => :destroy
49
+ has_many :repository_docker_manifests, :class_name => "Katello::RepositoryDockerManifest", :dependent => :delete_all
50
50
  has_many :docker_manifests, :through => :repository_docker_manifests
51
51
 
52
52
  has_many :docker_tags, :dependent => :destroy, :class_name => "Katello::DockerTag"
53
53
 
54
- has_many :repository_ostree_branches, :class_name => "Katello::RepositoryOstreeBranch", :dependent => :destroy
54
+ has_many :repository_ostree_branches, :class_name => "Katello::RepositoryOstreeBranch", :dependent => :delete_all
55
55
  has_many :ostree_branches, :through => :repository_ostree_branches
56
56
 
57
57
  has_many :system_repositories, :class_name => "Katello::SystemRepository", :dependent => :destroy
@@ -60,7 +60,7 @@ module Katello
60
60
  has_many :content_facet_repositories, :class_name => "Katello::ContentFacetRepository", :dependent => :destroy
61
61
  has_many :content_facets, :through => :content_facet_repositories
62
62
 
63
- has_many :repository_package_groups, :class_name => "Katello::RepositoryPackageGroup", :dependent => :destroy
63
+ has_many :repository_package_groups, :class_name => "Katello::RepositoryPackageGroup", :dependent => :delete_all
64
64
  has_many :package_groups, :through => :repository_package_groups
65
65
 
66
66
  has_many :kickstart_content_facets, :class_name => "Katello::Host::ContentFacet", :foreign_key => :kickstart_repository_id,
@@ -120,6 +120,15 @@ module Katello
120
120
  end
121
121
  end
122
122
 
123
+ def self.orphaned_consumer_ids
124
+ #returns consumer ids in candlepin with no matching katello entry
125
+ cp_consumers = ::Katello::Resources::Candlepin::Consumer.get({})
126
+ cp_consumers.reject! { |consumer| consumer['type']['label'] == 'uebercert' }
127
+ cp_consumer_ids = cp_consumers.map { |cons| cons["uuid"] }
128
+ katello_consumer_ids = ::Katello::Host::SubscriptionFacet.pluck(:uuid)
129
+ cp_consumer_ids - katello_consumer_ids
130
+ end
131
+
123
132
  def self.distribution_to_puppet_os(name)
124
133
  return ::Operatingsystem::REDHAT_ATOMIC_HOST_OS if name == ::Operatingsystem::REDHAT_ATOMIC_HOST_DISTRO_NAME
125
134
 
@@ -337,13 +337,16 @@ class MigrateContentHosts < ActiveRecord::Migration
337
337
  end
338
338
 
339
339
  User.current = User.anonymous_api_admin
340
+ system_count = ::MigrateContentHosts::System.all.count
341
+
342
+ return true if system_count == 0
340
343
 
341
344
  ping = ::Katello::Ping.ping
342
345
  if ping[:status] != ::Katello::Ping::OK_RETURN_CODE
343
346
  fail _("Some backend services are not running: %s") % ping.inspect
344
347
  end
345
348
 
346
- ::Katello::System.where(:uuid => nil).destroy_all
349
+ ::MigrateContentHosts::System.where(:uuid => nil).destroy_all
347
350
 
348
351
  ensure_one_system_per_hostname(MigrateContentHosts::System.where("type != '#{HYPERVISOR_CLASS}'").all)
349
352
 
@@ -158,7 +158,7 @@ angular.module('Bastion.content-views').controller('PackageFilterController',
158
158
  var repositoryIds = $scope.contentView['repository_ids'],
159
159
  promise;
160
160
 
161
- promise = Package.autocompleteName({repoids: repositoryIds, term: term}).$promise;
161
+ promise = Package.autocompleteName({'repoids[]': repositoryIds, term: term}).$promise;
162
162
 
163
163
  return promise.then(function (data) {
164
164
  return data.results;
@@ -1,7 +1,7 @@
1
1
  <span page-title ng-model="tag">{{ 'Docker Tag: ' | translate }} {{ tag.full_name }}</span>
2
2
 
3
3
  <div class="loading-mask loading-mask-panel" ng-show="panel.loading">
4
- <i class="icon-spinner icon-spin"></i>
4
+ <i class="fa fa-spinner fa-spin"></i>
5
5
  {{ "Loading..." | translate }}
6
6
  </div>
7
7
 
@@ -20,7 +20,7 @@
20
20
  </div>
21
21
 
22
22
  <div class="alert alert-info" ng-show="state.working">
23
- <i class="icon-spinner inline-icon icon-spin"></i>
23
+ <i class="fa fa-spinner fa-spin"></i>
24
24
  {{ 'Processing' | translate }}
25
25
  </div>
26
26
 
@@ -254,7 +254,7 @@ module Katello
254
254
  load "#{Katello::Engine.root}/lib/katello/tasks/setup.rake"
255
255
  load "#{Katello::Engine.root}/lib/katello/tasks/delete_orphaned_content.rake"
256
256
  load "#{Katello::Engine.root}/lib/katello/tasks/regenerate_repo_metadata.rake"
257
- load "#{Katello::Engine.root}/lib/katello/tasks/reindex.rake"
257
+ load "#{Katello::Engine.root}/lib/katello/tasks/reimport.rake"
258
258
  load "#{Katello::Engine.root}/lib/katello/tasks/rubocop.rake"
259
259
  load "#{Katello::Engine.root}/lib/katello/tasks/clean_backend_objects.rake"
260
260
  load "#{Katello::Engine.root}/lib/katello/tasks/upgrade_check.rake"
@@ -1,22 +1,30 @@
1
1
  namespace :katello do
2
- desc "Cleans backend objects (systems) that are missing in one or more backend systems"
3
- task :clean_backend_objects => ["environment"] do
4
- def cleanup_systems
5
- Katello::System.find_each do |system|
6
- if system.uuid.nil?
7
- cp_fail = true
8
- pulp_fail = true
9
- else
10
- cp_fail = test_method { system.facts }
11
- pulp_fail = test_method { system.pulp_facts } unless system.is_a?(Katello::Hypervisor)
2
+ desc "Cleans backend objects (hosts) that are missing in one or more backend systems. Run with COMMIT=true to commit changes."
3
+ task :clean_backend_objects => ["environment", "check_ping"] do
4
+ def cleanup_hosts
5
+ Host.includes(:content_facet, :subscription_facet).find_each do |host|
6
+ if test_candlepin(host) || test_pulp(host)
7
+ print "Host #{host.id} #{host.name} #{host.subscription_facet.try(:uuid)} is partially missing. Un-registering\n"
8
+ execute("Failed to delete host") { ForemanTasks.sync_task(::Actions::Katello::Host::Unregister, host) }
12
9
  end
10
+ end
11
+ end
13
12
 
14
- if cp_fail || pulp_fail
15
- print "System #{system.id} #{system.name} #{system.uuid} is partially missing. Cleaning.\n"
16
- ::Katello::Resources::Candlepin::Consumer.destroy(system.uuid) unless cp_fail
17
- system.del_pulp_consumer unless (pulp_fail || system.is_a?(Katello::Hypervisor))
18
- system.destroy!
19
- end
13
+ def test_pulp(host)
14
+ if host.content_facet.try(:uuid)
15
+ test_method { Katello.pulp_server.extensions.consumer.retrieve(host.content_facet.uuid) }
16
+ else
17
+ test_method { false }
18
+ end
19
+ end
20
+
21
+ def test_candlepin(host)
22
+ if host.subscription_facet && host.subscription_facet.uuid
23
+ test_method { ::Katello::Resources::Candlepin::Consumer.get(host.subscription_facet.uuid) }
24
+ elsif host.subscription_facet
25
+ test_method { true }
26
+ else
27
+ test_method { false }
20
28
  end
21
29
  end
22
30
 
@@ -31,40 +39,32 @@ namespace :katello do
31
39
  true
32
40
  end
33
41
 
34
- def cleanup_host_delete_artifacts
35
- # clean up dirty consumer data in candleplin,
36
- # that did not get cleared by host delete.
37
- # look at https://bugzilla.redhat.com/show_bug.cgi?id=1140653
38
- # for more information
39
- cp_consumers = ::Katello::Resources::Candlepin::Consumer.get({})
40
- cp_consumers.reject! { |consumer| consumer['type']['label'] == 'uebercert' }
41
- cp_consumer_ids = cp_consumers.map { |cons| cons["uuid"] }
42
- katello_consumer_ids = ::Katello::System.pluck(:uuid)
43
- deletable_ids = cp_consumer_ids - katello_consumer_ids
44
- deletable_ids.each do |consumer_id|
45
- begin
46
- Katello::Resources::Candlepin::Consumer.destroy(consumer_id)
47
- rescue RestClient::Exception => e
48
- p "exception when destroying candlepin consumer #{consumer_id}:#{e.inspect}"
49
- end
50
- begin
51
- Katello.pulp_server.extensions.consumer.delete(consumer_id)
52
- rescue RestClient::ResourceNotFound # rubocop:disable Lint/HandleExceptions
53
- #do nothing
54
- rescue RestClient::Exception => e
55
- p "exception when destroying pulp consumer #{consumer_id}:#{e.inspect}"
56
- end
42
+ # rubocop:disable HandleExceptions
43
+ def execute(error_msg)
44
+ if ENV['COMMIT'] == 'true'
45
+ yield
46
+ end
47
+ rescue RestClient::ResourceNotFound
48
+ rescue => e
49
+ print error_msg
50
+ print e.inspect
51
+ end
52
+
53
+ def clean_backend_orphans
54
+ consumer_ids = Katello::Candlepin::Consumer.orphaned_consumer_ids
55
+ print "#{consumer_ids.count} orphaned consumer id(s) found.\n"
56
+ consumer_ids.each do |consumer_id|
57
+ execute("exception when destroying candlepin consumer #{consumer_id}") { Katello::Resources::Candlepin::Consumer.destroy(consumer_id) }
58
+ execute("exception when destroying pulp consumer #{consumer_id}") { Katello.pulp_server.extensions.consumer.delete(consumer_id) }
57
59
  end
58
60
  end
59
61
 
60
- # check services first
61
- result = ::Katello::Ping.ping
62
- if result[:status] != ::Katello::Ping::OK_RETURN_CODE
63
- fail "Could not connect to service: #{result[:message]}"
62
+ unless ENV['COMMIT'] == 'true'
63
+ print "The following changes will not actually be performed. Rerun with COMMIT=true to apply the changes\n"
64
64
  end
65
65
 
66
66
  User.current = User.anonymous_admin
67
- cleanup_systems
68
- cleanup_host_delete_artifacts
67
+ cleanup_hosts
68
+ clean_backend_orphans
69
69
  end
70
70
  end
@@ -0,0 +1,43 @@
1
+ namespace :katello do
2
+ desc "Runs a katello ping and prints out the statuses of each service"
3
+ task :check_ping do
4
+ User.current = User.anonymous_admin
5
+ ping_results = Katello::Ping.ping
6
+ if ping_results[:status] != "ok"
7
+ pp ping_results
8
+ fail("Not all the services have been started. Check the status report above and try again.")
9
+ end
10
+ end
11
+
12
+ desc "Reimports information from backend systems"
13
+ task :reimport => ["environment", "katello:check_ping"] do
14
+ User.current = User.anonymous_admin #set a user for orchestration
15
+
16
+ Dir.glob(Katello::Engine.root.to_s + '/app/models/katello/*.rb').each { |file| require file }
17
+
18
+ models = [Katello::Erratum,
19
+ Katello::PackageGroup,
20
+ Katello::PuppetModule,
21
+ Katello::Rpm,
22
+ Katello::Subscription,
23
+ Katello::Pool]
24
+
25
+ models << Katello::OstreeBranch if Katello::RepositoryTypeManager.find(Katello::Repository::OSTREE_TYPE).present?
26
+
27
+ models.each do |model|
28
+ print "Importing #{model.name}\n"
29
+ model.import_all
30
+ end
31
+
32
+ print "Importing Activation Key Subscriptions\n"
33
+ Katello::ActivationKey.all.each do |ack_key|
34
+ ack_key.import_pools
35
+ end
36
+
37
+ print "Importing Docker Content\n"
38
+ # For docker repositories, index all associated manifests and tags
39
+ Katello::Repository.docker_type.each do |docker_repo|
40
+ docker_repo.index_db_docker_manifests
41
+ end
42
+ end
43
+ end
@@ -2,29 +2,65 @@ namespace :katello do
2
2
  namespace :upgrades do
3
3
  namespace '3.0' do
4
4
  task :update_subscription_facet_backend_data => ["environment"] do
5
+ def error(message)
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 ||= []
5
31
  User.current = User.anonymous_api_admin
6
32
  puts _("Updating backend data for subscription facets")
7
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
+
8
41
  Katello::Host::SubscriptionFacet.find_each do |subscription_facet|
9
42
  begin
10
43
  candlepin_attrs = subscription_facet.candlepin_consumer.consumer_attributes
11
44
  subscription_facet.import_database_attributes(candlepin_attrs)
12
-
13
45
  subscription_facet.host = ::Host::Managed.find(subscription_facet.host_id)
14
46
  subscription_facet.save!
15
47
 
16
- Katello::Host::SubscriptionFacet.update_facts(subscription_facet.host, candlepin_attrs[:facts])
17
- rescue RestClient::Exception => exception
18
- Rails.logger.error exception
19
- end
20
- end
48
+ host = subscription_facet.host
49
+ if host.name.include?('_') || host.name != host.name.downcase
50
+ host.name = host.name.gsub('_', '-').downcase
51
+ host.save!
52
+ end
21
53
 
22
- #there may be some invalid hosts, if there are create a primary interface
23
- ::Host.includes(:interfaces).find_each do |host|
24
- if host.primary_interface.nil?
25
- host.interfaces.create!(:primary => true)
54
+ Katello::Host::SubscriptionFacet.update_facts(subscription_facet.host, candlepin_attrs[:facts])
55
+ rescue StandardError => exception
56
+ error("Error: #{subscription_facet.host.name} - #{subscription_facet.host.id}")
57
+ error(candlepin_attrs)
58
+ error(exception.message)
59
+ error(exception.backtrace.join("\n"))
60
+ error("\n")
26
61
  end
27
62
  end
63
+ report_errors
28
64
  end
29
65
  end
30
66
  end
@@ -1,3 +1,3 @@
1
1
  module Katello
2
- VERSION = "3.1.0.rc2.1".freeze
2
+ VERSION = "3.1.0".freeze
3
3
  end
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.1.0.rc2.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - N/A
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-22 00:00:00.000000000 Z
11
+ date: 2016-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -101,6 +101,9 @@ dependencies:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: 0.2.0
104
+ - - "<"
105
+ - !ruby/object:Gem::Version
106
+ version: 3.0.0
104
107
  type: :runtime
105
108
  prerelease: false
106
109
  version_requirements: !ruby/object:Gem::Requirement
@@ -108,6 +111,9 @@ dependencies:
108
111
  - - ">="
109
112
  - !ruby/object:Gem::Version
110
113
  version: 0.2.0
114
+ - - "<"
115
+ - !ruby/object:Gem::Version
116
+ version: 3.0.0
111
117
  - !ruby/object:Gem::Dependency
112
118
  name: qpid_messaging
113
119
  requirement: !ruby/object:Gem::Requirement
@@ -208,16 +214,16 @@ dependencies:
208
214
  name: bastion
209
215
  requirement: !ruby/object:Gem::Requirement
210
216
  requirements:
211
- - - "<"
217
+ - - '='
212
218
  - !ruby/object:Gem::Version
213
- version: 3.3.0
219
+ version: 3.2.0
214
220
  type: :runtime
215
221
  prerelease: false
216
222
  version_requirements: !ruby/object:Gem::Requirement
217
223
  requirements:
218
- - - "<"
224
+ - - '='
219
225
  - !ruby/object:Gem::Version
220
- version: 3.3.0
226
+ version: 3.2.0
221
227
  - !ruby/object:Gem::Dependency
222
228
  name: factory_girl_rails
223
229
  requirement: !ruby/object:Gem::Requirement
@@ -1187,7 +1193,6 @@ files:
1187
1193
  - config/initializers/rabl_init.rb
1188
1194
  - config/initializers/runcible.rb
1189
1195
  - config/katello.yaml.example
1190
- - config/katello.yml
1191
1196
  - config/locales/README
1192
1197
  - config/locales/bn.yml
1193
1198
  - config/locales/compare_upstream.sh
@@ -1838,7 +1843,7 @@ files:
1838
1843
  - lib/katello/tasks/jsroutes.rake
1839
1844
  - lib/katello/tasks/pretty_routes.rake
1840
1845
  - lib/katello/tasks/regenerate_repo_metadata.rake
1841
- - lib/katello/tasks/reindex.rake
1846
+ - lib/katello/tasks/reimport.rake
1842
1847
  - lib/katello/tasks/rubocop.rake
1843
1848
  - lib/katello/tasks/setup.rake
1844
1849
  - lib/katello/tasks/simplecov.rake
@@ -1962,12 +1967,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
1962
1967
  version: '0'
1963
1968
  required_rubygems_version: !ruby/object:Gem::Requirement
1964
1969
  requirements:
1965
- - - ">"
1970
+ - - ">="
1966
1971
  - !ruby/object:Gem::Version
1967
- version: 1.3.1
1972
+ version: '0'
1968
1973
  requirements: []
1969
1974
  rubyforge_project:
1970
- rubygems_version: 2.4.8
1975
+ rubygems_version: 2.5.1
1971
1976
  signing_key:
1972
1977
  specification_version: 4
1973
1978
  summary: ''
data/config/katello.yml DELETED
@@ -1,49 +0,0 @@
1
- #
2
- # WARNING: THIS CONFIGURATION WAS GENERATED BY KATELLO-CONFIGURE TOOL,
3
- # CHANGES WILL LIKELY BE OVERWRITTEN. IF YOU WISH TO PRESERVE ANY CHANGES
4
- # TO THIS FILE PLEASE EDIT /usr/share/katello/install/default-answer-file
5
- # FOR THE CORRESPONDING OPTION AND RERUN katello-configure.
6
- #
7
-
8
- # Katello configuration
9
- #
10
- # :vim:sw=2:ts=2:et:
11
-
12
- # see /usr/share/katello/config.katello_defaults.yml for available options
13
-
14
- :katello:
15
-
16
- :rest_client_timeout: 120
17
-
18
- :post_sync_url: https://robot.example.com/katello/api/v2/repositories/sync_complete?token=test
19
-
20
- :candlepin:
21
- :url: https://robot.example.com:8443/candlepin
22
- :oauth_key: katello
23
- :oauth_secret: katello
24
-
25
- :pulp:
26
- :url: https://robot.example.com/pulp/api/v2/
27
- :oauth_key: katello
28
- :oauth_secret: katello
29
-
30
- :qpid:
31
- :url: amqp:ssl:robot.example.com:5671
32
- :subscriptions_queue_address: katello_event_queue
33
-
34
- :loggers:
35
- :glue:
36
- :enabled: false
37
- :pulp_rest:
38
- :enabled: false
39
- :cp_rest:
40
- :enabled: false
41
- :cp_proxy:
42
- :enabled: false
43
- :action:
44
- :enabled: false
45
- :tire_rest:
46
- :enabled: false
47
- :manifest_import_logger:
48
- :enabled: false
49
-
@@ -1,157 +0,0 @@
1
- namespace :katello do
2
- class ReindexHelper
3
- LOG_FILE = "#{Rails.root}/log/reindex.log".freeze
4
-
5
- attr_accessor :reindex_logger
6
-
7
- def reindex_logger
8
- unless @reindex_logger
9
- @reindex_logger = Logger.new(LOG_FILE)
10
- @reindex_logger.formatter = Logger::Formatter.new
11
- @reindex_logger.level = Logger::DEBUG
12
- end
13
- @reindex_logger
14
- end
15
-
16
- def log(message, options = {})
17
- puts message if options[:console]
18
- if options[:error]
19
- reindex_logger.error(message)
20
- else
21
- reindex_logger.info("#{message}")
22
- end
23
- end
24
-
25
- def log_error(message)
26
- log(message, :error => true)
27
- end
28
-
29
- def fetch_resource
30
- return yield
31
- rescue RestClient::ResourceNotFound, RestClient::BadRequest => _ # rubocop:disable Lint/HandleExceptions
32
- # ignore
33
- end
34
-
35
- def index_objects(object_class)
36
- log("Re-indexing #{object_class.name}", :console => true)
37
- begin
38
- yield
39
- rescue => _
40
- if object_class.ancestors.include?(Katello::Glue::Pulp::PulpContentUnit)
41
- report_bad_backend_class(object_class.name)
42
- else
43
- bad_objects = []
44
- object_class.each do |object|
45
- begin
46
- object.update_index
47
- rescue => e
48
- bad_objects << [object, e]
49
- end
50
- end
51
- report_bad_objects(bad_objects, object_class.name)
52
- end
53
- end
54
- end
55
-
56
- def report_bad_objects(bad_objects_exception_hash, model_name)
57
- User.current = User.anonymous_admin
58
- log("The following #{model_name} items could not be indexed due to various reasons.", :console => true)
59
- log("Please check #{ReindexHelper::LOG_FILE} for more detailed information.", :console => true)
60
-
61
- bad_objects_exception_hash.each do |object, exception|
62
- log("Object: #{object.inspect}", :console => true)
63
- log_error("Exception: #{exception.message}")
64
- if object.is_a? Katello::Repository
65
- notes = []
66
- notes << "Pulp Repository #{object.pulp_id} was not found." if object.pulp_repo_facts.nil?
67
- if object.content_id
68
- content = fetch_resource { object.content }
69
- notes << "Candlepin Content was not available for #{object.name}." if content.nil?
70
- end
71
- log_error "Notes:\n #{notes.join("\n")}" unless notes.empty?
72
- elsif object.is_a? Katello::System
73
- notes = []
74
- facts = fetch_resource { object.pulp_facts }
75
- notes << "Pulp Consumer #{object.uuid} was not found." if facts.nil?
76
- candlepin_consumer_info = fetch_resource { Katello::Resources::Candlepin::Consumer.get(object.uuid) }
77
- notes << "Candlepin Consumer was not available for #{object.name}." if candlepin_consumer_info.nil?
78
- notes << "Foreman Host was not available for #{object.name}." if object.foreman_host.nil?
79
-
80
- log_error "Notes:\n #{notes.join("\n")}" unless notes.empty?
81
- end
82
- log_error "Stack Trace: \n #{exception.backtrace.join("\n")}"
83
- end
84
- end
85
- end
86
-
87
- def report_bad_backend_class(model_name)
88
- log("The following #{model_name} items could not be indexed due to various reasons.", :console => true)
89
- log("Please check #{ReindexHelper::LOG_FILE} for more detailed information.", :console => true)
90
- log_error("Exception: #{exception.message}")
91
- log_error "Stack Trace: \n #{exception.backtrace.join("\n")}"
92
- end
93
-
94
- desc "Runs a katello ping and prints out the statuses of each service"
95
- task :check_ping do
96
- User.current = User.anonymous_admin
97
- ping_results = Katello::Ping.ping
98
- if ping_results[:status] != "ok"
99
- pp ping_results
100
- fail("Not all the services have been started. Check the status report above and try again.")
101
- end
102
- end
103
-
104
- desc "Regenerates the search indicies for various Katello objects"
105
- task :reindex => ["environment", "katello:check_ping"] do
106
- User.current = User.anonymous_admin #set a user for orchestration
107
-
108
- Dir.glob(Katello::Engine.root.to_s + '/app/models/katello/*.rb').each { |file| require file }
109
- reindex_helper = ReindexHelper.new
110
-
111
- Katello::Util::Search.active_record_search_classes.each do |model|
112
- reindex_helper.log("Re-indexing #{model.name}", :console => true)
113
- sub_classes = model.subclasses
114
-
115
- if sub_classes.empty? || !model.column_names.include?('type')
116
- objects = model.all
117
- else
118
- #Index STI subclasses separately
119
- objects = model.where(:type => [nil, model.name])
120
- end
121
-
122
- begin
123
- model.index.import(objects) if objects.count > 0
124
- rescue => e
125
- bad_objects = []
126
- objects.each do |object|
127
- begin
128
- object.update_index
129
- rescue => e
130
- bad_objects << [object, e]
131
- end
132
- end
133
- reindex_helper.report_bad_objects(bad_objects, model.name)
134
- end
135
- end
136
-
137
- Katello::Erratum.import_all
138
- Katello::PackageGroup.import_all
139
- Katello::PuppetModule.import_all
140
- Katello::OstreeBranch.import_all if Katello::RepositoryTypeManager.find(Katello::Repository::OSTREE_TYPE).present?
141
- Katello::Subscription.import_all
142
- Katello::Pool.import_all
143
-
144
- Katello::ActivationKey.all.each do |ack_key|
145
- ack_key.import_pools
146
- end
147
-
148
- reindex_helper.index_objects(Katello::Rpm) do
149
- Katello::Rpm.import_all
150
- end
151
-
152
- # For docker repositories, index all associated manifests and tags
153
- Katello::Repository.docker_type.each do |docker_repo|
154
- docker_repo.index_db_docker_manifests
155
- end
156
- end
157
- end