Sha256: e5a7080af1b200acbda501ec4529658a9e16892a299e7b6e2c1bec55efff526f

Contents?: true

Size: 1.41 KB

Versions: 11

Compression:

Stored size: 1.41 KB

Contents

namespace :katello do
  namespace :upgrades do
    namespace '2.1' do
      task :import_errata => ["environment"]  do

        def error(exception, system)
          message = _("There was an error updating Content Host %{name} with id %{id}") %
                               {:name =>system.name, :id => system.id}
          puts message
          Rails.logger.error(message)
          Rails.logger.error(exception.message)
        end

        def update_system_repositories(system)
          if system.bound_repositories.empty?
            puts _("Updating Content Host Repositories %s") % system.name
            system.bound_repositories << Katello::Repository.where(:pulp_id => system.pulp_bound_yum_repositories)
            system.save!
            system.propagate_yum_repos
          end
        end


        User.current = User.anonymous_api_admin

        puts _("Importing Errata")
        Katello::Erratum.import_all

        Katello::System.find_each do |system|
          begin
            update_system_repositories(system)
          rescue => e
            error(e, system)
          end
        end

        if Katello::System.any?
          puts _("Generating applicability for %s Content Hosts") % Katello::System.count
          ForemanTasks.sync_task(::Actions::Katello::System::GenerateApplicability,
                                 Katello::System.select([:id, :uuid]).all)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
katello-2.4.5 lib/katello/tasks/upgrades/2.1/import_errata.rake
katello-2.4.4 lib/katello/tasks/upgrades/2.1/import_errata.rake
katello-2.4.3 lib/katello/tasks/upgrades/2.1/import_errata.rake
katello-2.4.2 lib/katello/tasks/upgrades/2.1/import_errata.rake
katello-3.0.0.rc1 lib/katello/tasks/upgrades/2.1/import_errata.rake
katello-2.4.1 lib/katello/tasks/upgrades/2.1/import_errata.rake
katello-2.4.0 lib/katello/tasks/upgrades/2.1/import_errata.rake
katello-2.4.0.rc3 lib/katello/tasks/upgrades/2.1/import_errata.rake
katello-2.4.0.rc2 lib/katello/tasks/upgrades/2.1/import_errata.rake
katello-2.4.0.rc1 lib/katello/tasks/upgrades/2.1/import_errata.rake
katello-2.2.2 lib/katello/tasks/upgrades/2.1/import_errata.rake