class ForemanInventoryUpload::Generators::Queries
Public Class Methods
fact_names()
click to toggle source
# 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', 'hypervisor::type', 'hypervisor::version', '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_ipv4_enabled', 'insights_client::obfuscate_ipv6_enabled', 'insights_client::obfuscated_ipv4', 'insights_client::obfuscated_ipv6', 'insights_client::obfuscated_hostname', '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, hosts_query: '')
click to toggle source
# File lib/foreman_inventory_upload/generators/queries.rb, line 73 def self.for_org(organization_id, use_batches: true, hosts_query: '') base_query = for_slice(Host.unscoped.where(organization_id: organization_id).search_for(hosts_query)) use_batches ? base_query.in_batches(of: ForemanInventoryUpload.slice_size) : base_query end
for_slice(base)
click to toggle source
# File lib/foreman_inventory_upload/generators/queries.rb, line 49 def self.for_slice(base) query = base # In IoP mode, skip the parameter check - include all hosts regardless of opt-out setting unless skip_inventory_parameter_filter? query = query.search_for("not params.#{InsightsCloud.enable_client_param_inventory} = f") end query .joins(:subscription_facet) .preload( :interfaces, :installed_packages, :content_facet, :host_statuses, :inventory_upload_facts, subscription_facet: [:installed_products, :hypervisor_host] ) end
skip_inventory_parameter_filter?()
click to toggle source
# File lib/foreman_inventory_upload/generators/queries.rb, line 69 def self.skip_inventory_parameter_filter? ForemanRhCloud.with_iop_smart_proxy? end