Sha256: 990a0b20e4ebbef5f4fc74042e3549e2dc0de5347e8c5436d56f2e3e727b3fca

Contents?: true

Size: 1.14 KB

Versions: 33

Compression:

Stored size: 1.14 KB

Contents

require 'tempfile'

namespace :foreman_inventory_upload do
  namespace :report do
    desc 'Generate inventory report to be sent to Red Hat cloud'
    task generate: :environment do
      portal_user = ENV['portal_user']
      organizations = [ENV['organization_id']]
      base_folder = ENV['target'] || Dir.pwd

      unless portal_user || organizations.empty?
        puts "Must specify either portal_user or organization_id"
      end

      if portal_user
        puts "Generating report for all organizations associated with #{portal_user}"
        base_folder = File.join(base_folder, portal_user)
        organizations = ForemanInventoryUpload::Generators::Queries.organizations_for_user(portal_user).pluck(:id)
      end

      organizations.each do |organization|
        target = File.join(base_folder, ForemanInventoryUpload.facts_archive_name(organization))
        archived_report_generator = ForemanInventoryUpload::Generators::ArchivedReport.new(target, Logger.new(STDOUT))
        archived_report_generator.render(organization: organization)
        puts "Successfully generated #{target} for organization id #{organization}"
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
foreman_rh_cloud-0.9.10 lib/tasks/generator.rake
foreman_rh_cloud-1.0.10 lib/tasks/generator.rake
foreman_rh_cloud-2.0.10 lib/tasks/generator.rake
foreman_rh_cloud-2.0.9 lib/tasks/generator.rake
foreman_rh_cloud-1.0.9 lib/tasks/generator.rake
foreman_rh_cloud-0.9.9 lib/tasks/generator.rake
foreman_rh_cloud-0.9.8 lib/tasks/generator.rake
foreman_rh_cloud-1.0.8 lib/tasks/generator.rake
foreman_rh_cloud-2.0.8 lib/tasks/generator.rake
foreman_rh_cloud-0.9.7 lib/tasks/generator.rake
foreman_rh_cloud-1.0.7 lib/tasks/generator.rake
foreman_rh_cloud-2.0.7 lib/tasks/generator.rake
foreman_rh_cloud-0.9.6 lib/tasks/generator.rake
foreman_rh_cloud-1.0.6 lib/tasks/generator.rake
foreman_rh_cloud-2.0.6 lib/tasks/generator.rake
foreman_rh_cloud-0.9.5 lib/tasks/generator.rake
foreman_rh_cloud-1.0.5 lib/tasks/generator.rake
foreman_rh_cloud-2.0.5 lib/tasks/generator.rake
foreman_rh_cloud-0.9.4.1 lib/tasks/generator.rake
foreman_rh_cloud-1.0.4.1 lib/tasks/generator.rake