Class: Puppet::Provider::Rabbitmqctl

Inherits:
Puppet::Provider
  • Object
show all
Defined in:
lib/puppet/provider/rabbitmqctl.rb

Class Method Summary collapse

Class Method Details

.rabbitmq_versionObject



5
6
7
8
9
# File 'lib/puppet/provider/rabbitmqctl.rb', line 5

def self.rabbitmq_version
  output = rabbitmqctl('-q', 'status')
  version = output.match(%r{\{rabbit,"RabbitMQ","([\d\.]+)"\}})
  version[1] if version
end

.run_with_retries(count = 30, step = 6, timeout = 10) ⇒ Object

Retry the given code block 'count' retries or until the command suceeeds. Use 'step' delay between retries. Limit each query time by 'timeout'. For example: users = self.class.run_with_retries { rabbitmqctl 'list_users' }

Raises:

  • (Puppet::Error)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/puppet/provider/rabbitmqctl.rb', line 16

def self.run_with_retries(count = 30, step = 6, timeout = 10)
  count.times do |_n|
    begin
      output = Timeout.timeout(timeout) do
        yield
      end
    rescue Puppet::ExecutionFailure, Timeout::Error
      Puppet.debug 'Command failed, retrying'
      sleep step
    else
      Puppet.debug 'Command succeeded'
      return output
    end
  end
  raise Puppet::Error, "Command is still failing after #{count * step} seconds expired!"
end