From 2859570b81e0afd4742225a191853edb142c7e27 Mon Sep 17 00:00:00 2001 From: Alan Meadows Date: Sat, 28 Jun 2014 14:10:06 -0700 Subject: [PATCH] Allow file_upload_temp_dir override This adds the ability to overide the file_upload_temp_dir setting in django which is usually '/tmp' by default but may not be appropriate for all installations Change-Id: Idebae5e0ec2249868f5ce411a7f798a7584fa40a --- CHANGELOG.md | 3 +-- attributes/default.rb | 2 ++ spec/server_spec.rb | 13 +++++++++++++ templates/default/local_settings.py.erb | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bb5998..2a0d392 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,10 +14,9 @@ This file is used to list changes made in each version of the openstack-dashboar * Add sensitive flag to private key and certificate file resources * Add hash algorithm option to local_settings * Update user group for local_settings from root to horizon user group - * Bump Chef gem to 11.16 - * Add sensitive flag to local_settings file resource +* allow override of the temporary directory used for file uploads ## 9.1 * python_packages database client attributes have been moved to the -common cookbook diff --git a/attributes/default.rb b/attributes/default.rb index 4f4dfc8..03a56dd 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -147,6 +147,8 @@ default['openstack']['dashboard']['session_backend'] = 'memcached' default['openstack']['dashboard']['ssl_offload'] = false default['openstack']['dashboard']['plugins'] = nil +default['openstack']['dashboard']['file_upload_temp_dir'] = nil + default['openstack']['dashboard']['error_log'] = 'openstack-dashboard-error.log' default['openstack']['dashboard']['access_log'] = 'openstack-dashboard-access.log' diff --git a/spec/server_spec.rb b/spec/server_spec.rb index 4e59b4d..1062b06 100644 --- a/spec/server_spec.rb +++ b/spec/server_spec.rb @@ -221,6 +221,19 @@ describe 'openstack-dashboard::server' do end end + context 'temp dir override' do + context 'temp dir is nil' do + it 'does not override temp dir when it is nil' do + node.set['openstack']['dashboard']['file_upload_temp_dir'] = nil + expect(chef_run).not_to render_file(file.name).with_content(/^FILE_UPLOAD_TEMP_DIR =/) + end + it 'does override temp dir when it is not nil' do + node.set['openstack']['dashboard']['file_upload_temp_dir'] = '/foobar' + expect(chef_run).to render_file(file.name).with_content(/^FILE_UPLOAD_TEMP_DIR = "\/foobar"$/) + end + end + end + context 'ssl settings' do context 'use_ssl enabled' do before do diff --git a/templates/default/local_settings.py.erb b/templates/default/local_settings.py.erb index 7134a6e..7c1c5f4 100644 --- a/templates/default/local_settings.py.erb +++ b/templates/default/local_settings.py.erb @@ -611,3 +611,7 @@ mod.INSTALLED_APPS += ('<%= p %>', ) <% end %> <% end %> +# define a custom tmp upload directory (override /tmp) +<% if node["openstack"]["dashboard"]["file_upload_temp_dir"] %> +FILE_UPLOAD_TEMP_DIR = "<%= node["openstack"]["dashboard"]["file_upload_temp_dir"] %>" +<% end %>