Module: Pacemaker::ConstraintColocations

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

Overview

functions related to colocations constraints main structure “constraint_colocations”

Instance Method Summary collapse

Instance Method Details

#constraint_colocation_add(colocation_structure) ⇒ Object

add a colocation constraint

Parameters:

  • colocation_structure (Hash<String => String>)

    the location data structure



21
22
23
24
25
26
27
# File 'lib/pacemaker/xml/constraint_colocations.rb', line 21

def constraint_colocation_add(colocation_structure)
  colocation_patch = xml_document
  colocation_element = xml_rsc_colocation colocation_structure
  raise "Could not create XML patch from colocation '#{colocation_structure.inspect}'!" unless colocation_element
  colocation_patch.add_element colocation_element
  wait_for_constraint_create xml_pretty_format(colocation_patch.root), colocation_structure['id']
end

#constraint_colocation_exists?(id) ⇒ TrueClass, FalseClass

check if colocation constraint exists

Parameters:

  • id (String)

    the constraint id

Returns:

  • (TrueClass, FalseClass)


15
16
17
# File 'lib/pacemaker/xml/constraint_colocations.rb', line 15

def constraint_colocation_exists?(id)
  constraint_colocations.key? id
end

#constraint_colocation_remove(id) ⇒ Object

remove a colocation constraint

Parameters:

  • id (String)

    the constraint id



31
32
33
# File 'lib/pacemaker/xml/constraint_colocations.rb', line 31

def constraint_colocation_remove(id)
  wait_for_constraint_remove "<rsc_colocation id='#{id}'/>\n", id
end

#constraint_colocationsHash<String => Hash>

get colocation constraints and use mnemoization on the list

Returns:

  • (Hash<String => Hash>)


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

def constraint_colocations
  return @colocations_structure if @colocations_structure
  @colocations_structure = constraints 'rsc_colocation'
end

#xml_rsc_colocation(data) ⇒ REXML::Element

generate rsc_colocation elements from data structure

Parameters:

  • data (Hash)

Returns:

  • (REXML::Element)


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

def xml_rsc_colocation(data)
  return unless data && data.is_a?(Hash)
  xml_element 'rsc_colocation', data, 'type'
end