From 2ea252646d96ab7d1ce738ec627142740494967f Mon Sep 17 00:00:00 2001 From: Lan Qi song Date: Thu, 7 May 2015 21:37:59 +0800 Subject: [PATCH] Make enable v1 and v2 api option configurable Change-Id: I40efdc8c31dc38f214cc300cc68279af1b614089 Closes-Bug: #1452730 --- README.md | 2 ++ attributes/default.rb | 6 ++++++ spec/cinder_common_spec.rb | 13 +++++++++++-- templates/default/cinder.conf.erb | 4 ++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 16c1c1a..42f5b0b 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,8 @@ Cinder attributes * `openstack["block-storage"]["rpc_conn_pool_size"]` - Size of RPC connection pool * `openstack["block-storage"]["rpc_response_timeout"]` - Seconds to wait for a response from call or multicall * `openstack["block-storage"]["misc_cinder"] - Array of strings to be added to cinder.conf for misc options, e.g. ['# Comment', 'key=value'] +* `openstack["block-storage"]["enable_v1_api"]` - Whether to enable cinder v1 api or not. +* `openstack["block-storage"]["enable_v2_api"]` - Whether to enable cinder v2 api or not. ### Storwize/SVC attributes ### * `openstack['block-storage']['san']['san_ip'] - IP address of SAN controller diff --git a/attributes/default.rb b/attributes/default.rb index 4aaf3aa..91f1d48 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -322,6 +322,12 @@ default['openstack']['block-storage']['misc_cinder'] = [] default['openstack']['block-storage']['lock_path'] = "#{node['openstack']['block-storage']['volume']['state_path']}/lock" +# Whether to enable cinder v1 api or not +default['openstack']['block-storage']['enable_v1_api'] = 'False' + +# Whether to enable cinder v2 api or not +default['openstack']['block-storage']['enable_v2_api'] = 'True' + case platform_family when 'fedora', 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this # operating system user and group names diff --git a/spec/cinder_common_spec.rb b/spec/cinder_common_spec.rb index c92f09c..d6d175f 100644 --- a/spec/cinder_common_spec.rb +++ b/spec/cinder_common_spec.rb @@ -341,8 +341,17 @@ describe 'openstack-block-storage::cinder-common' do end it 'has default api version set' do - [/^enable_v1_api=false$/, - /^enable_v2_api=true$/].each do |line| + [/^enable_v1_api=False$/, + /^enable_v2_api=True$/].each do |line| + expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) + end + end + + it 'has override api version set' do + node.set['openstack']['block-storage']['enable_v1_api'] = 'True' + node.set['openstack']['block-storage']['enable_v2_api'] = 'False' + [/^enable_v1_api=True$/, + /^enable_v2_api=False$/].each do |line| expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line) end end diff --git a/templates/default/cinder.conf.erb b/templates/default/cinder.conf.erb index 2097e48..67e6efd 100644 --- a/templates/default/cinder.conf.erb +++ b/templates/default/cinder.conf.erb @@ -53,10 +53,10 @@ log_file = /var/log/cinder/cinder.log #### (StrOpt) File name for the paste.deploy config for cinder-api # DEPRECATED: Deploy v1 of the Cinder API. (boolean value) -enable_v1_api=false +enable_v1_api=<%= node["openstack"]["block-storage"]["enable_v1_api"] %> # Deploy v2 of the Cinder API. (boolean value) -enable_v2_api=true +enable_v2_api=<%= node["openstack"]["block-storage"]["enable_v2_api"] %> # pybasedir=/usr/lib/python/site-packages #### (StrOpt) Directory where the cinder python module is installed