Class: OS::Puppet::Fencing::Classifier

Inherits:
Object
  • Object
show all
Defined in:
lib/fencing/classifier.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, facter_adapter) ⇒ Classifier

Returns a new instance of Classifier.



9
10
11
12
# File 'lib/fencing/classifier.rb', line 9

def initialize(config, facter_adapter)
	@config = config
	@facter = facter_adapter
end

Instance Method Details

#assert_blocked(host_name, blocker) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fencing/classifier.rb', line 21

def assert_blocked(host_name, blocker)
          if !blocker
            Log.log("No blocker exists - returning")
            return
          end
	allowed_host = blocker.blocking_host_name
          return if !allowed_host
          Log.log("blocker not blocking #{allowed_host}")
	return if host_name.start_with?(allowed_host)
	fact_name = blocker.fact
	fact_value = @facter.lookup(allowed_host, fact_name)
          Log.log("Fact #{fact_name} on node #{allowed_host} has value #{fact_value}: expecting #{blocker.expected_value}")
	raise "cannot release #{host_name}" unless fact_value == blocker.expected_value
          Log.log("Fine - releasing node definition for #{host_name}")
end

#resolve_node(host_name) ⇒ Object



14
15
16
17
18
19
# File 'lib/fencing/classifier.rb', line 14

def resolve_node(host_name)
          Log.log("Looking up #{host_name}")
	node_config = @config.match_node(host_name)
	assert_blocked(host_name, node_config.blocker)
	node_config.node
end