From 6d369703bb1778a11cf55fe679150928cb553cf6 Mon Sep 17 00:00:00 2001 From: Matthias Bastian Date: Tue, 24 Apr 2018 16:13:06 +0200 Subject: [PATCH] Set optional API version-related environment vars If OSC's default values for API versions are not suitable, this change allows overriding them using environment variables. This applies to the compute, network, image, volume, identity and object services. Change-Id: I5447be16d71a3baa4224dae222d710be9d49b759 --- manifests/auth_file.pp | 30 +++++++++++++++++-- .../openstack_extras_auth_file_spec.rb | 15 ++++++++-- templates/openrc.erb | 17 +++++++++++ 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/manifests/auth_file.pp b/manifests/auth_file.pp index 46653c1..c3f9e86 100644 --- a/manifests/auth_file.pp +++ b/manifests/auth_file.pp @@ -93,9 +93,29 @@ # (optional) Authentication type to load. # Default to undef. # +# [*compute_api_version*] +# (optional) Compute API version to use. +# Defaults to undef. +# +# [*network_api_version*] +# (optional) Network API version to use. +# Defaults to undef. +# +# [*image_api_version*] +# (optional) Image API version to use. +# Defaults to undef. +# +# [*volume_api_version*] +# (optional) Volume API version to use. +# Defaults to undef. +# # [*identity_api_version*] # (optional) Identity API version to use. -# Defaults to '3'. +# Defaults to undef. +# +# [*object_api_version*] +# (optional) Object API version to use. +# Defaults to undef. # class openstack_extras::auth_file( @@ -120,7 +140,13 @@ class openstack_extras::auth_file( $neutron_endpoint_type = 'publicURL', $auth_strategy = 'keystone', $path = '/root/openrc', - $identity_api_version = '3', + $compute_api_version = undef, + $network_api_version = undef, + $image_api_version = undef, + $volume_api_version = undef, + $identity_api_version = undef, + $object_api_version = undef, + ) { if ! $password { fail('You must specify a password for openstack_extras::auth_file') diff --git a/spec/classes/openstack_extras_auth_file_spec.rb b/spec/classes/openstack_extras_auth_file_spec.rb index 3cb0480..3c0c074 100644 --- a/spec/classes/openstack_extras_auth_file_spec.rb +++ b/spec/classes/openstack_extras_auth_file_spec.rb @@ -26,7 +26,6 @@ describe 'openstack_extras::auth_file' do 'export KEYSTONE_ENDPOINT_TYPE=\'publicURL\'', 'export NOVA_ENDPOINT_TYPE=\'publicURL\'', 'export NEUTRON_ENDPOINT_TYPE=\'publicURL\'', - 'export OS_IDENTITY_API_VERSION=\'3\'', ]) end end @@ -54,7 +53,12 @@ describe 'openstack_extras::auth_file' do :auth_strategy => 'no_auth', :user_domain => 'anotherdomain', :project_domain => 'anotherdomain', - :identity_api_version => '3.1', + :compute_api_version => '2.1', + :network_api_version => '2.0', + :image_api_version => '2', + :volume_api_version => '2', + :identity_api_version => '3', + :object_api_version => '1', } end @@ -79,7 +83,12 @@ describe 'openstack_extras::auth_file' do 'export KEYSTONE_ENDPOINT_TYPE=\'internalURL\'', 'export NOVA_ENDPOINT_TYPE=\'internalURL\'', 'export NEUTRON_ENDPOINT_TYPE=\'internalURL\'', - 'export OS_IDENTITY_API_VERSION=\'3.1\'', + 'export OS_COMPUTE_API_VERSION=\'2.1\'', + 'export OS_NETWORK_API_VERSION=\'2.0\'', + 'export OS_IMAGE_API_VERSION=\'2\'', + 'export OS_VOLUME_API_VERSION=\'2\'', + 'export OS_IDENTITY_API_VERSION=\'3\'', + 'export OS_OBJECT_API_VERSION=\'1\'', ]) end end diff --git a/templates/openrc.erb b/templates/openrc.erb index 3a9b508..83d9dcd 100644 --- a/templates/openrc.erb +++ b/templates/openrc.erb @@ -31,4 +31,21 @@ export GLANCE_ENDPOINT_TYPE='<%= @glance_endpoint_type %>' export KEYSTONE_ENDPOINT_TYPE='<%= @keystone_endpoint_type %>' export NOVA_ENDPOINT_TYPE='<%= @nova_endpoint_type %>' export NEUTRON_ENDPOINT_TYPE='<%= @neutron_endpoint_type %>' +<% if @compute_api_version -%> +export OS_COMPUTE_API_VERSION='<%= @compute_api_version %>' +<% end -%> +<% if @network_api_version -%> +export OS_NETWORK_API_VERSION='<%= @network_api_version %>' +<% end -%> +<% if @image_api_version -%> +export OS_IMAGE_API_VERSION='<%= @image_api_version %>' +<% end -%> +<% if @volume_api_version -%> +export OS_VOLUME_API_VERSION='<%= @volume_api_version %>' +<% end -%> +<% if @identity_api_version -%> export OS_IDENTITY_API_VERSION='<%= @identity_api_version %>' +<% end -%> +<% if @object_api_version -%> +export OS_OBJECT_API_VERSION='<%= @object_api_version %>' +<% end -%>