Class: Loom::Facts::Provider

Inherits:
Object
  • Object
show all
Defined in:
lib/loom/facts/provider.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fact_mapObject (readonly)

TODO: add documentation re: use of namespace in fact_set.rb



5
6
7
# File 'lib/loom/facts/provider.rb', line 5

def fact_map
  @fact_map
end

#namespaceObject (readonly)

TODO: add documentation re: use of namespace in fact_set.rb



5
6
7
# File 'lib/loom/facts/provider.rb', line 5

def namespace
  @namespace
end

Class Method Details

.create_fact_providers(host_spec, shell, loom_config) ⇒ Object



31
32
33
34
35
# File 'lib/loom/facts/provider.rb', line 31

def create_fact_providers(host_spec, shell, loom_config)
  @provider_factories.map do |block|
    block.call(host_spec, shell, loom_config)
  end.flatten
end

.disable_for_host(host_spec, klass) ⇒ Object



12
13
14
15
16
17
# File 'lib/loom/facts/provider.rb', line 12

def disable_for_host(host_spec, klass)
  Loom.log.warn "disabling fact provider => #{klass} on #{host_spec.hostname}"
  @disabled_providers ||= {}
  @disabled_providers[host_spec.hostname] ||= []
  @disabled_providers[host_spec.hostname] << klass
end

.disabled_for_host?(host_spec, klass) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
22
23
# File 'lib/loom/facts/provider.rb', line 19

def disabled_for_host?(host_spec, klass)
  @disabled_providers ||= {}
  @disabled_providers[host_spec.hostname] ||= []
  @disabled_providers[host_spec.hostname].include? klass
end

.register_factory(klass, &block) ⇒ Object



25
26
27
28
29
# File 'lib/loom/facts/provider.rb', line 25

def register_factory(klass, &block)
  @provider_factories ||= []
  @provider_factories << block
  Loom.log.debug1(self) { "registered fact provider => #{klass}" }
end

Instance Method Details

#collect_factsObject

Should return a Hash of fact_name => fact_value entries



43
44
45
# File 'lib/loom/facts/provider.rb', line 43

def collect_facts
  raise 'not implemented'
end

#disable(host_spec) ⇒ Object



38
39
40
# File 'lib/loom/facts/provider.rb', line 38

def disable(host_spec)
  Provider.disable_for_host host_spec, self.class
end