Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix runs with RabbitMQ >= 3.7.9 #751

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/puppet/provider/rabbitmq_binding/rabbitmqadmin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ def should_vhost

def self.all_vhosts
vhosts = []
rabbitmqctl('list_vhosts', '-q').split(%r{\n}).map do |vhost|
rabbitmqctl("#{@format_table_headers} -q list_vhosts".split(' ')).split(%r{\n}).map do |vhost|
vhosts.push(vhost)
end
vhosts
end

def self.all_bindings(vhost)
rabbitmqctl('list_bindings', '-q', '-p', vhost, 'source_name', 'destination_name', 'destination_kind', 'routing_key', 'arguments').split(%r{\n})
rabbitmqctl("#{@format_table_headers} list_bindings -q -p #{vhost} source_name destination_name destination_kind routing_key arguments".split(' ')).split(%r{\n})
end

def self.instances
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/provider/rabbitmq_exchange/rabbitmqadmin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def should_vhost
end

def self.all_vhosts
run_with_retries { rabbitmqctl('-q', 'list_vhosts') }.split(%r{\n})
run_with_retries { rabbitmqctl("#{@format_table_headers} -q list_vhosts".split(' ')) }.split(%r{\n})
end

def self.all_exchanges(vhost)
exchange_list = run_with_retries do
rabbitmqctl('-q', 'list_exchanges', '-p', vhost, 'name', 'type', 'internal', 'durable', 'auto_delete', 'arguments')
rabbitmqctl("#{@format_table_headers} -q list_exchanges -p #{vhost} name type internal durable auto_delete arguments".split(' '))
end
exchange_list.split(%r{\n}).reject { |exchange| exchange =~ %r{^federation:} }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/rabbitmq_parameter/rabbitmqctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def self.parameters(name, vhost)
unless @parameters[vhost]
@parameters[vhost] = {}
parameter_list = run_with_retries do
rabbitmqctl('list_parameters', '-q', '-p', vhost)
rabbitmqctl("#{@format_table_headers} list_parameters -q -p #{vhost}".split(' '))
end
parameter_list.split(%r{\n}).each do |line|
raise Puppet::Error, "cannot parse line from list_parameter:#{line}" unless line =~ %r{^(\S+)\s+(\S+)\s+(\S+)$}
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/rabbitmq_policy/rabbitmqctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def self.policies(vhost, name)
unless @policies[vhost]
@policies[vhost] = {}
policy_list = run_with_retries do
rabbitmqctl('list_policies', '-q', '-p', vhost)
rabbitmqctl("#{@format_table_headers} list_policies -q -p #{vhost}".split(' '))
end

# rabbitmq<3.2 does not support the applyto field
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/provider/rabbitmq_queue/rabbitmqadmin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def should_vhost
end

def self.all_vhosts
rabbitmqctl('list_vhosts', '-q').split(%r{\n})
rabbitmqctl("#{@format_table_headers} -q list_vhosts".split(' ')).split(%r{\n})
end

def self.all_queues(vhost)
rabbitmqctl('list_queues', '-q', '-p', vhost, 'name', 'durable', 'auto_delete', 'arguments').split(%r{\n})
rabbitmqctl("#{@format_table_headers} list_queues -q -p #{vhost} name durable auto_delete arguments".split(" ")).split(%r{\n})
end

def self.instances
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/rabbitmq_user/rabbitmqctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize(value = {})

def self.instances
user_list = run_with_retries do
rabbitmqctl('-q', 'list_users')
rabbitmqctl("#{@format_table_headers} -q list_users".split(' '))
end

user_list.split(%r{\n}).map do |line|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.users(name, vhost)
unless @users[name]
@users[name] = {}
user_permission_list = run_with_retries do
rabbitmqctl('-q', 'list_user_permissions', name)
rabbitmqctl("#{@format_table_headers} -q list_user_permissions #{name}".split(' '))
end
user_permission_list.split(%r{\n}).each do |line|
line = strip_backslashes(line)
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/provider/rabbitmq_vhost/rabbitmqctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def self.instances
vhost_list = run_with_retries do
rabbitmqctl('-q', 'list_vhosts')
rabbitmqctl("#{@format_table_headers} -q list_vhosts".split(' '))
end

vhost_list.split(%r{\n}).map do |line|
Expand All @@ -28,6 +28,6 @@ def destroy
end

def exists?
self.class.run_with_retries { rabbitmqctl('-q', 'list_vhosts') }.split(%r{\n}).include? resource[:name]
self.class.run_with_retries { rabbitmqctl("#{@format_table_headers} -q list_vhosts".split(' ')) }.split(%r{\n}).include? resource[:name]
end
end
9 changes: 8 additions & 1 deletion lib/puppet/provider/rabbitmqctl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ class Puppet::Provider::Rabbitmqctl < Puppet::Provider
def self.rabbitmq_version
output = rabbitmqctl('-q', 'status')
version = output.match(%r{\{rabbit,"RabbitMQ","([\d\.]+)"\}})
version[1] if version
if version
if Puppet::Util::Package.versioncmp(version[1], '3.7.9') >= 0
@format_table_headers = '--no-table-headers'
else
@format_table_headers = nil
end
version[1]
end
end

# Retry the given code block 'count' retries or until the
Expand Down