23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/services/foreman_discovery/host_converter.rb', line 23
def self.set_build_clean_facts(host)
if Setting['discovery_clean_facts']
host.define_singleton_method(:clear_facts) do
keep_ids = FactValue.where(host_id: host.id, fact_names: { type: 'DiscoveryFactName' }).where("fact_names.name like 'discovery_%'").joins(:fact_name).pluck("fact_values.id")
FactValue.where.not(id: keep_ids).delete_all
end
else
host.define_singleton_method(:clear_facts) {}
end
host.build = true
end
|