Class: ForemanInventoryUpload::Generators::Queries

Inherits:
Object
  • Object
show all
Defined in:
lib/foreman_inventory_upload/generators/queries.rb

Class Method Summary collapse

Class Method Details

.fact_namesObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/foreman_inventory_upload/generators/queries.rb', line 4

def self.fact_names
  @fact_names ||= Hash[
    Katello::RhsmFactName.where(name:
      [
        'dmi::system::uuid',
        'virt::uuid',
        'cpu::cpu(s)',
        'cpu::cpu_socket(s)',
        'cpu::core(s)_per_socket',
        'memory::memtotal',
        'dmi::bios::vendor',
        'dmi::bios::version',
        'dmi::bios::relase_date',
        'distribution::name',
        'uname::release',
        'lscpu::flags',
        'distribution::version',
        'distribution::id',
        'virt::is_guest',
        'dmi::system::manufacturer',
        'dmi::system::product_name',
        'dmi::chassis::asset_tag',
        'insights_client::obfuscate_hostname_enabled',
        'insights_client::obfuscate_ip_enabled',
        'insights_client::hostname',
        'insights_client::ips',
        'insights_id',
        'conversions::activity',
        'conversions::packages::0::nevra',
        'conversions::packages::0::signature',
        'conversions::activity_started',
        'conversions::activity_ended',
        'conversions::success',
        'conversions::source_os::name',
        'conversions::source_os::version',
        'conversions::target_os::name',
        'conversions::target_os::version',
      ]).pluck(:name, :id)
    ]
end

.for_org(organization_id, use_batches: true) ⇒ Object



59
60
61
62
# File 'lib/foreman_inventory_upload/generators/queries.rb', line 59

def self.for_org(organization_id, use_batches: true)
  base_query = for_slice(Host.unscoped.where(organization_id: organization_id))
  use_batches ? base_query.in_batches(of: ForemanInventoryUpload.slice_size) : base_query
end

.for_slice(base) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/foreman_inventory_upload/generators/queries.rb', line 45

def self.for_slice(base)
  base
    .search_for("not params.#{InsightsCloud.enable_client_param} = f")
    .joins(:subscription_facet)
    .preload(
      :interfaces,
      :installed_packages,
      :content_facet,
      :host_statuses,
      :inventory_upload_facts,
      subscription_facet: [:pools, :installed_products, :hypervisor_host]
    )
end