Module: ForemanInventoryUpload
  
  
  
  
  
  
  
  
  
  
  
  
    - Defined in:
 
    - lib/foreman_inventory_upload.rb,
  lib/foreman_inventory_upload/generators/tags.rb,
 lib/foreman_inventory_upload/generators/slice.rb,
 lib/foreman_inventory_upload/generators/queries.rb,
 lib/foreman_inventory_upload/async/async_helpers.rb,
 lib/foreman_inventory_upload/async/delayed_start.rb,
 lib/foreman_inventory_upload/async/shell_process.rb,
 lib/foreman_inventory_upload/generators/metadata.rb,
 lib/foreman_inventory_upload/async/progress_output.rb,
 lib/foreman_inventory_upload/generators/json_stream.rb,
 lib/foreman_inventory_upload/async/upload_report_job.rb,
 lib/foreman_inventory_upload/generators/fact_helpers.rb,
 lib/foreman_inventory_upload/async/generate_report_job.rb,
 lib/foreman_inventory_upload/async/queue_for_upload_job.rb,
 lib/foreman_inventory_upload/generators/archived_report.rb,
 app/controllers/foreman_inventory_upload/tasks_controller.rb,
 app/controllers/foreman_inventory_upload/reports_controller.rb,
 app/controllers/foreman_inventory_upload/uploads_controller.rb,
 lib/foreman_inventory_upload/async/generate_all_reports_job.rb,
 app/controllers/foreman_inventory_upload/accounts_controller.rb,
 lib/foreman_inventory_upload/async/remove_insights_hosts_job.rb,
 app/controllers/foreman_inventory_upload/cloud_status_controller.rb,
 app/controllers/foreman_inventory_upload/missing_hosts_controller.rb,
 app/controllers/foreman_inventory_upload/uploads_settings_controller.rb,
 lib/foreman_inventory_upload/notifications/manifest_import_success_notification_override.rb
 
  
  
 
Defined Under Namespace
  
    
      Modules: Async, Generators, Notifications
    
  
    
      Classes: AccountsController, CloudStatusController, MissingHostsController, ReportsController, TasksController, UploadsController, UploadsSettingsController
    
  
  
    
      Class Method Summary
      collapse
    
    
  
  
    Class Method Details
    
      
  
  
    .base_folder  ⇒ Object 
  
  
  
  
    
      
2
3
4
5
6
7
8
9
10 
     | 
    
      # File 'lib/foreman_inventory_upload.rb', line 2
def self.base_folder
        @base_folder ||= File.join(
    Dir.glob('/var/lib/foreman').first || Dir.getwd,
    'red_hat_inventory/'
  )
end
     | 
  
 
    
      
  
  
    .done_file_path(filename)  ⇒ Object 
  
  
  
 
    
      
    
      
  
  
    .ensure_folder(folder)  ⇒ Object 
  
  
  
  
    
      
68
69
70
71 
     | 
    
      # File 'lib/foreman_inventory_upload.rb', line 68
def self.ensure_folder(folder)
  FileUtils.mkdir_p(folder)
  folder
end 
     | 
  
 
    
      
  
  
    .facts_archive_name(organization)  ⇒ Object 
  
  
  
  
    
      
50
51
52 
     | 
    
      # File 'lib/foreman_inventory_upload.rb', line 50
def self.facts_archive_name(organization)
  "report_for_#{organization}.tar.xz"
end
     | 
  
 
    
      
  
  
    .generated_reports_folder  ⇒ Object 
  
  
  
  
    
      
33
34
35
36
37
38
39
40 
     | 
    
      # 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)  ⇒ Object 
  
  
  
  
    
      
86
87
88
89 
     | 
    
      # 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  ⇒ Object 
  
  
  
  
    
      
73
74
75 
     | 
    
      # 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  ⇒ Object 
  
  
  
  
    
      
77
78
79
80 
     | 
    
      # File 'lib/foreman_inventory_upload.rb', line 77
def self.inventory_export_url
  tags = CGI.escape("satellite/satellite_instance_id=#{Foreman.instance_id}")
  inventory_base_url + "?tags=#{tags}"
end
     | 
  
 
    
      
  
  
    .inventory_self_url  ⇒ Object 
  
  
  
  
    
      
82
83
84 
     | 
    
      # 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  ⇒ Object 
  
  
  
  
    
      
63
64
65
66 
     | 
    
      # File 'lib/foreman_inventory_upload.rb', line 63
def self.max_org_size
    @max_org_size ||= (ENV['SATELLITE_INVENTORY_MAX_ORG_SIZE'] || 150_000).to_i
end
     | 
  
 
    
      
  
  
    .outputs_folder  ⇒ Object 
  
  
  
  
    
      
42
43
44 
     | 
    
      # 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  ⇒ Object 
  
  
  
  
    
      
59
60
61 
     | 
    
      # 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  ⇒ Object 
  
  
  
  
    
      
46
47
48 
     | 
    
      # File 'lib/foreman_inventory_upload.rb', line 46
def self.upload_script_file
  'uploader.sh'
end 
     | 
  
 
    
      
  
  
    .upload_url  ⇒ Object 
  
  
  
  
    
      
54
55
56
57 
     | 
    
      # File 'lib/foreman_inventory_upload.rb', line 54
def self.upload_url
    @upload_url ||= ENV['SATELLITE_INVENTORY_UPLOAD_URL'] || 'https://cert.cloud.redhat.com/api/ingress/v1/upload'
end
     | 
  
 
    
      
  
  
    .uploads_file_path(filename)  ⇒ Object 
  
  
  
 
    
      
  
  
    .uploads_folder  ⇒ Object 
  
  
  
  
    
      
12
13
14
15
16
17
18
19 
     | 
    
      # File 'lib/foreman_inventory_upload.rb', line 12
def self.uploads_folder
  @uploads_folder ||= ensure_folder(
    File.join(
      ForemanInventoryUpload.base_folder,
      'uploads/'
    )
  )
end
     |