katello 3.0.0.rc7 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of katello might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 636bd960fc851d7cfc7cad566463d5f9d12ecd31
4
- data.tar.gz: 6e0d3f04c2ea64cc9e4d587b634e901328023f99
3
+ metadata.gz: 50ee4bb4ee7bca71af7c79c1a52cc26adab5e6cd
4
+ data.tar.gz: 5c41510b896e3e3e5c2109126dc850d789c6b43e
5
5
  SHA512:
6
- metadata.gz: d95efc1f9e60ae63131a696dc04cc59887f84c59b0da8cca8682af6d94b560267f5b6f2e0a11c66dd249be71438dc88f3de65f0d3b720730db10042e63403cfb
7
- data.tar.gz: 7f797259505a86902c5335fed36f1affb78e84f75bcbc0f35709887f6907067c555e17312e75883269a101bfd6cf32e93efc6255a6a87499b5b19f0f2ce0a8c4
6
+ metadata.gz: 8a6facf5f73221e202cd7dad30bb5b81b9b64bc6ba223696abee7815b258ad2d42592f81a3f021ad47d981e32ae24e309b12f2559456dc1f165faa99aa8e396a
7
+ data.tar.gz: 7fd62ba9c47195a89655b2bcd542de757c8472aa07a9db0a7604e9af54d3818992a9e9fa7964de2bceed2e9ce5d34483a055b0df050d48467b378fe1af8c614d
@@ -243,7 +243,7 @@ module Katello
243
243
  def facts
244
244
  User.as_anonymous_admin do
245
245
  sync_task(::Actions::Katello::Host::Update, @host, rhsm_params)
246
- Katello::Host::SubscriptionFacet.update_facts(@host, rhsm_params[:facts])
246
+ Katello::Host::SubscriptionFacet.update_facts(@host, rhsm_params[:facts]) unless rhsm_params[:facts].nil?
247
247
  end
248
248
  render :json => {:content => _("Facts successfully updated.")}, :status => 200
249
249
  end
@@ -435,8 +435,8 @@ module Katello
435
435
  def authorize_proxy_routes
436
436
  deny_access unless (authenticate || authenticate_client)
437
437
 
438
- route, params = Engine.routes.router.recognize(request) do |rte, parameters|
439
- break rte, parameters if rte.name
438
+ route, _, params = Engine.routes.router.recognize(request) do |rte, match, parameters|
439
+ break rte, match, parameters if rte.name
440
440
  end
441
441
 
442
442
  # route names are defined in routes.rb (:as => :name)
@@ -144,9 +144,34 @@ module Actions
144
144
  end
145
145
  unless Rails.env.test?
146
146
  world.before_termination do
147
- # make sure we close the service at exit to finish the listening action
148
- suspended_action.ask(Close).wait
149
- self.class.triggered_action.finished.wait
147
+ finish_service
148
+ end
149
+ end
150
+ end
151
+ end
152
+
153
+ def finish_service
154
+ log_prefix = "Finishing #{self.class.name} #{task.id}"
155
+ action_logger.info(log_prefix)
156
+ # make sure we close the service at exit to finish the listening action
157
+ suspended_action.ask(Close).wait
158
+ # if the triggered_action is nil, it means the action was resumed from
159
+ # previous run due to some unexpected termination of previous process
160
+ if self.class.triggered_action
161
+ self.class.triggered_action.finished.wait
162
+ else
163
+ max_attempts = 10
164
+ (1..max_attempts).each do |attempt|
165
+ task.reload
166
+ if !task.pending? || task.paused?
167
+ break
168
+ else
169
+ action_logger.info("#{log_prefix}: attempt #{attempt}/#{max_attempts}")
170
+ if attempt == max_attempts
171
+ action_logger.info("#{log_prefix} failed, skipping")
172
+ else
173
+ sleep 1
174
+ end
150
175
  end
151
176
  end
152
177
  end
@@ -81,8 +81,8 @@ module Actions
81
81
  repos.select do |repo|
82
82
  repo_details = capsule.pulp_repo_facts(repo.pulp_id)
83
83
  next unless repo_details
84
- capsule_importer = repo_details["importers"][0]["config"]
85
- !(repo.importer_matches?(capsule_importer))
84
+ capsule_importer = repo_details["importers"][0].try(:[], "config")
85
+ capsule_importer.nil? || !(repo.importer_matches?(capsule_importer))
86
86
  end
87
87
  end
88
88
 
@@ -66,12 +66,6 @@ module Actions
66
66
  end
67
67
 
68
68
  def done?
69
- output[:pulp_tasks].each do |pulp_task|
70
- if pulp_exception = ::Katello::Errors::PulpError.from_task(pulp_task)
71
- fail pulp_exception
72
- end
73
- end
74
-
75
69
  external_task.all? { |task| task[:finish_time] || FINISHED_STATES.include?(task[:state]) }
76
70
  end
77
71
 
@@ -122,6 +116,11 @@ module Actions
122
116
  output[:pulp_tasks] = (external_task_data + new_tasks).reject do |task|
123
117
  task["task_id"].nil? || (task["tags"] && (task["tags"] & ignored_tags).present?)
124
118
  end
119
+ output[:pulp_tasks].each do |pulp_task|
120
+ if pulp_exception = ::Katello::Errors::PulpError.from_task(pulp_task)
121
+ fail pulp_exception
122
+ end
123
+ end
125
124
  end
126
125
 
127
126
  def get_new_tasks(current_list, spawned_task_ids)
@@ -1,7 +1,7 @@
1
1
  module Actions
2
2
  module Pulp
3
3
  module Repository
4
- class AssociateImporter < Pulp::Abstract
4
+ class AssociateImporter < Pulp::AbstractAsyncTask
5
5
  input_format do
6
6
  param :repo_id
7
7
  param :type_id
@@ -10,9 +10,8 @@ module Actions
10
10
  param :capsule_id
11
11
  end
12
12
 
13
- def run
14
- output[:response] = pulp_resources.repository.
15
- associate_importer(*input.values_at(:repo_id, :type_id, :config))
13
+ def invoke_external_task
14
+ pulp_resources.repository.associate_importer(*input.values_at(:repo_id, :type_id, :config))
16
15
  end
17
16
  end
18
17
  end
@@ -31,7 +31,7 @@ module Actions
31
31
  :repo_id => repository.pulp_id,
32
32
  :type_id => repository.importers.first['importer_type_id'],
33
33
  :config => importer_config,
34
- :capsule_id => input[:capsule_id],
34
+ :capsule_id => capsule_id,
35
35
  :hash => { :importer_id => importer.id }
36
36
  )
37
37
  end
@@ -42,15 +42,17 @@ module Katello
42
42
  end
43
43
 
44
44
  def humanized_action
45
- case self.task.label
45
+ case self.task.try(:label)
46
46
  when "Actions::Katello::ContentViewVersion::Export"
47
47
  _("Exported version")
48
48
  when "Actions::Katello::ContentView::Publish"
49
49
  _("Published new version")
50
50
  when "Actions::Katello::ContentView::Promote"
51
- _("Promoted to %{environment}") % { :environment => self.environment.name }
51
+ _("Promoted to %{environment}") % { :environment => self.environment.try(:name) || _('Unknown') }
52
52
  when "Actions::Katello::ContentView::Remove"
53
- _("Deleted from %{environment}") % { :environment => self.environment.name }
53
+ _("Deleted from %{environment}") % { :environment => self.environment.try(:name) || _('Unknown')}
54
+ else
55
+ _("Unknown Action")
54
56
  end
55
57
  end
56
58
 
@@ -161,7 +161,7 @@ module Katello
161
161
  if capsule
162
162
  self.full_path(nil, true)
163
163
  else
164
- self.url
164
+ self.url if self.respond_to?(:url)
165
165
  end
166
166
  end
167
167
 
@@ -14,14 +14,22 @@ module Katello
14
14
  attr_accessible :release_version, :autoheal, :service_level, :host
15
15
 
16
16
  def update_from_consumer_attributes(consumer_params)
17
+ import_database_attributes(consumer_params)
18
+ self.installed_products = consumer_params['installedProducts'] unless consumer_params['installedProducts'].blank?
19
+ self.hypervisor_guest_uuids = consumer_params['guestIds'] unless consumer_params['hypervisor_guest_uuids'].blank?
20
+ self.facts = consumer_params['facts'] unless consumer_params['facts'].blank?
21
+ end
22
+
23
+ def import_database_attributes(consumer_params)
17
24
  self.autoheal = consumer_params['autoheal'] unless consumer_params['autoheal'].blank?
18
25
  self.service_level = consumer_params['serviceLevel'] unless consumer_params['serviceLevel'].blank?
19
26
  self.registered_at = consumer_params['created'] unless consumer_params['created'].blank?
20
27
  self.last_checkin = consumer_params['lastCheckin'] unless consumer_params['lastCheckin'].blank?
21
- self.release_version = consumer_params['releaseVer'] unless consumer_params['releaseVer'].blank?
22
28
 
23
- if self.release_version.is_a?(Hash)
24
- self.release_version = self.release_version['releaseVer']
29
+ unless consumer_params['releaseVer'].blank?
30
+ release = consumer_params['releaseVer']
31
+ release = release['releaseVer'] if release.is_a?(Hash)
32
+ self.release_version = release
25
33
  end
26
34
  end
27
35
 
@@ -51,7 +59,7 @@ module Katello
51
59
  end
52
60
 
53
61
  def self.update_facts(host, rhsm_facts)
54
- return if host.build?
62
+ return if host.build? || rhsm_facts.nil?
55
63
  rhsm_facts[:_type] = RhsmFactName::FACT_TYPE
56
64
  rhsm_facts[:_timestamp] = DateTime.now.to_s
57
65
  host.import_facts(rhsm_facts)
@@ -18,7 +18,7 @@ class MigrateContentHosts < ActiveRecord::Migration
18
18
  class SmartProxy < ActiveRecord::Base
19
19
  self.table_name = "smart_proxies"
20
20
 
21
- belongs_to :content_host, :class_name => "MigrateContentHosts::ContentHost", :inverse_of => :capsule
21
+ belongs_to :content_host, :class_name => "MigrateContentHosts::System", :inverse_of => :capsule
22
22
  end
23
23
 
24
24
  class KTEnvironment < ActiveRecord::Base
@@ -74,6 +74,7 @@ class MigrateContentHosts < ActiveRecord::Migration
74
74
  self.table_name = "katello_errata"
75
75
 
76
76
  has_many :systems_applicable, :through => :system_errata, :class_name => "MigrateContentHosts::System", :source => :system
77
+ has_many :content_facet_errata, :class_name => "MigrateContentHosts::ContentFacetErratum", :source => :erratum
77
78
  end
78
79
 
79
80
  class SystemErratum < ActiveRecord::Base
@@ -143,7 +144,7 @@ class MigrateContentHosts < ActiveRecord::Migration
143
144
  belongs_to :content_view, :inverse_of => :content_facets, :class_name => "MigrateContentHosts::ContentView"
144
145
  belongs_to :lifecycle_environment, :inverse_of => :content_facets, :class_name => "MigrateContentHosts::KTEnvironment"
145
146
 
146
- has_many :content_facet_repositories, :class_name => "MigrateContentHosts::ContentFacetRepository", :dependent => :destroy, :inverse_of => :content_facets
147
+ has_many :content_facet_repositories, :class_name => "MigrateContentHosts::ContentFacetRepository", :dependent => :destroy, :inverse_of => :content_facet
147
148
  has_many :bound_repositories, :through => :content_facet_repositories, :class_name => "MigrateContentHosts::Repository", :source => :repository
148
149
  has_many :applicable_errata, :through => :content_facet_errata, :class_name => "MigrateContentHosts::Erratum", :source => :erratum
149
150
  has_many :content_facet_errata, :class_name => "MigrateContentHosts::ContentFacetErratum", :dependent => :destroy, :inverse_of => :content_facet
@@ -182,13 +183,15 @@ class MigrateContentHosts < ActiveRecord::Migration
182
183
  Rails.logger
183
184
  end
184
185
 
185
- def create_content_facet(host, system)
186
+ def create_content_facet(host, system, include_env_and_view_only = false)
186
187
  logger.info("Creating content facet for host #{host.name}.")
187
188
  content_facet = host.content_facet = MigrateContentHosts::ContentFacet.new(:content_view => system.content_view,
188
189
  :lifecycle_environment => system.environment)
189
- content_facet.uuid = system.uuid
190
- content_facet.bound_repositories = system.bound_repositories
191
- content_facet.applicable_errata = system.applicable_errata
190
+ unless include_env_and_view_only
191
+ content_facet.uuid = system.uuid
192
+ content_facet.bound_repositories = system.bound_repositories
193
+ content_facet.applicable_errata = system.applicable_errata
194
+ end
192
195
  content_facet.save!
193
196
  end
194
197
 
@@ -307,6 +310,8 @@ class MigrateContentHosts < ActiveRecord::Migration
307
310
  fail _("Some backend services are not running: %s") % ping.inspect
308
311
  end
309
312
 
313
+ ::Katello::System.where(:uuid => nil).destroy_all
314
+
310
315
  ensure_one_system_per_hostname(MigrateContentHosts::System.all)
311
316
 
312
317
  systems = get_systems_with_facts(MigrateContentHosts::System.all)
@@ -342,7 +347,7 @@ class MigrateContentHosts < ActiveRecord::Migration
342
347
  end
343
348
  host = hosts.first
344
349
 
345
- create_content_facet(host, system) unless host.content_facet
350
+ create_content_facet(host, system, true) unless host.content_facet
346
351
  unregister_system(system)
347
352
 
348
353
  else #host exists in the correct org
@@ -353,8 +358,10 @@ class MigrateContentHosts < ActiveRecord::Migration
353
358
  create_subscription_facet(host, system) unless host.subscription_facet
354
359
  end
355
360
 
356
- system.host_id = host.id
357
- system.save!
361
+ unless system.destroyed? # if the system was unregistered, it will no longer exist
362
+ system.host_id = host.id
363
+ system.save!
364
+ end
358
365
  end
359
366
  end
360
367
  end
@@ -11,8 +11,7 @@ class MoveSystemDescriptionToHost < ActiveRecord::Migration
11
11
  add_column :hosts, :description, :text
12
12
 
13
13
  System.find_each do |system|
14
- system.foreman_host.description = system.description
15
- system.foreman_host.save!
14
+ system.foreman_host.update_attribute(:description, system.description)
16
15
  end
17
16
 
18
17
  remove_column :katello_systems, :description
@@ -22,8 +21,7 @@ class MoveSystemDescriptionToHost < ActiveRecord::Migration
22
21
  add_column :katello_systems, :description, :text
23
22
 
24
23
  System.find_each do |system|
25
- system.description = system.foreman_host.description
26
- system.save!
24
+ system.update_attribute(:description, system.foreman_host.description)
27
25
  end
28
26
 
29
27
  remove_column :hosts, :description
@@ -0,0 +1,10 @@
1
+ class AddRepoIdIndexes < ActiveRecord::Migration
2
+ def change
3
+ add_index :katello_repository_docker_manifests, :repository_id
4
+ add_index :katello_repository_errata, :repository_id
5
+ add_index :katello_repository_ostree_branches, :repository_id
6
+ add_index :katello_repository_package_groups, :repository_id
7
+ add_index :katello_repository_puppet_modules, :repository_id
8
+ add_index :katello_repository_rpms, :repository_id
9
+ end
10
+ end
@@ -256,6 +256,7 @@ module Katello
256
256
  load "#{Katello::Engine.root}/lib/katello/tasks/upgrades/2.4/import_subscriptions.rake"
257
257
  load "#{Katello::Engine.root}/lib/katello/tasks/upgrades/3.0/add_export_distributor.rake"
258
258
  load "#{Katello::Engine.root}/lib/katello/tasks/upgrades/3.0/delete_docker_v1_content.rake"
259
+ load "#{Katello::Engine.root}/lib/katello/tasks/upgrades/3.0/update_puppet_repository_distributors.rake"
259
260
  load "#{Katello::Engine.root}/lib/katello/tasks/upgrades/3.0/update_subscription_facet_backend_data.rake"
260
261
  end
261
262
  end
@@ -0,0 +1,20 @@
1
+ namespace :katello do
2
+ namespace :upgrades do
3
+ namespace '3.0' do
4
+ task :update_puppet_repository_distributors => ["environment"] do
5
+ User.current = User.anonymous_api_admin
6
+ puts _("Updating Puppet Repository Distributors")
7
+ Katello::Repository.puppet_type.each do |repo|
8
+ ForemanTasks.sync_task(::Actions::Pulp::Repository::Refresh, repo)
9
+ ForemanTasks.sync_task(::Actions::Katello::Repository::MetadataGenerate, repo)
10
+ end
11
+
12
+ puts _("Updating Content View Puppet Environment Distributors")
13
+ Katello::ContentViewPuppetEnvironment.all.each do |repo|
14
+ ForemanTasks.sync_task(::Actions::Pulp::Repository::Refresh, repo)
15
+ ForemanTasks.sync_task(::Actions::Katello::Repository::MetadataGenerate, repo)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -7,12 +7,23 @@ namespace :katello do
7
7
 
8
8
  Katello::Host::SubscriptionFacet.find_each do |subscription_facet|
9
9
  begin
10
- subscription_facet.update_from_consumer_attributes(subscription_facet.candlepin_consumer.consumer_attributes)
10
+ candlepin_attrs = subscription_facet.candlepin_consumer.consumer_attributes
11
+ subscription_facet.import_database_attributes(candlepin_attrs)
12
+
13
+ subscription_facet.host = ::Host::Managed.find(subscription_facet.host_id)
14
+ subscription_facet.save!
15
+
16
+ Katello::Host::SubscriptionFacet.update_facts(subscription_facet.host, candlepin_attrs[:facts])
11
17
  rescue RestClient::Exception => exception
12
18
  Rails.logger.error exception
13
19
  end
14
- subscription_facet.host = ::Host::Managed.find(subscription_facet.host_id)
15
- subscription_facet.save!
20
+ end
21
+
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)
26
+ end
16
27
  end
17
28
  end
18
29
  end
@@ -1,3 +1,3 @@
1
1
  module Katello
2
- VERSION = "3.0.0.rc7"
2
+ VERSION = "3.0.0"
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.0.0.rc7
4
+ version: 3.0.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-05-29 00:00:00.000000000 Z
11
+ date: 2016-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -1336,6 +1336,7 @@ files:
1336
1336
  - db/migrate/20160404132250_remove_katello_from_notification_name.rb
1337
1337
  - db/migrate/20160413230128_add_kickstart_repository_to_hosts_and_hostgroups.rb
1338
1338
  - db/migrate/20160426145517_move_host_description_to_host_comment.rb
1339
+ - db/migrate/20160530184400_add_repo_id_indexes.rb
1339
1340
  - db/seeds.d/101-locations.rb
1340
1341
  - db/seeds.d/102-organizations.rb
1341
1342
  - db/seeds.d/103-provisioning_templates.rb
@@ -1849,6 +1850,7 @@ files:
1849
1850
  - lib/katello/tasks/upgrades/2.4/import_subscriptions.rake
1850
1851
  - lib/katello/tasks/upgrades/3.0/add_export_distributor.rake
1851
1852
  - lib/katello/tasks/upgrades/3.0/delete_docker_v1_content.rake
1853
+ - lib/katello/tasks/upgrades/3.0/update_puppet_repository_distributors.rake
1852
1854
  - lib/katello/tasks/upgrades/3.0/update_subscription_facet_backend_data.rake
1853
1855
  - lib/katello/tasks/yard.rake
1854
1856
  - lib/katello/url_constrained_cookie_store.rb
@@ -1959,9 +1961,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
1959
1961
  version: '0'
1960
1962
  required_rubygems_version: !ruby/object:Gem::Requirement
1961
1963
  requirements:
1962
- - - ">"
1964
+ - - ">="
1963
1965
  - !ruby/object:Gem::Version
1964
- version: 1.3.1
1966
+ version: '0'
1965
1967
  requirements: []
1966
1968
  rubyforge_project:
1967
1969
  rubygems_version: 2.4.6