From f710bed6aa445c33d3d307bdc144b6f7534d1282 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Wed, 3 Feb 2016 18:16:04 +0100 Subject: [PATCH] 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 --- lib/puppet/provider/keystone.rb | 7 ++++++- spec/unit/provider/keystone_spec.rb | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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)