Class: Facter::Resolvers::BaseResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/facter/resolvers/base_resolver.rb

Direct Known Subclasses

AioAgentVersion, Aix::Disks, Aix::Filesystem, Aix::LoadAverages, Aix::Memory, Aix::Mountpoints, Aix::Networking, Aix::Nim, Aix::OsLevel, Aix::Partitions, Aix::Processors, Aix::Serialnumber, Amzn::OsReleaseRpm, Architecture, Augeas, Az, Facter::Resolvers::Bsd::Processors, Containers, DMIBios, DMIComputerSystem, DebianVersion, DmiDecode, Ec2, EosRelease, Facterversion, Freebsd::DmiBios, Freebsd::FreebsdVersion, Freebsd::Geom, Freebsd::Processors, Freebsd::SwapMemory, Freebsd::SystemMemory, Freebsd::Virtual, Gce, Hardware, HardwareArchitecture, Hostname, Identity, Kernel, Linux::Disks, Linux::DmiBios, Linux::DockerUptime, Linux::Filesystems, Linux::FipsEnabled, Linux::Hostname, Linux::LoadAverages, Linux::Lscpu, Linux::Memory, Linux::Networking, Linux::Processors, LoadAverages, Lpar, LsbRelease, Lspci, Macosx::DmiBios, Macosx::Filesystems, Macosx::LoadAverages, Macosx::Mountpoints, Macosx::Processors, Macosx::SwapMemory, Macosx::SystemMemory, Macosx::SystemProfiler, Memory, Mountpoints, NetKVM, Networking, OpenVz, OsRelease, Partitions, Path, PosxIdentity, Processors, ProductRelease, RedHatRelease, ReleaseFromFirstLine, Ruby, SELinux, Solaris::Disks, Solaris::Dmi, Solaris::DmiSparc, Solaris::Filesystem, Solaris::Ipaddress, Solaris::Ldom, Solaris::Memory, Solaris::Mountpoints, Solaris::Networking, Solaris::OsRelease, Solaris::Processors, Solaris::Zone, Solaris::ZoneName, SpecificReleaseFile, Ssh, SuseRelease, SwVers, System32, Timezone, Uname, Uptime, VirtWhat, Vmware, WinOsDescription, Windows::AioAgentVersion, Windows::Fips, Windows::Networking, Windows::Ssh, Windows::Timezone, Windows::Uptime, Windows::Virtualization, Wpar, Xen, ZFS, Zpool

Class Method Summary collapse

Class Method Details

.cache_nil_for_unresolved_facts(fact_name) ⇒ Object



35
36
37
38
# File 'lib/facter/resolvers/base_resolver.rb', line 35

def self.cache_nil_for_unresolved_facts(fact_name)
  @fact_list.fetch(fact_name) { @fact_list[fact_name] = nil }
  @fact_list[fact_name]
end

.init_resolverObject



14
15
16
17
# File 'lib/facter/resolvers/base_resolver.rb', line 14

def self.init_resolver
  @fact_list = {}
  @semaphore = Mutex.new
end

.invalidate_cacheObject



10
11
12
# File 'lib/facter/resolvers/base_resolver.rb', line 10

def self.invalidate_cache
  @fact_list = {}
end

.logObject



6
7
8
# File 'lib/facter/resolvers/base_resolver.rb', line 6

def self.log
  @log ||= Log.new(self)
end

.post_resolve(_fact_name, _options) ⇒ Object

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/facter/resolvers/base_resolver.rb', line 40

def self.post_resolve(_fact_name, _options)
  raise NotImplementedError, "You must implement post_resolve(fact_name, options) method in #{name}"
end

.resolve(fact_name, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/facter/resolvers/base_resolver.rb', line 23

def self.resolve(fact_name, options = {})
  @semaphore.synchronize do
    subscribe_to_manager
    post_resolve(fact_name, options)

    cache_nil_for_unresolved_facts(fact_name)
  end
rescue LoadError, NameError => e
  log.error("Resolving fact #{fact_name}, but got #{e} at #{e.backtrace[0]}")
  @fact_list[fact_name] = nil
end

.subscribe_to_managerObject



19
20
21
# File 'lib/facter/resolvers/base_resolver.rb', line 19

def self.subscribe_to_manager
  Facter::SessionCache.subscribe(self)
end