Sha256: 9cccd976d2b48da5086b670106cd54936e175cdd9fdb620cdcc6e2782fb00705

Contents?: true

Size: 1.38 KB

Versions: 17

Compression:

Stored size: 1.38 KB

Contents

require 'tempfile'

namespace :rh_cloud_inventory 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

      User.as_anonymous_admin do
        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

  desc "Synchronize Insights hosts hits"
  task sync: :environment do
    InsightsCloud::Async::InsightsFullSync.perform_now()
    puts "Synchronized Insights hosts hits data"
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
foreman_rh_cloud-1.0.18 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-1.0.17 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-1.0.16 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-1.0.15 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-3.0.14 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-2.0.14 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-1.0.14 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-0.9.14 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-0.9.13.1 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-1.0.13.1 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-2.0.13.1 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-0.9.13 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-1.0.13 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-2.0.13 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-0.9.12 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-1.0.12 lib/tasks/rh_cloud_inventory.rake
foreman_rh_cloud-2.0.12 lib/tasks/rh_cloud_inventory.rake