From 03556cd333afaa19f58825789c2429793ec5eff5 Mon Sep 17 00:00:00 2001 From: newptone Date: Wed, 17 Apr 2013 22:40:33 +0800 Subject: [PATCH] Add param use_no_cache to the openstack::auth_file Fix bug 1169993 This patch contains: * use_no_cache param will add BooleanVar OS_NO_CACHE to the openrc, in the default its value is true. * add the openstack_auth_file_spec for test. Change-Id: I3885bccb4c06bbe652f7fee1d5db83913d8cd79b --- manifests/auth_file.pp | 4 +- spec/classes/openstack_auth_file_spec.rb | 55 ++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 spec/classes/openstack_auth_file_spec.rb diff --git a/manifests/auth_file.pp b/manifests/auth_file.pp index fb99281..c54e58b 100644 --- a/manifests/auth_file.pp +++ b/manifests/auth_file.pp @@ -8,11 +8,13 @@ class openstack::auth_file( $controller_node = '127.0.0.1', $keystone_admin_token = 'keystone_admin_token', $admin_user = 'admin', - $admin_tenant = 'admin' + $admin_tenant = 'admin', + $use_no_cache = 'true' ) { file { '/root/openrc': content => " + export OS_NO_CACHE=${use_no_cache} export OS_TENANT_NAME=${admin_tenant} export OS_USERNAME=${admin_user} export OS_PASSWORD='${admin_password}' diff --git a/spec/classes/openstack_auth_file_spec.rb b/spec/classes/openstack_auth_file_spec.rb new file mode 100644 index 0000000..b0b195b --- /dev/null +++ b/spec/classes/openstack_auth_file_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper' + +describe 'openstack::auth_file' do + + describe "when only passing required class parameters" do + + let :params do + { :admin_password => 'admin' } + end + + it 'should create a openrc file' do + should contain_file('/root/openrc').with_content( + ' + export OS_NO_CACHE=true + export OS_TENANT_NAME=admin + export OS_USERNAME=admin + export OS_PASSWORD=\'admin\' + export OS_AUTH_URL="http://127.0.0.1:5000/v2.0/" + export OS_AUTH_STRATEGY=keystone + export SERVICE_TOKEN=keystone_admin_token + export SERVICE_ENDPOINT=http://127.0.0.1:35357/v2.0/ + ' + ) + end + end + + describe 'when overridding' do + + let :params do + { + :admin_password => 'nova', + :controller_node => '127.0.0.2', + :keystone_admin_token => 'keystone', + :admin_user => 'nova', + :admin_tenant => 'nova', + :use_no_cache => 'false', + } + end + + it 'should create a openrc file' do + should contain_file('/root/openrc').with_content( + ' + export OS_NO_CACHE=false + export OS_TENANT_NAME=nova + export OS_USERNAME=nova + export OS_PASSWORD=\'nova\' + export OS_AUTH_URL="http://127.0.0.2:5000/v2.0/" + export OS_AUTH_STRATEGY=keystone + export SERVICE_TOKEN=keystone + export SERVICE_ENDPOINT=http://127.0.0.2:35357/v2.0/ + ' + ) + end + end +end