Module: Pacemaker::Cib
- Included in:
- Puppet::Provider::PacemakerXML, Serverspec::Type::PacemakerXML
- Defined in:
- lib/pacemaker/xml/cib.rb
Overview
this submodule contains the basic functions for low-level actions with CIB data
Instance Method Summary collapse
-
#cib ⇒ REXML::Document
REXML::Document of the CIB data.
-
#cib=(cib) ⇒ Object
insert a new cib xml data instead of retrieving it can be used either for prefetching or for debugging.
-
#cib? ⇒ TrueClass, FalseClass
check id the CIB is retrieved and memorized.
-
#cib_reset(comment = nil) ⇒ Object
reset all mnemoization variables to force pacemaker to reload all the data structures.
-
#cibadmin_create(xml, scope = nil) ⇒ Object
add a new XML element to CIB.
-
#cibadmin_delete(xml, scope = nil) ⇒ Object
delete the XML element to CIB.
-
#cibadmin_modify(xml, scope = nil) ⇒ Object
modify the XML element.
-
#cibadmin_replace(xml, scope = nil) ⇒ Object
replace the XML element.
-
#dc ⇒ String?
get the name of the DC (Designated Controller) node used to determine if the cluster have elected one and is ready.
-
#dc_version ⇒ String?
get the dc_version string from the CIB configuration used to determine that the cluster have finished forming a correct cib structure uses an independent command call because CIB may not be ready yet.
-
#raw_cib ⇒ String
get the raw CIB from Pacemaker.
Instance Method Details
#cib ⇒ REXML::Document
REXML::Document of the CIB data
18 19 20 21 |
# File 'lib/pacemaker/xml/cib.rb', line 18 def cib return @cib if @cib @cib = REXML::Document.new(raw_cib) end |
#cib=(cib) ⇒ Object
insert a new cib xml data instead of retrieving it can be used either for prefetching or for debugging
26 27 28 29 30 31 32 |
# File 'lib/pacemaker/xml/cib.rb', line 26 def cib=(cib) @cib = if cib.is_a? REXML::Document cib else REXML::Document.new(cib) end end |
#cib? ⇒ TrueClass, FalseClass
check id the CIB is retrieved and memorized
36 37 38 |
# File 'lib/pacemaker/xml/cib.rb', line 36 def cib? !@cib.nil? end |
#cib_reset(comment = nil) ⇒ Object
reset all mnemoization variables to force pacemaker to reload all the data structures
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/pacemaker/xml/cib.rb', line 105 def cib_reset(comment = nil) = 'Call: cib_reset' += " (#{comment})" if comment debug @cib = nil @primitives_structure = nil @locations_structure = nil @colocations_structure = nil @orders_structure = nil @node_status_structure = nil @cluster_properties_structure = nil @nodes_structure = nil @resource_defaults_structure = nil @operation_defaults_structure = nil end |
#cibadmin_create(xml, scope = nil) ⇒ Object
add a new XML element to CIB
43 44 45 46 47 48 |
# File 'lib/pacemaker/xml/cib.rb', line 43 def cibadmin_create(xml, scope = nil) xml = xml_pretty_format xml if xml.is_a? REXML::Element = %w(--force --sync-call --create) += ['--scope', scope.to_s] if scope cibadmin_safe , '--xml-text', xml.to_s end |
#cibadmin_delete(xml, scope = nil) ⇒ Object
delete the XML element to CIB
53 54 55 56 57 58 |
# File 'lib/pacemaker/xml/cib.rb', line 53 def cibadmin_delete(xml, scope = nil) xml = xml_pretty_format xml if xml.is_a? REXML::Element = %w(--force --sync-call --delete) += ['--scope', scope.to_s] if scope cibadmin_safe , '--xml-text', xml.to_s end |
#cibadmin_modify(xml, scope = nil) ⇒ Object
modify the XML element
63 64 65 66 67 68 |
# File 'lib/pacemaker/xml/cib.rb', line 63 def cibadmin_modify(xml, scope = nil) xml = xml_pretty_format xml if xml.is_a? REXML::Element = %w(--force --sync-call --modify) += ['--scope', scope.to_s] if scope cibadmin_safe , '--xml-text', xml.to_s end |
#cibadmin_replace(xml, scope = nil) ⇒ Object
replace the XML element
73 74 75 76 77 78 |
# File 'lib/pacemaker/xml/cib.rb', line 73 def cibadmin_replace(xml, scope = nil) xml = xml_pretty_format xml if xml.is_a? REXML::Element = %w(--force --sync-call --replace) += ['--scope', scope.to_s] if scope cibadmin_safe , '--xml-text', xml.to_s end |
#dc ⇒ String?
get the name of the DC (Designated Controller) node used to determine if the cluster have elected one and is ready
83 84 85 86 87 88 89 90 |
# File 'lib/pacemaker/xml/cib.rb', line 83 def dc cib_element = cib.elements['/cib'] return unless cib_element dc_node_id = cib_element.attribute('dc-uuid') return unless dc_node_id return if dc_node_id == 'NONE' dc_node_id.to_s end |
#dc_version ⇒ String?
get the dc_version string from the CIB configuration used to determine that the cluster have finished forming a correct cib structure uses an independent command call because CIB may not be ready yet
96 97 98 99 100 |
# File 'lib/pacemaker/xml/cib.rb', line 96 def dc_version dc_version = crm_attribute '-q', '--type', 'crm_config', '--query', '--name', 'dc-version' return if dc_version.empty? dc_version end |
#raw_cib ⇒ String
get the raw CIB from Pacemaker
10 11 12 13 14 |
# File 'lib/pacemaker/xml/cib.rb', line 10 def raw_cib raw_cib = cibadmin '-Q' raise 'Could not dump CIB XML!' if !raw_cib || raw_cib == '' raw_cib end |