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
-
#cib_section_operation_defaults ⇒ REXML::Element
get operation defaults CIB section.
-
#operation_default_defined?(attribute_name) ⇒ true, false
check if this operation default attribute have been defined.
-
#operation_default_delete(attribute_name) ⇒ Object
remove a defined operation default attribute.
-
#operation_default_set(attribute_name, attribute_value) ⇒ Object
set a single operation default value.
-
#operation_default_value(attribute_name) ⇒ String?
extract a single operation default attribute value returns nil if it have not been set.
-
#operation_defaults ⇒ Hash
the main ‘operation_defaults’ structure contains defaults operations and their values.
Instance Method Details
#cib_section_operation_defaults ⇒ REXML::Element
get operation defaults CIB section
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
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
41 42 43 44 45 |
# File 'lib/pacemaker/xml/operation_default.rb', line 41 def operation_default_delete(attribute_name) = ['--quiet', '--type', 'op_defaults', '--attr-name', attribute_name] += ['--delete-attr'] retry_block { crm_attribute_safe } end |
#operation_default_set(attribute_name, attribute_value) ⇒ Object
set a single operation default value
33 34 35 36 37 |
# File 'lib/pacemaker/xml/operation_default.rb', line 33 def operation_default_set(attribute_name, attribute_value) = ['--quiet', '--type', 'op_defaults', '--attr-name', attribute_name] += ['--attr-value', attribute_value] retry_block { crm_attribute_safe } end |
#operation_default_value(attribute_name) ⇒ String?
extract a single operation default attribute value returns nil if it have not been set
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_defaults ⇒ Hash
the main ‘operation_defaults’ structure contains defaults operations and their values
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 |