lib/katello/tasks/pulp3_migration.rake in katello-3.18.3.1 vs lib/katello/tasks/pulp3_migration.rake in katello-3.18.4
- old
+ new
@@ -1,48 +1,55 @@
namespace :katello do
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."
task :pulp3_migration => ["dynflow:client", 'check_config'] do
- services = [:candlepin, :foreman_tasks, :pulp3, :pulp, :pulp_auth]
- Katello::Ping.ping!(services: services)
+ if !SETTINGS[:katello][:use_pulp_2_for_content_type][:docker] &&
+ !SETTINGS[:katello][:use_pulp_2_for_content_type][:file] &&
+ !SETTINGS[:katello][:use_pulp_2_for_content_type][:yum] &&
+ !SETTINGS[:katello][:use_pulp_2_for_content_type][:deb]
+ puts "Switchover is already complete, skipping migration work."
+ else
+ services = [:candlepin, :foreman_tasks, :pulp3, :pulp, :pulp_auth]
+ Katello::Ping.ping!(services: services)
- puts "Starting task."
- SmartProxy.pulp_primary.refresh
+ puts "Starting task."
+ SmartProxy.pulp_primary.refresh
- reimport_all = ::Foreman::Cast.to_bool(ENV['reimport_all'])
- wait = ::Foreman::Cast.to_bool(ENV['wait'] || 'true')
- preserve_output = ::Foreman::Cast.to_bool(ENV['preserve_output'])
+ reimport_all = ::Foreman::Cast.to_bool(ENV['reimport_all'])
+ wait = ::Foreman::Cast.to_bool(ENV['wait'] || 'true')
+ preserve_output = ::Foreman::Cast.to_bool(ENV['preserve_output'])
- User.current = User.anonymous_api_admin
- task = ForemanTasks.async_task(Actions::Pulp3::ContentMigration, SmartProxy.pulp_primary, reimport_all: reimport_all)
+ User.current = User.anonymous_api_admin
+ task = ForemanTasks.async_task(Actions::Pulp3::ContentMigration, SmartProxy.pulp_primary, reimport_all: reimport_all)
- if wait
- clear_count = nil
- until !task.pending? || task.paused?
- $stdout.print("\r#{' ' * clear_count}\r") if clear_count && !preserve_output #clear the line before printing
- $stdout.print("\n") if preserve_output
- message = "#{Time.now.to_s}: #{task.humanized[:output]}"
- clear_count = message.length + 1
- $stdout.print(message)
+ if wait
+ clear_count = nil
+ until !task.pending? || task.paused?
+ $stdout.print("\r#{' ' * clear_count}\r") if clear_count && !preserve_output #clear the line before printing
+ $stdout.print("\n") if preserve_output
+ message = "#{Time.now.to_s}: #{task.humanized[:output]}"
+ clear_count = message.length + 1
+ $stdout.print(message)
- sleep(10)
- task = ForemanTasks::Task.find(task.id)
- end
+ sleep(10)
+ task = ForemanTasks::Task.find(task.id)
+ end
- if task.result == 'warning' || task.result == 'pending'
- msg = _("Migration failed, You will want to investigate: https://#{Socket.gethostname}/foreman_tasks/tasks/#{task.id}\n")
- $stderr.print(msg)
- fail ForemanTasks::TaskError, task
- else
- puts
- Katello::Pulp3::Migration::CORRUPTABLE_CONTENT_TYPES.each do |type|
- if type.missing_migrated_content.any?
- puts "Some corrupted or missing content found, run 'foreman-maintain content migration-stats' for more information."
- exit(-1)
+ if task.result == 'warning' || task.result == 'pending'
+ msg = _("Migration failed, You will want to investigate: https://#{Socket.gethostname}/foreman_tasks/tasks/#{task.id}\n")
+ $stderr.print(msg)
+ fail ForemanTasks::TaskError, task
+ else
+ puts
+ Katello::Pulp3::Migration::CORRUPTABLE_CONTENT_TYPES.each do |type|
+ if type.missing_migrated_content.any?
+ puts "Some corrupted or missing content found, run 'foreman-maintain content migration-stats' for more information."
+ exit(-1)
+ end
end
+ puts _("Content Migration completed successfully")
end
- puts _("Content Migration completed successfully")
+ else
+ puts "Migration started, you may monitor it at: https://#{Socket.gethostname}/foreman_tasks/tasks/#{task.id}"
end
- else
- puts "Migration started, you may monitor it at: https://#{Socket.gethostname}/foreman_tasks/tasks/#{task.id}"
end
end
end