Module: Pacemaker::OperationDefault

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

Overview

functions related to the operation defaults main structure “operation_defaults”

Instance Method Summary collapse

Instance Method Details

#cib_section_operation_defaultsREXML::Element

get operation defaults CIB section

Returns:

  • (REXML::Element)


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

def cib_section_operation_defaults
  REXML::XPath.match(cib, '/cib/configuration/op_defaults/meta_attributes').first
end

#operation_default_defined?(attribute_name) ⇒ true, false

check if this operation default attribute have been defined

Parameters:

  • attribute_name (String)

Returns:

  • (true, false)


50
51
52
53
54
# File 'lib/pacemaker/xml/operation_default.rb', line 50

def operation_default_defined?(attribute_name)
  return false unless operation_defaults.key? attribute_name
  return false unless operation_defaults[attribute_name].is_a?(Hash) && operation_defaults[attribute_name]['value']
  true
end

#operation_default_delete(attribute_name) ⇒ Object

remove a defined operation default attribute

Parameters:

  • attribute_name (String)


41
42
43
44
45
# File 'lib/pacemaker/xml/operation_default.rb', line 41

def operation_default_delete(attribute_name)
  options = ['--quiet', '--type', 'op_defaults', '--attr-name', attribute_name]
  options += ['--delete-attr']
  retry_block { crm_attribute_safe options }
end

#operation_default_set(attribute_name, attribute_value) ⇒ Object

set a single operation default value

Parameters:

  • attribute_name (String)
  • attribute_value (String)


33
34
35
36
37
# File 'lib/pacemaker/xml/operation_default.rb', line 33

def operation_default_set(attribute_name, attribute_value)
  options = ['--quiet', '--type', 'op_defaults', '--attr-name', attribute_name]
  options += ['--attr-value', attribute_value]
  retry_block { crm_attribute_safe options }
end

#operation_default_value(attribute_name) ⇒ String?

extract a single operation default attribute value returns nil if it have not been set

Parameters:

  • attribute_name (String)

Returns:

  • (String, nil)


25
26
27
28
# File 'lib/pacemaker/xml/operation_default.rb', line 25

def operation_default_value(attribute_name)
  return unless operation_default_defined? attribute_name
  operation_defaults[attribute_name]['value']
end

#operation_defaultsHash

the main ‘operation_defaults’ structure contains defaults operations and their values

Returns:

  • (Hash)


14
15
16
17
18
19
# File 'lib/pacemaker/xml/operation_default.rb', line 14

def operation_defaults
  return @operation_defaults_structure if @operation_defaults_structure
  @operation_defaults_structure = children_elements_to_hash cib_section_operation_defaults, 'name'
  @operation_defaults_structure = {} unless @operation_defaults_structure
  @operation_defaults_structure
end