Puppet Function: mq_install::running_managers

Defined in:
lib/puppet/functions/mq_install/running_managers.rb
Function type:
Ruby 4.x API

Overview

mq_install::running_managers()Array

Function to fetch the fact mq_managers and based on that information decide if the specfied queue manager is running in standby mode or not.

Returns:

  • (Array)

    The MQ manageres that are currently running on the system



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/puppet/functions/mq_install/running_managers.rb', line 5

Puppet::Functions.create_function('mq_install::running_managers') do
  #
  # See the file "LICENSE" for the full license governing this code.
  #
  # @return The MQ manageres that are currently running on the system
  #
  dispatch :running_managers do
    return_type 'Array'
  end

  def running_managers
    variable = 'mq_managers'
    running_qms = []
    if variable_exists?(variable)
      fact_value = closure_scope.lookupvar("::#{variable}")
      fact_value.each { |qm| running_qms << qm['name'] if qm['state'] == 'Running' }
    end
    running_qms
  end

  # Check if the variable exists without generating a warning
  def variable_exists?(var)
    closure_scope.to_hash.key?(var)
  end
end