Module: Pacemaker::Nodes

Included in:
Puppet::Provider::PacemakerXML, Serverspec::Type::PacemakerXML
Defined in:
lib/pacemaker/xml/nodes.rb

Overview

functions related to the cluster nodes main structure “nodes” with node’s names and ids

Instance Method Summary collapse

Instance Method Details

#cib_section_nodesREXML::Element

get nodes CIB section

Returns:

  • (REXML::Element)

    at /cib/configuration/nodes



7
8
9
# File 'lib/pacemaker/xml/nodes.rb', line 7

def cib_section_nodes
  REXML::XPath.match cib, '/cib/configuration/nodes/*'
end

#dc_nameString?

the name of the current DC node

Returns:

  • (String, nil)


36
37
38
39
40
41
42
43
44
# File 'lib/pacemaker/xml/nodes.rb', line 36

def dc_name
  dc_node_id = dc
  return unless dc_node_id
  nodes.each do |node, attrs|
    next unless attrs['id'] == dc_node_id
    return node
  end
  nil
end

#node_nameString Also known as: hostname

hostname of the current node

Returns:

  • (String)


13
14
15
16
# File 'lib/pacemaker/xml/nodes.rb', line 13

def node_name
  return @node_name if @node_name
  @node_name = crm_node('-n').chomp.strip
end

#nodesHash<String => Hash>

the nodes structure uname => id

Returns:

  • (Hash<String => Hash>)


23
24
25
26
27
28
29
30
31
32
# File 'lib/pacemaker/xml/nodes.rb', line 23

def nodes
  return @nodes_structure if @nodes_structure
  @nodes_structure = {}
  cib_section_nodes.each do |node_block|
    node = attributes_to_hash node_block
    next unless node['id'] && node['uname']
    @nodes_structure.store node['uname'], node
  end
  @nodes_structure
end