katello 4.0.0.rc2 → 4.0.0.rc3

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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/katello/api/v2/content_exports_controller.rb +1 -1
  3. data/app/controllers/katello/api/v2/content_view_puppet_modules_controller.rb +3 -3
  4. data/app/controllers/katello/api/v2/content_view_versions_controller.rb +1 -1
  5. data/app/controllers/katello/api/v2/errata_controller.rb +1 -1
  6. data/app/controllers/katello/api/v2/host_errata_controller.rb +1 -1
  7. data/app/controllers/katello/api/v2/organizations_controller.rb +0 -1
  8. data/app/controllers/katello/concerns/api/v2/authorization.rb +14 -1
  9. data/app/controllers/katello/concerns/smart_proxies_controller_extensions.rb +1 -2
  10. data/app/helpers/katello/concerns/smart_proxy_helper_extensions.rb +15 -20
  11. data/app/lib/actions/pulp3/content_migration_reset.rb +22 -0
  12. data/app/lib/katello/concerns/base_template_scope_extensions.rb +3 -2
  13. data/app/models/katello/concerns/smart_proxy_extensions.rb +28 -0
  14. data/app/models/katello/content_view_version_export_history.rb +7 -6
  15. data/app/models/katello/host/content_facet.rb +9 -31
  16. data/app/models/katello/host/info_provider.rb +0 -2
  17. data/app/models/katello/ping.rb +37 -17
  18. data/app/services/katello/pulp3/erratum.rb +2 -1
  19. data/app/services/katello/pulp3/migration.rb +39 -2
  20. data/app/services/katello/pulp3/migration_plan.rb +2 -2
  21. data/app/services/katello/pulp3/repository.rb +1 -1
  22. data/app/services/katello/ui_notifications/pulp/proxy_disk_space.rb +2 -5
  23. data/app/views/smart_proxies/_disk_usage.html.erb +6 -4
  24. data/db/migrate/20210218214048_change_default_content_view_version_export_history.rb +5 -0
  25. data/lib/katello/plugin.rb +1 -1
  26. data/lib/katello/tasks/pulp3_migration.rake +5 -1
  27. data/lib/katello/tasks/pulp3_migration_reset.rake +26 -0
  28. data/lib/katello/version.rb +1 -1
  29. data/webpack/scenes/Subscriptions/Manifest/ManageManifestModal.js +7 -2
  30. data/webpack/scenes/Subscriptions/Manifest/index.js +1 -0
  31. metadata +15 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 336a4ba95971459cc367612026947e16d536f4002aa4edbbf1ef2f5c75fc8d79
4
- data.tar.gz: bf25590898a3e0485037acb025c7d654c3a98dce1dfb2830f85db8923eb78bdd
3
+ metadata.gz: 25c755b23475d0447099ee99388c1d900ae9815b1e4be88ab5d13afeb7d044d2
4
+ data.tar.gz: 4482488f5ff9186dfe7f7db25901b2afa00b979c2fbf926ccfc329983a122661
5
5
  SHA512:
6
- metadata.gz: 19244df2d07a33451ae52bf787b7cd5d173db7647a90b88535077e27266a14814315d7b31f124c66cad14a41eb27bdbb8e78a2fe06b900b3f931f833b89b89c6
7
- data.tar.gz: 753d1c2598e96cdf3ce57c79abe0f997733ea296c29f5ccedafd0502530046a727be430ae87b3d4b3030415f66c9d7801f8222dca6e388c576ca6ad46766cd9b
6
+ metadata.gz: 464106f37ffb3915d1029ea95f9ecdc8d6c985fde7d0a40826dc111aefb1e621c17a79d478ef6538be9f485c35fec13cc1af6ad47a3b30485183a381af71828a
7
+ data.tar.gz: 1da0019879786addea556e156ae5b187df06170a0718eff50580d4e9bb8579b9c897fd7729c893bf414068d89813a5f9614d799e7b0584852c6c890ffac8660e
@@ -29,7 +29,7 @@ module Katello
29
29
 
30
30
  api :GET, "/content_exports/api_status", N_("true if the export api is pulp3 ready and usable. This API is intended for use by hammer-cli only.")
31
31
  def api_status
32
- ::Foreman::Deprecation.api_deprecation_warning("/content_exports/api_status is being deprecated and will be removed in a future version of Katello.")
32
+ ::Foreman::Deprecation.api_deprecation_warning("/content_exports/api_status is being deprecated and will be removed in Katello 4.1.")
33
33
  render json: { api_usable: SmartProxy.pulp_primary.pulp3_repository_type_support?(Katello::Repository::YUM_TYPE) }, status: :ok
34
34
  end
35
35
 
@@ -9,7 +9,7 @@ module Katello
9
9
  param :content_view_id, :number, :desc => N_("content view identifier"), :required => true
10
10
  param :name, String, :desc => N_("name of the puppet module")
11
11
  param :author, String, :desc => N_("author of the puppet module")
12
- param :uuid, String, :desc => N_("uuid of the puppet module"), :deprecated => true
12
+ param :uuid, String, :desc => N_("uuid of the puppet module")
13
13
  param_group :search, ::Katello::Api::V2::ApiController
14
14
  add_scoped_search_description_for(ContentViewPuppetModule)
15
15
  def index
@@ -22,7 +22,7 @@ module Katello
22
22
  param :name, String, :desc => N_("name of the puppet module")
23
23
  param :author, String, :desc => N_("author of the puppet module")
24
24
  param :id, String, :desc => N_("the id of the puppet module to associate")
25
- param :uuid, String, :desc => N_("the uuid of the puppet module to associate"), :deprecated => true
25
+ param :uuid, String, :desc => N_("the uuid of the puppet module to associate")
26
26
  def create
27
27
  params[:content_view_puppet_module][:uuid] ||= PuppetModule.find(params[:id]).try(:pulp_id) if params[:id]
28
28
  respond resource: ContentViewPuppetModule.create!(puppet_module_params.merge(content_view: @view))
@@ -41,7 +41,7 @@ module Katello
41
41
  param :id, :number, :desc => N_("puppet module ID"), :required => true
42
42
  param :name, String, :desc => N_("name of the puppet module")
43
43
  param :author, String, :desc => N_("author of the puppet module")
44
- param :uuid, String, :desc => N_("the uuid of the puppet module to associate"), :deprecated => true
44
+ param :uuid, String, :desc => N_("the uuid of the puppet module to associate")
45
45
  def update
46
46
  @puppet_module.update!(puppet_module_params)
47
47
  respond :resource => @puppet_module
@@ -95,7 +95,7 @@ module Katello
95
95
  fail HttpErrors::BadRequest, _("Invalid usage for Pulp 3 repositories. "\
96
96
  "Use hammer content-export for Yum repositories")
97
97
  end
98
- ::Foreman::Deprecation.api_deprecation_warning("Export is being deprecated and will be removed in a future version of Katello. Use hammer content-view version export instead.")
98
+ ::Foreman::Deprecation.api_deprecation_warning("Pulp 2 export is deprecated and will not work as of Katello 4.0. To export using Pulp 3, use hammer content-export version.")
99
99
  if params[:export_to_iso].blank? && params[:iso_mb_size].present?
100
100
  fail HttpErrors::BadRequest, _("ISO export must be enabled when specifying ISO size")
101
101
  end
@@ -62,7 +62,7 @@ module Katello
62
62
  collection
63
63
  end
64
64
 
65
- api :GET, "/content_view_versions/:id/available_errata", N_("Return errata that can be added to the Content View Version via an Incremental Update"), :deprecated => true
65
+ api :GET, "/content_view_versions/:id/available_errata", N_("Return errata that can be added to the Content View Version via an Incremental Update. Will be removed in Katello 4.1."), :deprecated => true
66
66
  param :id, :number, :desc => N_("Content View Version identifier"), :required => true
67
67
  param :organization_id, :number, :desc => N_("Organization identifier")
68
68
  param :content_view_filter_id, :number, :desc => N_("Content View Filter identifier")
@@ -51,7 +51,7 @@ module Katello
51
51
 
52
52
  api :PUT, "/hosts/:host_id/errata/apply", N_("Schedule errata for installation")
53
53
  param :host_id, :number, :desc => N_("Host ID"), :required => true
54
- param :errata_ids, Array, :desc => N_("List of Errata ids to install"), :required => false, :deprecated => true
54
+ param :errata_ids, Array, :desc => N_("List of Errata ids to install. Will be removed in Katello 4.1."), :required => false, :deprecated => true
55
55
 
56
56
  param_group :bulk_errata_ids
57
57
  def apply
@@ -22,7 +22,6 @@ module Katello
22
22
  param :smart_proxy_ids, Array, N_("Smart proxy IDs"), :required => false
23
23
  param :compute_resource_ids, Array, N_("Compute resource IDs"), :required => false
24
24
  param :medium_ids, Array, N_("Medium IDs"), :required => false
25
- param :config_template_ids, Array, N_("Provisioning template IDs"), :required => false # FIXME: deprecated
26
25
  param :ptable_ids, Array, N_("Partition template IDs"), :required => false
27
26
  param :provisioning_template_ids, Array, N_("Provisioning template IDs"), :required => false
28
27
  param :domain_ids, Array, N_("Domain IDs"), :required => false
@@ -39,7 +39,20 @@ module Katello
39
39
  end
40
40
 
41
41
  def throw_resource_not_found(name: resource_name, id: params[:id])
42
- fail HttpErrors::NotFound, _("Could not find %{name} resource with id %{id}") % {id: id, name: name}
42
+ perms_message = "Potential missing permissions: " +
43
+ missing_permissions.map(&:name).join(', ')
44
+ fail HttpErrors::NotFound, _("Could not find %{name} resource with id %{id}. %{perms_message}") % {id: id, name: name, perms_message: perms_message}
45
+ end
46
+
47
+ def missing_permissions
48
+ missing_perms = ::Foreman::AccessControl.permissions_for_controller_action(path_to_authenticate)
49
+
50
+ # promote_or_remove_content_views_to_environments has a special relationship to promote_or_remove_content_views
51
+ if path_to_authenticate["controller"] == "katello/api/v2/content_view_versions" &&
52
+ path_to_authenticate["action"].in?(["promote", "remove_from_environment", "remove", "republish_repositories"])
53
+ missing_perms << ::Permission.find_by(name: "promote_or_remove_content_views_to_environments")
54
+ end
55
+ missing_perms
43
56
  end
44
57
 
45
58
  def throw_resources_not_found(name:, expected_ids: [])
@@ -26,8 +26,7 @@ module Katello
26
26
  before_action :find_resource_and_status, :only => [:pulp_storage, :pulp_status]
27
27
 
28
28
  def pulp_storage
29
- pulp_connection = @proxy_status[:pulp] || @proxy_status[:pulpnode]
30
- @storage = pulp_connection.storage
29
+ @storage = @smart_proxy.pulp_disk_usage
31
30
  respond_to do |format|
32
31
  format.html { render :layout => false }
33
32
  format.json { render :json => {:success => true, :message => @storage} }
@@ -2,20 +2,21 @@ module Katello
2
2
  module Concerns
3
3
  module SmartProxyHelperExtensions
4
4
  def disks(storage)
5
- mount_points = {}
6
- disks = []
7
- storage.each_value do |values|
8
- mount = values['mounted']
9
- mount_points[mount].nil? ? mount_points[mount] = [values['path']] : mount_points[mount] << values['path']
10
- values['header'] = "#{mount_points[mount].to_sentence} (on #{values['filesystem']})"
11
- values['available_percent'] = available_percent(values['percent'])
12
- values['size_status'] = storage_warning(values['available'])
13
- values['total'] = kb_to_actual(values.delete('1k-blocks'))
14
- values['used'] = kb_to_actual(values['used'])
15
- values['available'] = kb_to_actual(values['available'])
16
- disks << values
5
+ storage.map do |values|
6
+ values['header'] = values['description']
7
+ values['available_percent'] = 100 - values['percentage']
8
+ values['size_status'] = storage_warning(values['free'])
9
+ values
10
+ end
11
+ end
12
+
13
+ def humanize_bytes(bytes)
14
+ mb = bytes / 1024 / 1024
15
+ if mb < 1000
16
+ "#{mb} MB"
17
+ else
18
+ "#{mb / 1024} GB"
17
19
  end
18
- disks.group_by { |h| h['mounted'] }.map { |_, hs| hs.reduce(:merge) }
19
20
  end
20
21
 
21
22
  def boolean_to_icon(boolean)
@@ -24,12 +25,6 @@ module Katello
24
25
  icon_text(icon, '', :kind => 'pficon')
25
26
  end
26
27
 
27
- def available_percent(percent_string)
28
- used_percent = percent_string.delete('%').to_i
29
- available_percent = 100 - used_percent
30
- "#{available_percent}%"
31
- end
32
-
33
28
  def download_policies
34
29
  policies = [
35
30
  {
@@ -54,7 +49,7 @@ module Katello
54
49
  end
55
50
 
56
51
  def storage_warning(available)
57
- gb_size = available.to_i / 1_048_576
52
+ gb_size = available.to_i / 1_073_741_824
58
53
  case gb_size
59
54
  when 0..1
60
55
  "danger"
@@ -0,0 +1,22 @@
1
+ module Actions
2
+ module Pulp3
3
+ class ContentMigrationReset < Pulp3::AbstractAsyncTask
4
+ def plan(smart_proxy)
5
+ plan_self(smart_proxy_id: smart_proxy.id)
6
+ end
7
+
8
+ def invoke_external_task
9
+ migration_service = ::Katello::Pulp3::Migration.new(smart_proxy)
10
+ migration_service.reset
11
+ end
12
+
13
+ def humanized_name
14
+ _("Content Migration Reset")
15
+ end
16
+
17
+ def rescue_strategy
18
+ Dynflow::Action::Rescue::Skip
19
+ end
20
+ end
21
+ end
22
+ end
@@ -129,13 +129,14 @@ module Katello
129
129
  seen_errata_ids = (seen_errata_ids + parse_errata(task)).uniq
130
130
  seen_host_ids << task.input['host']['id'].to_i if include_last_reboot == 'yes'
131
131
  end
132
+ seen_host_ids &= only_host_ids if only_host_ids
132
133
 
133
134
  # preload errata in one query for this batch
134
135
  preloaded_errata = Katello::Erratum.where(:errata_id => seen_errata_ids).pluck(:errata_id, :errata_type)
135
- preloaded_hosts = ::Host.where(:id => seen_host_ids & only_host_ids).includes(:reported_data)
136
+ preloaded_hosts = ::Host.where(:id => seen_host_ids).includes(:reported_data)
136
137
 
137
138
  batch.each do |task|
138
- next unless only_host_ids.include?(task.input['host']['id'].to_i)
139
+ next if !only_host_ids.nil? && only_host_ids.include?(task.input['host']['id'].to_i)
139
140
  parse_errata(task).each do |erratum_id|
140
141
  current_erratum_errata_type = preloaded_errata.find { |k, _| k == erratum_id }.last
141
142
 
@@ -153,6 +153,34 @@ module Katello
153
153
  end
154
154
  end
155
155
 
156
+ def pulp_disk_usage
157
+ if has_feature?(PULP_FEATURE) || has_feature?(PULP_NODE_FEATURE)
158
+ status = self.statuses[:pulp] || self.statuses[:pulpnode]
159
+ status&.storage&.map do |label, results|
160
+ {
161
+ description: results['path'],
162
+ total: results['1k-blocks'] * 1024,
163
+ used: results['used'] * 1024,
164
+ free: results['available'] * 1024,
165
+ percentage: (results['used'] / results['1k-blocks'].to_f * 100).to_i,
166
+ label: label
167
+ }.with_indifferent_access
168
+ end
169
+ elsif pulp3_enabled?
170
+ storage = ping_pulp3['storage']
171
+ [
172
+ {
173
+ description: 'Pulp Storage (/var/lib/pulp by default)',
174
+ total: storage['total'],
175
+ used: storage['used'],
176
+ free: storage['free'],
177
+ percentage: (storage['used'] / storage['total'].to_f * 100).to_i,
178
+ label: 'pulp_dir'
179
+ }.with_indifferent_access
180
+ ]
181
+ end
182
+ end
183
+
156
184
  def backend_service_type(repository)
157
185
  if pulp3_support?(repository)
158
186
  Actions::Pulp3::Abstract::BACKEND_SERVICE_TYPE
@@ -8,13 +8,14 @@ module Katello
8
8
 
9
9
  belongs_to :content_view_version, :class_name => "Katello::ContentViewVersion", :inverse_of => :export_histories
10
10
  validates_lengths_from_database
11
+
11
12
  validates :content_view_version_id, :presence => true
12
13
  validates :destination_server, :uniqueness => { :scope => [:content_view_version_id, :destination_server, :path] }
13
- validates :export_type, :inclusion => { :in => EXPORT_TYPES,
14
- :allow_blank => false,
15
- :message => _("Invalid export_type from one of the following: %s" % EXPORT_TYPES.join(', '))
16
- }
17
-
14
+ validates :export_type, :presence => true,
15
+ :inclusion => { :in => EXPORT_TYPES,
16
+ :allow_blank => false,
17
+ :message => _("must be one of the following: %s" % EXPORT_TYPES.join(', '))
18
+ }
18
19
  validates :metadata, :presence => true
19
20
  serialize :metadata, Hash
20
21
 
@@ -39,7 +40,7 @@ module Katello
39
40
  end
40
41
 
41
42
  def export_type_from_metadata
42
- cvve.metadata[:incremental] ? INCREMENTAL : COMPLETE
43
+ metadata[:incremental] ? INCREMENTAL : COMPLETE
43
44
  end
44
45
 
45
46
  def set_export_type
@@ -31,43 +31,21 @@ module Katello
31
31
  validates :host, :presence => true, :allow_blank => false
32
32
  validates_with Validators::ContentViewEnvironmentValidator
33
33
 
34
- def bindable_types
35
- [
36
- {
37
- type: Repository::DEB_TYPE,
38
- matcher: '/pulp/deb/',
39
- paths: []
40
- },
41
- {
42
- type: Repository::YUM_TYPE,
43
- matcher: '/pulp/repos/',
44
- paths: []
45
- }
46
- ]
47
- end
48
-
49
34
  def update_repositories_by_paths(paths)
50
- bindable_paths = bindable_types
35
+ prefixes = %w(/pulp/deb/ /pulp/repos/ /pulp/content/)
51
36
  relative_paths = []
52
37
 
53
- # paths == ["/pulp/repos/Default_Organization/Library/custom/Test_product/test2",
54
- # "/pulp/repos/Default_Organization/Library/custom/Test_product/My_repo"]
55
- paths.each do |absolute_path|
56
- bindable_paths.each do |supported|
57
- relative_path = absolute_path.gsub(supported[:matcher], '') # remove e.g. '/pulp/repos/' from beginning of string
58
- relative_paths << relative_path unless relative_path == absolute_path
59
- if absolute_path.starts_with?(supported[:matcher])
60
- supported[:paths] << relative_path
61
- break
62
- end
38
+ # paths == ["/pulp/repos/Default_Organization/Library/custom/Test_product/test2"]
39
+ paths.each do |path|
40
+ if (prefix = prefixes.find { |pre| path.start_with?(pre) })
41
+ relative_paths << path.gsub(prefix, '')
42
+ else
43
+ Rails.logger.warn("System #{self.host.name} (#{self.host.id}) requested binding to repo with unknown prefix. #{path}")
63
44
  end
64
45
  end
65
46
 
66
- repos = bindable_paths.flat_map do |supported|
67
- repos = Repository.joins(:root).where(RootRepository.table_name => {content_type: supported[:type]}, relative_path: supported[:paths])
68
- relative_paths -= repos.pluck(:relative_path) # remove relative paths that match our repos
69
- repos
70
- end
47
+ repos = Repository.where(relative_path: relative_paths)
48
+ relative_paths -= repos.pluck(:relative_path) # remove relative paths that match our repos
71
49
 
72
50
  # Any leftover relative paths do not match the repos we've just retrieved from the db,
73
51
  # so we should log warnings about them.
@@ -6,8 +6,6 @@ module Katello
6
6
  def host_info
7
7
  info = {}
8
8
  info['parameters'] = {
9
- 'kt_env' => host.lifecycle_environment.try(:label), #deprecated
10
- 'kt_cv' => host.content_view.try(:label), #deprecated
11
9
  'foreman_host_collections' => host.host_collections.map(&:name),
12
10
  'lifecycle_environment' => host.lifecycle_environment.try(:label),
13
11
 
@@ -9,7 +9,7 @@ module Katello
9
9
  SETTINGS[:katello][:use_pulp_2_for_content_type].nil? || (!SETTINGS[:katello][:use_pulp_2_for_content_type][:yum] &&
10
10
  !SETTINGS[:katello][:use_pulp_2_for_content_type][:docker] &&
11
11
  !SETTINGS[:katello][:use_pulp_2_for_content_type][:file]) ||
12
- system('systemctl is-enabled pulpcore-api.service')
12
+ system('systemctl is-enabled pulpcore-api.service &>/dev/null')
13
13
  end
14
14
 
15
15
  def services(capsule_id = nil)
@@ -23,26 +23,18 @@ module Katello
23
23
  services
24
24
  end
25
25
 
26
- # Calls "status" services in all backend engines.
27
26
  def ping(services: nil, capsule_id: nil)
28
- services ||= self.services(capsule_id)
29
- result = {}
30
- services.each { |service| result[service] = {} }
27
+ ping_services_for_capsule(services, capsule_id)
28
+ end
31
29
 
32
- ping_pulp3_without_auth(result[:pulp3], capsule_id) if result.include?(:pulp3)
33
- ping_pulp_without_auth(result[:pulp], capsule_id) if result.include?(:pulp)
34
- ping_candlepin_without_auth(result[:candlepin]) if result.include?(:candlepin)
30
+ def ping!(services: nil, capsule_id: nil)
31
+ result = ping_services_for_capsule(services, capsule_id)
35
32
 
36
- ping_pulp_with_auth(result[:pulp_auth], result[:pulp][:status]) if result.include?(:pulp_auth)
37
- ping_candlepin_with_auth(result[:candlepin_auth]) if result.include?(:candlepin_auth)
38
- ping_foreman_tasks(result[:foreman_tasks]) if result.include?(:foreman_tasks)
39
- ping_katello_events(result[:katello_events]) if result.include?(:katello_events)
40
- ping_candlepin_events(result[:candlepin_events]) if result.include?(:candlepin_events)
41
- ping_katello_agent(result[:katello_agent]) if result.include?(:katello_agent)
33
+ if result[:status] != OK_RETURN_CODE
34
+ failed_names = failed_services(result).keys
35
+ fail("The following services have not been started or are reporting errors: #{failed_names.join(', ')}")
36
+ end
42
37
 
43
- # set overall status result code
44
- result = {:services => result}
45
- result[:status] = result[:services].each_value.any? { |v| v[:status] == FAIL_RETURN_CODE } ? FAIL_RETURN_CODE : OK_RETURN_CODE
46
38
  result
47
39
  end
48
40
 
@@ -229,6 +221,34 @@ module Katello
229
221
 
230
222
  private
231
223
 
224
+ def failed_services(result)
225
+ result[:services].reject do |_name, details|
226
+ details[:status] != OK_RETURN_CODE
227
+ end
228
+ end
229
+
230
+ def ping_services_for_capsule(services, capsule_id)
231
+ services ||= self.services(capsule_id)
232
+ result = {}
233
+ services.each { |service| result[service] = {} }
234
+
235
+ ping_pulp3_without_auth(result[:pulp3], capsule_id) if result.include?(:pulp3)
236
+ ping_pulp_without_auth(result[:pulp], capsule_id) if result.include?(:pulp)
237
+ ping_candlepin_without_auth(result[:candlepin]) if result.include?(:candlepin)
238
+
239
+ ping_pulp_with_auth(result[:pulp_auth], result[:pulp][:status]) if result.include?(:pulp_auth)
240
+ ping_candlepin_with_auth(result[:candlepin_auth]) if result.include?(:candlepin_auth)
241
+ ping_foreman_tasks(result[:foreman_tasks]) if result.include?(:foreman_tasks)
242
+ ping_katello_events(result[:katello_events]) if result.include?(:katello_events)
243
+ ping_candlepin_events(result[:candlepin_events]) if result.include?(:candlepin_events)
244
+ ping_katello_agent(result[:katello_agent]) if result.include?(:katello_agent)
245
+
246
+ # set overall status result code
247
+ result = {:services => result}
248
+ result[:status] = result[:services].each_value.any? { |v| v[:status] == FAIL_RETURN_CODE } ? FAIL_RETURN_CODE : OK_RETURN_CODE
249
+ result
250
+ end
251
+
232
252
  def fetch_proxy(capsule_id)
233
253
  capsule_id ? SmartProxy.unscoped.find(capsule_id) : SmartProxy.pulp_primary
234
254
  end
@@ -35,7 +35,8 @@ module Katello
35
35
  custom_json["issued"] = convert_date_if_epoch(custom_json["issued"])
36
36
  custom_json["updated"] = convert_date_if_epoch(custom_json["updated"]) unless custom_json["updated"].blank?
37
37
 
38
- if model.updated.blank? || (custom_json['updated'].to_datetime != model.updated.to_datetime)
38
+ if model.updated.blank? ||
39
+ (custom_json['updated'] && (custom_json['updated'].to_datetime != model.updated.to_datetime))
39
40
  custom_json['errata_id'] = custom_json.delete('id')
40
41
  custom_json['errata_type'] = custom_json.delete('type')
41
42
  custom_json['updated'] = custom_json['updated'].blank? ? custom_json['issued'] : custom_json['updated']
@@ -114,6 +114,44 @@ module Katello
114
114
  Katello::Pulp3::MigrationPlan.new(@repository_types).generate.as_json
115
115
  end
116
116
 
117
+ def reset
118
+ if @repository_types.empty?
119
+ fail ::Katello::Errors::Pulp3MigrationError, 'There are no Pulp 3 content types to reset'
120
+ end
121
+
122
+ plugins = @repository_types.sort.map do |repository_type|
123
+ {
124
+ type: ::Katello::Pulp3::MigrationPlan.pulp2_repository_type(repository_type)
125
+ }
126
+ end
127
+ plan = { plugins: plugins }
128
+
129
+ # TODO: Don't provide the plan as a string once this is resolved: https://pulp.plan.io/issues/8211
130
+ migration_plan_api.reset(migration_plan_api.create(plan: plan).pulp_href, plan.to_json)
131
+
132
+ content_types_for_migration.each do |content_type|
133
+ if content_type.model_class == ::Katello::Erratum
134
+ ::Katello::RepositoryErratum.update_all(erratum_pulp3_href: nil)
135
+ else
136
+ content_type.model_class.update_all(migrated_pulp3_href: nil)
137
+ end
138
+ end
139
+
140
+ @repository_types.each do |repo_type|
141
+ if repo_type == "file"
142
+ ::Katello::Repository.file_type.update(remote_href: nil, publication_href: nil, version_href: nil)
143
+ elsif repo_type == "docker"
144
+ ::Katello::Repository.docker_type.update(remote_href: nil, publication_href: nil, version_href: nil)
145
+ elsif repo_type == "yum"
146
+ ::Katello::Repository.yum_type.update(remote_href: nil, publication_href: nil, version_href: nil)
147
+ end
148
+ end
149
+
150
+ ::Katello::Pulp3::RepositoryReference.destroy_all
151
+ ::Katello::Pulp3::DistributionReference.destroy_all
152
+ ::Katello::Pulp3::ContentGuard.destroy_all
153
+ end
154
+
117
155
  def create_migrations
118
156
  plan = migration_plan
119
157
  Rails.logger.info("Migration Plan: #{plan}")
@@ -280,8 +318,7 @@ module Katello
280
318
  update_import_status("Importing migrated content type #{content_type.label}: #{current_count}/#{total_count}")
281
319
  migrated_units = pulp2_content_api.list(pulp2_id__in: needing_hrefs.map { |unit| unit.pulp_id }.join(','))
282
320
  migrated_units.results.each do |migrated_unit|
283
- matching_record = needing_hrefs.find { |db_unit| db_unit.pulp_id == migrated_unit.pulp2_id }
284
- matching_record&.update_column(:migrated_pulp3_href, migrated_unit.pulp3_content)
321
+ content_type.model_class.where(pulp_id: migrated_unit.pulp2_id).update_all(migrated_pulp3_href: migrated_unit.pulp3_content)
285
322
  end
286
323
  end
287
324
  end
@@ -21,13 +21,13 @@ module Katello
21
21
  def generate_plugins
22
22
  @repository_types.sort.map do |repository_type|
23
23
  {
24
- type: pulp2_repository_type(repository_type),
24
+ type: self.class.pulp2_repository_type(repository_type),
25
25
  repositories: repository_migrations(repository_type)
26
26
  }
27
27
  end
28
28
  end
29
29
 
30
- def pulp2_repository_type(repository_type)
30
+ def self.pulp2_repository_type(repository_type)
31
31
  if repository_type == 'yum'
32
32
  return 'rpm' #migration plugin uses rpm
33
33
  else
@@ -309,7 +309,7 @@ module Katello
309
309
  }
310
310
  remote_options[:url] = root.url unless root.url.blank?
311
311
  remote_options[:download_concurrency] = root.download_concurrency unless root.download_concurrency.blank?
312
- if root.upstream_username && root.upstream_password
312
+ if !root.upstream_username.blank? && !root.upstream_password.blank?
313
313
  remote_options.merge!(username: root.upstream_username,
314
314
  password: root.upstream_password)
315
315
  end
@@ -5,12 +5,9 @@ module Katello
5
5
  class << self
6
6
  def deliver!
7
7
  SmartProxy.unscoped.with_content.each do |proxy|
8
- status = proxy.statuses[:pulp] || proxy.statuses[:pulpnode]
9
- next unless (percentage = status&.storage&.dig('pulp_dir', 'percent'))
10
-
11
- if percentage[0..2].to_i < 90 && notification_already_exists?(proxy)
8
+ if percentage < 90 && notification_already_exists?(proxy)
12
9
  blueprint.notifications.where(subject: proxy).destroy_all
13
- elsif update_notifications(proxy).empty? && percentage[0..2].to_i > 90
10
+ elsif update_notifications(proxy).empty? && percentage > 90
14
11
  ::Notification.create!(
15
12
  :subject => proxy,
16
13
  :initiator => User.anonymous_admin,
@@ -3,12 +3,14 @@
3
3
  <div class="progress-description" title="<%= disk['header'] %>">
4
4
  <%= disk['header'] %>
5
5
  </div>
6
+
6
7
  <div class="progress progress-label-top-right">
7
- <div class="progress-bar progress-bar-<%= disk['size_status'] %>" role="progressbar" aria-valuenow="<%= disk['percent'].delete('%') %>" aria-valuemin="0" aria-valuemax="100" style="width: <%= disk['percent'] %>;" data-toggle="tooltip" title="<%= _('%s Used') % disk['used'] %>">
8
- <span><strong><%= _('%{used} of %{total}') % {:used => disk['used'],:total => disk['total']} %></strong> Used</span>
8
+ <div class="progress-bar progress-bar-<%= disk['size_status'] %>" role="progressbar" aria-valuenow="<%= disk['percentage'] %>" aria-valuemin="0" aria-valuemax="100" style="width: <%= disk['percentage'] %>%;" data-toggle="tooltip" title="<%= _('%s Used') % humanize_bytes(disk['used']) %>">
9
+ <span><strong><%= _('%{used} of %{total}') % {:used => humanize_bytes(disk['used']),:total => humanize_bytes(disk['total'])} %></strong> Used</span>
9
10
  </div>
10
- <div class="progress-bar progress-bar-remaining" role="progressbar" aria-valuenow="<%= disk['available_percent'].delete('%') %>" aria-valuemin="0" aria-valuemax="100" style="width: <%= disk['available_percent'] %>;" data-toggle="tooltip" title="<%= _('%s Available') % disk['available'] %>">
11
- <span class="sr-only"><%= _('%s Available') % disk['available'] %></span>
11
+
12
+ <div class="progress-bar progress-bar-remaining" role="progressbar" aria-valuenow="<%= disk['available_percent'] %>" aria-valuemin="0" aria-valuemax="100" style="width: <%= disk['available_percent'] %>%;" data-toggle="tooltip" title="<%= _('%s Available') % humanize_bytes(disk['free']) %>">
13
+ <span class="sr-only"><%= _('%s Available') % humanize_bytes(disk['free']) %></span>
12
14
  </div>
13
15
  </div>
14
16
  </div>
@@ -0,0 +1,5 @@
1
+ class ChangeDefaultContentViewVersionExportHistory < ActiveRecord::Migration[6.0]
2
+ def change
3
+ change_column_default(:katello_content_view_version_export_histories, :export_type, nil)
4
+ end
5
+ end
@@ -293,7 +293,7 @@ Foreman::Plugin.register :katello do
293
293
  cx.add_pagelet :details_content,
294
294
  :name => _('Storage'),
295
295
  :partial => 'smart_proxies/show/storage',
296
- :onlyif => proc { |proxy| proxy.has_feature?(SmartProxy::PULP_FEATURE) || proxy.has_feature?(SmartProxy::PULP_NODE_FEATURE) }
296
+ :onlyif => proc { |proxy| proxy.has_feature?(SmartProxy::PULP_FEATURE) || proxy.has_feature?(SmartProxy::PULP_NODE_FEATURE) || proxy.has_feature?(SmartProxy::PULP3_FEATURE) }
297
297
  end
298
298
 
299
299
  register_facet Katello::Host::ContentFacet, :content_facet do
@@ -1,6 +1,9 @@
1
1
  namespace :katello do
2
2
  desc "Runs a Pulp 2 to 3 Content Migration for supported types. May be run multiple times. Use wait=false to immediately return with a task url."
3
- task :pulp3_migration => ["dynflow:client", "check_ping"] do
3
+ task :pulp3_migration => ["dynflow:client"] do
4
+ services = [:candlepin, :foreman_tasks, :pulp3, :pulp, :pulp_auth]
5
+ Katello::Ping.ping!(services: services)
6
+
4
7
  puts "Starting task."
5
8
  SmartProxy.pulp_primary.refresh
6
9
 
@@ -8,6 +11,7 @@ namespace :katello do
8
11
  wait = ::Foreman::Cast.to_bool(ENV['wait'] || 'true')
9
12
  preserve_output = ::Foreman::Cast.to_bool(ENV['preserve_output'])
10
13
 
14
+ User.current = User.anonymous_api_admin
11
15
  task = ForemanTasks.async_task(Actions::Pulp3::ContentMigration, SmartProxy.pulp_primary, reimport_all: reimport_all)
12
16
 
13
17
  if wait
@@ -0,0 +1,26 @@
1
+ namespace :katello do
2
+ desc "Reset the Pulp 2 -> Pulp 3 migration for content types that haven't been fully switched over"
3
+ task :pulp3_migration_reset => ["dynflow:client", "check_ping"] do
4
+ puts "Starting Content Migration Reset."
5
+ SmartProxy.pulp_primary.refresh
6
+
7
+ task = ForemanTasks.async_task(Actions::Pulp3::ContentMigrationReset, SmartProxy.pulp_primary)
8
+
9
+ if ENV['wait'].nil? || ::Foreman::Cast.to_bool(ENV['wait'])
10
+ until !task.pending? || task.paused?
11
+ sleep(20)
12
+ task = ForemanTasks::Task.find(task.id)
13
+ end
14
+
15
+ if task.result == 'warning' || task.result == 'pending'
16
+ msg = _("Content Migration Reset failed, You will want to investigate: https://#{Socket.gethostname}/foreman_tasks/tasks/#{task.id}\n")
17
+ $stderr.print(msg)
18
+ fail ForemanTasks::TaskError, task
19
+ else
20
+ puts _("Content Migration Reset completed successfully")
21
+ end
22
+ else
23
+ puts "Content Migration Reset started, you may monitor it at: https://#{Socket.gethostname}/foreman_tasks/tasks/#{task.id}"
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Katello
2
- VERSION = "4.0.0.rc2".freeze
2
+ VERSION = "4.0.0.rc3".freeze
3
3
  end
@@ -51,8 +51,11 @@ class ManageManifestModal extends Component {
51
51
  showDeleteManifestModal = () =>
52
52
  this.props.setModalOpen({ id: DELETE_MANIFEST_MODAL_ID });
53
53
 
54
- hideDeleteManifestModal = () =>
55
- this.props.setModalClosed({ id: DELETE_MANIFEST_MODAL_ID });
54
+ hideDeleteManifestModal = () => {
55
+ if (this.props.deleteManifestModalExists) {
56
+ this.props.setModalClosed({ id: DELETE_MANIFEST_MODAL_ID });
57
+ }
58
+ };
56
59
 
57
60
  updateRepositoryUrl = (event) => {
58
61
  this.setState({ redhat_repository_url: event.target.value });
@@ -326,6 +329,7 @@ ManageManifestModal.propTypes = {
326
329
  canImportManifest: PropTypes.bool,
327
330
  canDeleteManifest: PropTypes.bool,
328
331
  isManifestImported: PropTypes.bool,
332
+ deleteManifestModalExists: PropTypes.bool,
329
333
  canEditOrganizations: PropTypes.bool,
330
334
  disableManifestActions: PropTypes.bool,
331
335
  disabledReason: PropTypes.string,
@@ -351,6 +355,7 @@ ManageManifestModal.defaultProps = {
351
355
  canImportManifest: false,
352
356
  canDeleteManifest: false,
353
357
  isManifestImported: false,
358
+ deleteManifestModalExists: false,
354
359
  canEditOrganizations: false,
355
360
  simpleContentAccess: false,
356
361
  simpleContentAccessEligible: undefined,
@@ -20,6 +20,7 @@ const mapStateToProps = state => ({
20
20
  simpleContentAccess: selectSimpleContentAccessEnabled(state),
21
21
  isManifestImported: selectIsManifestImported(state),
22
22
  modalOpenState: state.foremanModals.ManageManifestModal,
23
+ deleteManifestModalExists: !!state.foremanModals.deleteManifestModal,
23
24
  manifestActionStarted: selectManifestActionStarted(state),
24
25
  simpleContentAccessEligible: selectSimpleContentAccessEligible(state),
25
26
  });
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: 4.0.0.rc2
4
+ version: 4.0.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - N/A
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-18 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 0.14.1
89
+ version: '4.0'
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.14.1
96
+ version: '4.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: foreman_remote_execution
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -374,46 +374,40 @@ dependencies:
374
374
  requirements:
375
375
  - - ">="
376
376
  - !ruby/object:Gem::Version
377
- version: 3.6.2
377
+ version: 3.9.0
378
378
  - - "<"
379
379
  - !ruby/object:Gem::Version
380
- version: 3.9.0
380
+ version: 3.10.0
381
381
  type: :runtime
382
382
  prerelease: false
383
383
  version_requirements: !ruby/object:Gem::Requirement
384
384
  requirements:
385
385
  - - ">="
386
386
  - !ruby/object:Gem::Version
387
- version: 3.6.2
387
+ version: 3.9.0
388
388
  - - "<"
389
389
  - !ruby/object:Gem::Version
390
- version: 3.9.0
390
+ version: 3.10.0
391
391
  - !ruby/object:Gem::Dependency
392
392
  name: pulp_2to3_migration_client
393
393
  requirement: !ruby/object:Gem::Requirement
394
394
  requirements:
395
395
  - - ">="
396
- - !ruby/object:Gem::Version
397
- version: 0.3.0
398
- - - "<"
399
396
  - !ruby/object:Gem::Version
400
397
  version: 0.7.0
401
- - - "!="
398
+ - - "<"
402
399
  - !ruby/object:Gem::Version
403
- version: 0.4.0
400
+ version: 0.8.0
404
401
  type: :runtime
405
402
  prerelease: false
406
403
  version_requirements: !ruby/object:Gem::Requirement
407
404
  requirements:
408
405
  - - ">="
409
- - !ruby/object:Gem::Version
410
- version: 0.3.0
411
- - - "<"
412
406
  - !ruby/object:Gem::Version
413
407
  version: 0.7.0
414
- - - "!="
408
+ - - "<"
415
409
  - !ruby/object:Gem::Version
416
- version: 0.4.0
410
+ version: 0.8.0
417
411
  - !ruby/object:Gem::Dependency
418
412
  name: pulp_certguard_client
419
413
  requirement: !ruby/object:Gem::Requirement
@@ -1086,6 +1080,7 @@ files:
1086
1080
  - app/lib/actions/pulp3/content_guard/refresh_all_distributions.rb
1087
1081
  - app/lib/actions/pulp3/content_migration.rb
1088
1082
  - app/lib/actions/pulp3/content_migration_presenter.rb
1083
+ - app/lib/actions/pulp3/content_migration_reset.rb
1089
1084
  - app/lib/actions/pulp3/content_view/delete_repository_references.rb
1090
1085
  - app/lib/actions/pulp3/content_view_version/create_exporter.rb
1091
1086
  - app/lib/actions/pulp3/content_view_version/create_importer.rb
@@ -2168,6 +2163,7 @@ files:
2168
2163
  - db/migrate/20210128231228_add_type_and_from_cvv_to_cvv_export_history.rb
2169
2164
  - db/migrate/20210201163238_migrate_background_download_policy_to_migrate.rb
2170
2165
  - db/migrate/20210208213920_add_available_module_stream_context.rb
2166
+ - db/migrate/20210218214048_change_default_content_view_version_export_history.rb
2171
2167
  - db/seeds.d/101-locations.rb
2172
2168
  - db/seeds.d/102-organizations.rb
2173
2169
  - db/seeds.d/104-proxy.rb
@@ -4529,6 +4525,7 @@ files:
4529
4525
  - lib/katello/tasks/pulp3_content_switchover.rake
4530
4526
  - lib/katello/tasks/pulp3_migration.rake
4531
4527
  - lib/katello/tasks/pulp3_migration_abort.rake
4528
+ - lib/katello/tasks/pulp3_migration_reset.rake
4532
4529
  - lib/katello/tasks/pulp3_migration_stats.rake
4533
4530
  - lib/katello/tasks/pulp3_post_migration_check.rake
4534
4531
  - lib/katello/tasks/receptor/extract_orgs.rake