Module: Pacemaker::Properties

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

Overview

functions related to the cluster properties main structure “cluster_properties”

Instance Method Summary collapse

Instance Method Details

#cib_section_cluster_propertyREXML::Element

get cluster property CIB section

Returns:

  • (REXML::Element)


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

def cib_section_cluster_property
  REXML::XPath.match(cib, '/cib/configuration/crm_config/cluster_property_set').first
end

#cluster_propertiesHash<String => Hash>

get cluster property structure

Returns:

  • (Hash<String => Hash>)


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

def cluster_properties
  return @cluster_properties_structure if @cluster_properties_structure
  @cluster_properties_structure = children_elements_to_hash cib_section_cluster_property, 'name'
end

#cluster_property_defined?(property_name) ⇒ TrueClass, FalseClass

check if this property has a value

Parameters:

  • property_name (String)

    the name of the property

Returns:

  • (TrueClass, FalseClass)


46
47
48
49
50
# File 'lib/pacemaker/xml/properties.rb', line 46

def cluster_property_defined?(property_name)
  return false unless cluster_properties.key? property_name
  return false unless cluster_properties[property_name].is_a?(Hash) && cluster_properties[property_name]['value']
  true
end

#cluster_property_delete(property_name) ⇒ Object

delete this cluster’s property

Parameters:

  • property_name (String)

    the name of the property



37
38
39
40
41
# File 'lib/pacemaker/xml/properties.rb', line 37

def cluster_property_delete(property_name)
  options = ['--quiet', '--type', 'crm_config', '--name', property_name]
  options += ['--delete']
  retry_block { crm_attribute_safe options }
end

#cluster_property_set(property_name, property_value) ⇒ Object

set the value to this cluster’s property

Parameters:

  • property_name (String)

    the name of the property

  • property_value (String)

    the value of the property



29
30
31
32
33
# File 'lib/pacemaker/xml/properties.rb', line 29

def cluster_property_set(property_name, property_value)
  options = ['--quiet', '--type', 'crm_config', '--name', property_name]
  options += ['--update', property_value]
  retry_block { crm_attribute_safe options }
end

#cluster_property_value(property_name) ⇒ String

get the value of a cluster property by it’s name

Parameters:

  • property_name (String)

    the name of the property

Returns:

  • (String)


21
22
23
24
# File 'lib/pacemaker/xml/properties.rb', line 21

def cluster_property_value(property_name)
  return unless cluster_property_defined? property_name
  cluster_properties[property_name]['value']
end