Transport url fix
- added possibility to add more then one rabbit host - edited rubocop constraints due to transport_url complexity Change-Id: I9540b40c0dba46a62c21242b94089b81921700ca
This commit is contained in:
parent
57fa9ecef7
commit
b6f06c34af
|
@ -30,4 +30,4 @@ WordArray:
|
|||
MinSize: 3
|
||||
|
||||
MethodLength:
|
||||
Max: 15
|
||||
Max: 16
|
||||
|
|
|
@ -11,7 +11,7 @@ Lint/NestedMethodDefinition:
|
|||
|
||||
# Offense count: 9
|
||||
Metrics/AbcSize:
|
||||
Max: 31
|
||||
Max: 40
|
||||
|
||||
# Offense count: 2
|
||||
Metrics/PerceivedComplexity:
|
||||
|
|
|
@ -36,10 +36,17 @@ module ::Openstack
|
|||
mq_password = get_password 'user', mq_user
|
||||
mq_port = node['openstack']['endpoints']['mq']['port']
|
||||
vhost = node['openstack']['mq']['vhost']
|
||||
bind_mq = node['openstack']['bind_service']['mq']
|
||||
bind_mq_address = bind_address bind_mq
|
||||
url = "rabbit://#{mq_user}:#{mq_password}@#{bind_mq_address}:#{mq_port}"
|
||||
url += "/#{vhost}" unless vhost == '/'
|
||||
bind_mq_address = bind_address node['openstack']['bind_service']['mq']
|
||||
url = 'rabbit://'
|
||||
if node['openstack']['mq']['cluster']
|
||||
node['openstack']['mq']['servers'].each do |server|
|
||||
url += "#{mq_user}:#{mq_password}@#{server}:#{mq_port}"
|
||||
url += ',' unless node['openstack']['mq']['servers'].last == server
|
||||
end
|
||||
else
|
||||
url += "#{mq_user}:#{mq_password}@#{bind_mq_address}:#{mq_port}"
|
||||
end
|
||||
url += vhost
|
||||
url
|
||||
end
|
||||
|
||||
|
|
|
@ -105,21 +105,22 @@ describe 'openstack-common::default' do
|
|||
allow(subject).to receive(:get_password)
|
||||
.with('user', 'guest')
|
||||
.and_return('mypass')
|
||||
expected = 'rabbit://guest:mypass@127.0.0.1:5672'
|
||||
expected = 'rabbit://guest:mypass@127.0.0.1:5672/'
|
||||
expect(subject.rabbit_transport_url('compute')).to eq(expected)
|
||||
end
|
||||
|
||||
it do
|
||||
node.set['openstack']['mq']['service_type'] = 'rabbit'
|
||||
node.set['openstack']['mq']['cluster'] = true
|
||||
node.set['openstack']['mq']['compute']['rabbit']['userid'] = 'rabbit2'
|
||||
node.set['openstack']['endpoints']['mq']['port'] = 1234
|
||||
node.set['openstack']['bind_service']['mq']['host'] = '10.0.0.1'
|
||||
node.set['openstack']['mq']['vhost'] = 'anyhost'
|
||||
node.set['openstack']['mq']['servers'] = %w(10.0.0.1 10.0.0.2 10.0.0.3)
|
||||
node.set['openstack']['mq']['vhost'] = '/anyhost'
|
||||
allow(subject).to receive(:node).and_return(chef_run.node)
|
||||
allow(subject).to receive(:get_password)
|
||||
.with('user', 'rabbit2')
|
||||
.and_return('mypass2')
|
||||
expected = 'rabbit://rabbit2:mypass2@10.0.0.1:1234/anyhost'
|
||||
expected = 'rabbit://rabbit2:mypass2@10.0.0.1:1234,rabbit2:mypass2@10.0.0.2:1234,rabbit2:mypass2@10.0.0.3:1234/anyhost'
|
||||
expect(subject.rabbit_transport_url('compute')).to eq(expected)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue