Sha256: cbb1c9e717f2b293dcdbc96fc1a7106ba779c5e9ce3daef385055fc3cf0265e9

Contents?: true

Size: 1.66 KB

Versions: 9

Compression:

Stored size: 1.66 KB

Contents

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"] do
    services = [:candlepin, :foreman_tasks, :pulp3, :pulp, :pulp_auth]
    Katello::Ping.ping!(services: services)

    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'])

    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)

        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 _("Content Migration completed successfully")
      end
    else
      puts "Migration started, you may monitor it at: https://#{Socket.gethostname}/foreman_tasks/tasks/#{task.id}"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
katello-4.0.3 lib/katello/tasks/pulp3_migration.rake
katello-4.0.2.1 lib/katello/tasks/pulp3_migration.rake
katello-4.0.2 lib/katello/tasks/pulp3_migration.rake
katello-4.0.1.2 lib/katello/tasks/pulp3_migration.rake
katello-4.0.1.1 lib/katello/tasks/pulp3_migration.rake
katello-4.0.1 lib/katello/tasks/pulp3_migration.rake
katello-4.0.0 lib/katello/tasks/pulp3_migration.rake
katello-4.0.0.rc3.1 lib/katello/tasks/pulp3_migration.rake
katello-4.0.0.rc3 lib/katello/tasks/pulp3_migration.rake