Class: OS::Puppet::Fencing::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_hash) ⇒ Config

Returns a new instance of Config.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fencing/config.rb', line 9

def initialize(config_hash)
	@config = config_hash
          global_blocker_config = config_hash['blocker']
          @global_blocker = Blocker.new(global_blocker_config) if global_blocker_config
          @nodes = []
          
          config_hash['hosts'].each do | host_prefix, conf|
              node_name = conf
              blocker = @global_blocker
              if(conf.class == Hash)
                  node_name = conf['node_name']
                  blocker_conf = conf['blocker'] 
                  blocker = blocker_conf ? Blocker.new(conf['blocker']) : global_blocker
              end
              nodes << Node.new(host_prefix, node_name, blocker)
          end
          
end

Instance Attribute Details

#nodesObject (readonly)

Returns the value of attribute nodes.



7
8
9
# File 'lib/fencing/config.rb', line 7

def nodes
  @nodes
end

Instance Method Details

#global_blockerObject



35
36
37
# File 'lib/fencing/config.rb', line 35

def global_blocker
    @global_blocker
end

#match_node(host_name) ⇒ Object



28
29
30
31
32
33
# File 'lib/fencing/config.rb', line 28

def match_node(host_name)
    nodes.each do | node |
        return node if host_name.start_with?(node.host_prefix)
    end
    raise "Could not find configuration for host #{host_name}"
end