From 22d88853672eb0098336c47bfe63abff8b336443 Mon Sep 17 00:00:00 2001 From: Mark Vanderwiel Date: Wed, 25 Mar 2015 17:11:52 -0500 Subject: [PATCH] Add identity_uri_transform to help move to identity_uri Starting on the identity_uri blueprint. A difference between the public auth_uri and the admin identity_uri is that the identity_uri does not include the path/version (/v2.0). And the auth_uri has to modify the version depending upon the needs of the environment. There existed a helper routine called, auth_uri_transform, so to be consistent and make this easy to follow, I created a identity_uri_transform which simply removes the path/version from the uri given. This helper will then be used thru out the cookbooks to make the switch to the identity_uri very easy. I guess the alturnatives are messing with our generic endpoint definitions/methods, but since they are used for many different purposes, I think having another matching transform method is the right way to go here. Bumped version for adding new method which other cookbooks will depend upon. Change-Id: I035a4491945c600dea8feb317b357a1a69da28cd Implements: blueprint identity-uri --- libraries/uri.rb | 11 +++++++++++ metadata.rb | 2 +- spec/uri_spec.rb | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/libraries/uri.rb b/libraries/uri.rb index 10d21fbf..99d897ce 100644 --- a/libraries/uri.rb +++ b/libraries/uri.rb @@ -71,4 +71,15 @@ module ::Openstack # rubocop:disable Documentation auth_uri.gsub('/v2.0', '/v3') end end + + # Helper for creating identity_uri value for the auth_token section + # of component config files. + # The definition of identity is: the unversioned root + # admin identity endpoint e.g. https://localhost:35357/ + # This method will make sure the path is removed from the uri. + def identity_uri_transform(identity_uri) + uri = ::URI.parse ::URI.encode(identity_uri.to_s) + uri.path = '/' + uri.to_s + end end diff --git a/metadata.rb b/metadata.rb index d01b03fb..31fe1261 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ maintainer_email 'opscode-chef-openstack@googlegroups.com' license 'Apache 2.0' description 'Common OpenStack attributes, libraries and recipes.' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '11.0.0' +version '11.1.0' recipe 'openstack-common', 'Installs/Configures common recipes' recipe 'openstack-common::set_endpoints_by_interface', 'Set endpoints by interface' diff --git a/spec/uri_spec.rb b/spec/uri_spec.rb index 150671e1..e0c2f944 100644 --- a/spec/uri_spec.rb +++ b/spec/uri_spec.rb @@ -117,4 +117,19 @@ describe 'Openstack uri' do ).to eq(expected_auth_uri) end end + + describe '#identity_uri_transform' do + it 'removes the path segment from identity admin endpoint' do + expect( + subject.identity_uri_transform('http://localhost:35357/v2.0') + ).to eq('http://localhost:35357/') + end + + it 'does not effect a valid identity admin endpoint' do + identity_uri = 'http://localhost:35357/' + expect( + subject.identity_uri_transform(identity_uri) + ).to eq(identity_uri) + end + end end