From e6d89d06894eb97cd907208b35a8d5ff6e8cabf1 Mon Sep 17 00:00:00 2001 From: Mark Vanderwiel Date: Tue, 2 Dec 2014 12:32:54 -0600 Subject: [PATCH] Allow storwize private key without san_login and san_password Using The san_private_key by itself is a common use case. The current code requires the san_login and password to be set. This patch allows the key to be used without the login and password. Also removed some clutter comments from the conf template. Change-Id: Iea84c8310eec39481c115587219cdac35c9b3589 Closes-Bug: #1398469 --- CHANGELOG.md | 1 + attributes/default.rb | 1 + recipes/cinder-common.rb | 4 +++- spec/cinder_common_spec.rb | 14 ++++++++++--- templates/default/cinder.conf.erb | 35 +++---------------------------- 5 files changed, 19 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30f3eeb..e232970 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ This file is used to list changes made in each version of the openstack-block-st * Change to cinder v2 service and endpoint * Add support for san_password with ibm.storwize_svc.StorwizeSVCDriver * Add glance_api_version config option +* Allow san_private_key to be used instead of san_login for Storwize ## 10.0.0 * Upgrading to Juno diff --git a/attributes/default.rb b/attributes/default.rb index 54965bf..ab14392 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -164,6 +164,7 @@ default['openstack']['block-storage']['nfs']['nfs_sparsed_volumes'] = 'true' # Storwize/SVC Support default['openstack']['block-storage']['storwize']['san_ip'] = node['openstack']['block-storage']['san']['san_ip'] default['openstack']['block-storage']['storwize']['san_login'] = node['openstack']['block-storage']['san']['san_login'] +# If the key is set to nil, the san_login and san_password will be used. default['openstack']['block-storage']['storwize']['san_private_key'] = node['openstack']['block-storage']['san']['san_private_key'] default['openstack']['block-storage']['storwize']['storwize_svc_volpool_name'] = 'volpool' default['openstack']['block-storage']['storwize']['storwize_svc_vol_rsize'] = 2 diff --git a/recipes/cinder-common.rb b/recipes/cinder-common.rb index 2bc1c73..cf52a4c 100644 --- a/recipes/cinder-common.rb +++ b/recipes/cinder-common.rb @@ -47,7 +47,9 @@ end case node['openstack']['block-storage']['volume']['driver'] when 'cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver' - storwize_pass = get_password 'user', node['openstack']['block-storage']['storwize']['san_login'] + if node['openstack']['block-storage']['storwize']['san_private_key'].to_s.empty? + storwize_pass = get_password 'user', node['openstack']['block-storage']['storwize']['san_login'] + end when 'cinder.volume.drivers.solidfire.SolidFire' solidfire_pass = get_password 'user', node['openstack']['block-storage']['solidfire']['san_login'] when 'cinder.volume.drivers.ibm.ibmnas.IBMNAS_NFSDriver' diff --git a/spec/cinder_common_spec.rb b/spec/cinder_common_spec.rb index fdebf90..3fa9def 100644 --- a/spec/cinder_common_spec.rb +++ b/spec/cinder_common_spec.rb @@ -567,8 +567,6 @@ describe 'openstack-block-storage::cinder-common' do it 'has a default attribute' do %w(san_ip=127.0.0.1 - san_login=admin - san_password=test_pass san_private_key=/v7000_rsa storwize_svc_volpool_name=volpool storwize_svc_vol_rsize=2 @@ -588,7 +586,6 @@ describe 'openstack-block-storage::cinder-common' do it 'has a overridden attribute' do %w(san_ip - san_login san_private_key storwize_svc_volpool_name storwize_svc_vol_rsize @@ -606,6 +603,17 @@ describe 'openstack-block-storage::cinder-common' do end end + context 'storwize with login and password' do + it 'has a login and password' do + node.set['openstack']['block-storage']['storwize']['san_private_key'] = '' + %w(san_login=admin + san_password=test_pass + san_private_key=).each do |attr| + expect(chef_run).to render_file(file.name).with_content(/^#{attr}$/) + end + end + end + context 'storwize with iSCSI connection protocol' do before do node.set['openstack']['block-storage']['storwize']['storwize_svc_connection_protocol'] = 'iSCSI' diff --git a/templates/default/cinder.conf.erb b/templates/default/cinder.conf.erb index a7ce154..a6adf6d 100644 --- a/templates/default/cinder.conf.erb +++ b/templates/default/cinder.conf.erb @@ -737,48 +737,19 @@ nfs_sparsed_volumes=<%= node["openstack"]["block-storage"]["ibmnas"]["nfs_sparse ######## defined in cinder.volume.san ######## <% if @enabled_drivers.include?("cinder.volume.drivers.ibm.storwize_svc.StorwizeSVCDriver") %> - san_ip=<%= node["openstack"]["block-storage"]["storwize"]["san_ip"] %> #### (StrOpt) IP address of SAN controller +<% if node['openstack']['block-storage']['storwize']['san_private_key'].to_s.empty? %> san_login=<%= node["openstack"]["block-storage"]["storwize"]["san_login"] %> #### (StrOpt) Username for SAN controller -san_private_key=<%= node["openstack"]["block-storage"]["storwize"]["san_private_key"] %> -#### (StrOpt) Filename of private key to use for SSH authentication - san_password=<%= @storwize_pass %> #### (StrOpt) Password for SAN controller +<% end %> - -<% else %> -# san_thin_provision=true -#### (BoolOpt) Use thin provisioning for SAN volumes? - -# san_ip= -#### (StrOpt) IP address of SAN controller - -# san_login=admin -#### (StrOpt) Username for SAN controller - -# san_password= -#### (StrOpt) Password for SAN controller - -# san_private_key= +san_private_key=<%= node["openstack"]["block-storage"]["storwize"]["san_private_key"] %> #### (StrOpt) Filename of private key to use for SSH authentication - -# san_clustername= -#### (StrOpt) Cluster name to use for creating volumes - -# san_ssh_port=22 -#### (IntOpt) SSH port to use with SAN - -# san_is_local=false -#### (BoolOpt) Execute commands locally instead of over SSH; use if the -#### volume service is running on the SAN device - -# san_zfs_volume_base=rpool/ -#### (StrOpt) The ZFS path under which to create zvols for volumes. <% end %> <% if @enabled_drivers.include?("cinder.volume.drivers.solidfire.SolidFire") %>