module ForemanInventoryUpload

Public Class Methods

base_folder() click to toggle source
# File lib/foreman_inventory_upload.rb, line 2
def self.base_folder
  # in production setup, where selinux is enabled, we only have rights to
  # create folders under /ver/lib/foreman. If the folder does not exist, it's
  # a dev setup, where we can use our current root
  @base_folder ||= File.join(
    Dir.glob('/var/lib/foreman').first || Dir.getwd,
    'red_hat_inventory/'
  )
end
done_file_path(filename) click to toggle source
# File lib/foreman_inventory_upload.rb, line 29
def self.done_file_path(filename)
  File.join(ForemanInventoryUpload.done_folder, filename)
end
done_folder() click to toggle source
# File lib/foreman_inventory_upload.rb, line 25
def self.done_folder
  File.join(ForemanInventoryUpload.uploads_folder, 'done/')
end
ensure_folder(folder) click to toggle source
# File lib/foreman_inventory_upload.rb, line 68
def self.ensure_folder(folder)
  FileUtils.mkdir_p(folder)
  folder
end
facts_archive_name(organization) click to toggle source
# File lib/foreman_inventory_upload.rb, line 50
def self.facts_archive_name(organization)
  "report_for_#{organization}.tar.xz"
end
generated_reports_folder() click to toggle source
# File lib/foreman_inventory_upload.rb, line 33
def self.generated_reports_folder
  @generated_reports_folder ||= ensure_folder(
    File.join(
      ForemanInventoryUpload.base_folder,
      'generated_reports/'
    )
  )
end
hosts_by_ids_url(host_ids) click to toggle source
# File lib/foreman_inventory_upload.rb, line 86
def self.hosts_by_ids_url(host_ids)
  host_ids_string = host_ids.join(',')
  "#{inventory_base_url}/#{host_ids_string}"
end
inventory_base_url() click to toggle source
# File lib/foreman_inventory_upload.rb, line 73
def self.inventory_base_url
  "#{ForemanRhCloud.cert_base_url}/api/inventory/v1/hosts"
end
inventory_export_url() click to toggle source
# File lib/foreman_inventory_upload.rb, line 77
def self.inventory_export_url
  tags = URI.encode("satellite/satellite_instance_id=#{Foreman.instance_id}")
  inventory_base_url + "?tags=#{tags}"
end
inventory_self_url() click to toggle source
# File lib/foreman_inventory_upload.rb, line 82
def self.inventory_self_url
  inventory_base_url + "?hostname_or_id=#{ForemanRhCloud.foreman_host.fqdn}"
end
max_org_size() click to toggle source
# File lib/foreman_inventory_upload.rb, line 63
def self.max_org_size
  # Set max amount of hosts per organization for automatic uploads
  @max_org_size ||= (ENV['SATELLITE_INVENTORY_MAX_ORG_SIZE'] || 150_000).to_i
end
outputs_folder() click to toggle source
# File lib/foreman_inventory_upload.rb, line 42
def self.outputs_folder
  @outputs_folder ||= ensure_folder(File.join(ForemanInventoryUpload.base_folder, 'outputs/'))
end
slice_size() click to toggle source
# File lib/foreman_inventory_upload.rb, line 59
def self.slice_size
  @slice_size ||= (ENV['SATELLITE_INVENTORY_SLICE_SIZE'] || '1000').to_i
end
upload_script_file() click to toggle source
# File lib/foreman_inventory_upload.rb, line 46
def self.upload_script_file
  'uploader.sh'
end
upload_url() click to toggle source
# File lib/foreman_inventory_upload.rb, line 54
def self.upload_url
  # for testing set ENV to 'https://ci.cloud.redhat.com/api/ingress/v1/upload'
  @upload_url ||= ENV['SATELLITE_INVENTORY_UPLOAD_URL'] || 'https://cert.cloud.redhat.com/api/ingress/v1/upload'
end
uploads_file_path(filename) click to toggle source
# File lib/foreman_inventory_upload.rb, line 21
def self.uploads_file_path(filename)
  File.join(ForemanInventoryUpload.uploads_folder, filename)
end
uploads_folder() click to toggle source
# File lib/foreman_inventory_upload.rb, line 12
def self.uploads_folder
  @uploads_folder ||= ensure_folder(
    File.join(
      ForemanInventoryUpload.base_folder,
      'uploads/'
    )
  )
end