Module: Pacemaker::ConstraintOrders

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

Overview

functions related to constraint_orders constraints main structure “constraint_orders”

Instance Method Summary collapse

Instance Method Details

#constraint_order_add(order_structure) ⇒ Object

add a order constraint

Parameters:

  • order_structure (Hash<String => String>)

    the location data structure



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

def constraint_order_add(order_structure)
  order_patch = xml_document
  order_element = xml_rsc_order order_structure
  raise "Could not create XML patch from colocation '#{order_structure.inspect}'!" unless order_element
  order_patch.add_element order_element
  wait_for_constraint_create xml_pretty_format(order_patch.root), order_structure['id']
end

#constraint_order_exists?(id) ⇒ TrueClass, FalseClass

check if order constraint exists

Parameters:

  • id (String)

    the constraint id

Returns:

  • (TrueClass, FalseClass)


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

def constraint_order_exists?(id)
  constraint_orders.key? id
end

#constraint_order_remove(id) ⇒ Object

remove an order constraint

Parameters:

  • id (String)

    the constraint id



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

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

#constraint_ordersHash<String => Hash>

get order constraints and use memoization on the list

Returns:

  • (Hash<String => Hash>)


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

def constraint_orders
  return @orders_structure if @orders_structure
  @orders_structure = constraints 'rsc_order'
end

#xml_rsc_order(data) ⇒ REXML::Element

generate rsc_order elements from data structure

Parameters:

  • data (Hash)

Returns:

  • (REXML::Element)


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

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