sanitize IPv6 in keystone provider

In keystone.rb provider, we need to make sure the ipv6 returned in
clean_host method has brackets.
If brackets are missing, the provider will fail to manage Keystone
resources, because of parsing issue and the multiple ":" in the host
value.

Change-Id: Ibdb340642270afae64b1055ef5fb97281b17066d
Closes-Bug: #1541512
This commit is contained in:
Emilien Macchi 2016-02-03 18:16:04 +01:00
parent d9cecd44a9
commit f710bed6aa
2 changed files with 14 additions and 1 deletions

View File

@ -29,7 +29,12 @@ class Puppet::Provider::Keystone < Puppet::Provider::Openstack
when '::0'
return '[::1]'
else
return host
# if ipv6, make sure ip address has brackets - LP#1541512
if host.include?(':') and !host.include?(']')
return "[" + host + "]"
else
return host
end
end
end

View File

@ -194,6 +194,14 @@ id="the_user_id"
expect(klass.get_admin_endpoint).to eq('http://[::1]:5001')
end
it 'should use [2620:52:0:23a9::25] in the admin endpoint if bind_host is 2620:52:0:23a9::25' do
mock = {'DEFAULT' => { 'admin_bind_host' => '2620:52:0:23a9::25', 'admin_port' => '5001' }}
File.expects(:exists?).with("/etc/keystone/keystone.conf").returns(true)
Puppet::Util::IniConfig::File.expects(:new).returns(mock)
mock.expects(:read).with('/etc/keystone/keystone.conf')
expect(klass.get_admin_endpoint).to eq('http://[2620:52:0:23a9::25]:5001')
end
it 'should use localhost in the admin endpoint if bind_host is unspecified' do
mock = {'DEFAULT' => { 'admin_port' => '5001' }}
File.expects(:exists?).with("/etc/keystone/keystone.conf").returns(true)