diff --git a/lib/puppet/provider/keystone.rb b/lib/puppet/provider/keystone.rb index c1a747873..8a5ab299c 100644 --- a/lib/puppet/provider/keystone.rb +++ b/lib/puppet/provider/keystone.rb @@ -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 diff --git a/spec/unit/provider/keystone_spec.rb b/spec/unit/provider/keystone_spec.rb index 7e694acdb..955099226 100644 --- a/spec/unit/provider/keystone_spec.rb +++ b/spec/unit/provider/keystone_spec.rb @@ -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)