Sha256: c3bc644ac93e2dd67b03c9ff1cce9e2f3177e65b0f2d76d5e025a539d3c6c099

Contents?: true

Size: 1.6 KB

Versions: 15

Compression:

Stored size: 1.6 KB

Contents

module ForemanInventoryUpload
  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

  def self.uploads_folder
    @uploads_folder ||= ensure_folder(
      File.join(
        ForemanInventoryUpload.base_folder,
        'uploads/'
      )
    )
  end

  def self.uploads_file_path(filename)
    File.join(ForemanInventoryUpload.uploads_folder, filename)
  end

  def self.done_folder
    File.join(ForemanInventoryUpload.uploads_folder, 'done/')
  end

  def self.done_file_path(filename)
    File.join(ForemanInventoryUpload.done_folder, filename)
  end

  def self.generated_reports_folder
    @generated_reports_folder ||= ensure_folder(
      File.join(
        ForemanInventoryUpload.base_folder,
        'generated_reports/'
      )
    )
  end

  def self.outputs_folder
    @outputs_folder ||= ensure_folder(File.join(ForemanInventoryUpload.base_folder, 'outputs/'))
  end

  def self.upload_script_file
    'uploader.sh'
  end

  def self.facts_archive_name(organization)
    "report_for_#{organization}.tar.gz"
  end

  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

  def self.ensure_folder(folder)
    FileUtils.mkdir_p(folder)
    folder
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
foreman_rh_cloud-2.0.9 lib/foreman_inventory_upload.rb
foreman_rh_cloud-1.0.9 lib/foreman_inventory_upload.rb
foreman_rh_cloud-0.9.9 lib/foreman_inventory_upload.rb
foreman_rh_cloud-0.9.8 lib/foreman_inventory_upload.rb
foreman_rh_cloud-1.0.8 lib/foreman_inventory_upload.rb
foreman_rh_cloud-2.0.8 lib/foreman_inventory_upload.rb
foreman_rh_cloud-0.9.7 lib/foreman_inventory_upload.rb
foreman_rh_cloud-1.0.7 lib/foreman_inventory_upload.rb
foreman_rh_cloud-2.0.7 lib/foreman_inventory_upload.rb
foreman_rh_cloud-0.9.6 lib/foreman_inventory_upload.rb
foreman_rh_cloud-1.0.6 lib/foreman_inventory_upload.rb
foreman_rh_cloud-2.0.6 lib/foreman_inventory_upload.rb
foreman_rh_cloud-0.9.5 lib/foreman_inventory_upload.rb
foreman_rh_cloud-1.0.5 lib/foreman_inventory_upload.rb
foreman_rh_cloud-2.0.5 lib/foreman_inventory_upload.rb