diff --git a/manifests/profile/base/cinder/volume.pp b/manifests/profile/base/cinder/volume.pp index fa7f485fc..5dd745163 100644 --- a/manifests/profile/base/cinder/volume.pp +++ b/manifests/profile/base/cinder/volume.pp @@ -1,4 +1,4 @@ -# Copyright 2016 Red Hat, Inc. +# Copyright 2022 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -54,6 +54,10 @@ # (Optional) Whether to enable the xtremio backend # Defaults to false # +# [*cinder_enable_ibm_svf_backend*] +# (Optional) Whether to enable the ibm_svf backend +# Defaults to false +# # [*cinder_enable_iscsi_backend*] # (Optional) Whether to enable the iscsi backend # Defaults to true @@ -127,6 +131,7 @@ class tripleo::profile::base::cinder::volume ( $cinder_enable_dellemc_powerstore_backend = false, $cinder_enable_dellemc_vnx_backend = false, $cinder_enable_dellemc_xtremio_backend = false, + $cinder_enable_ibm_svf_backend = false, $cinder_enable_iscsi_backend = true, $cinder_enable_netapp_backend = false, $cinder_enable_nfs_backend = false, @@ -256,6 +261,14 @@ class tripleo::profile::base::cinder::volume ( $cinder_dellemc_xtremio_backend_name = undef } + if $cinder_enable_ibm_svf_backend { + include tripleo::profile::base::cinder::volume::ibm_svf + $cinder_ibm_svf_backend_name = lookup('cinder::backend::ibm_svf::volume_backend_name', + undef, undef, 'tripleo_ibm_svf') + } else { + $cinder_ibm_svf_backend_name = undef + } + if $cinder_enable_iscsi_backend { include tripleo::profile::base::cinder::volume::iscsi $cinder_iscsi_backend_name = lookup('cinder::backend::iscsi::volume_backend_name', undef, undef, 'tripleo_iscsi') @@ -326,6 +339,7 @@ class tripleo::profile::base::cinder::volume ( $cinder_dellemc_powerstore_backend_name, $cinder_dellemc_vnx_backend_name, $cinder_dellemc_xtremio_backend_name, + $cinder_ibm_svf_backend_name, $cinder_netapp_backend_name, $cinder_nfs_backend_name, $cinder_user_enabled_backends, diff --git a/manifests/profile/base/cinder/volume/ibm_svf.pp b/manifests/profile/base/cinder/volume/ibm_svf.pp new file mode 100644 index 000000000..b33b3b7a3 --- /dev/null +++ b/manifests/profile/base/cinder/volume/ibm_svf.pp @@ -0,0 +1,60 @@ +# +# == Class: tripleo::profile::base::cinder::volume::ibm_svf +# +# Cinder Volume IBM Spectrum Virtualize family (Svf) profile for tripleo +# +# === Parameters +# +# [*backend_name*] +# (Optional) List of names given to the Cinder backend stanza. +# Defaults to lookup('cinder::backend:ibm_svf::volume_backend_name', undef, undef, +# ['tripleo_ibm_svf']) +# +# [*multi_config*] +# (Optional) A config hash when multiple backends are used. +# Defaults to lookup('cinder::backend::ibm_svf::volume_multi_config', undef, undef, {}) +# +# [*step*] +# (Optional) The current step in deployment. See tripleo-heat-templates +# for more details. +# Defaults to Integer(lookup('step')) +# +class tripleo::profile::base::cinder::volume::ibm_svf ( + $backend_name = lookup('cinder::backend::ibm_svf::volume_backend_name', undef, undef, ['tripleo_ibm_svf']), + $multi_config = lookup('cinder::backend::ibm_svf::volume_multi_config', undef, undef, {}), + $step = Integer(lookup('step')), +) { + include tripleo::profile::base::cinder::volume + # NOTE: Svf was earlier called as storwize/svc driver, so the cinder + # configuration parameters were named accordingly. + if $step >= 4 { + $backend_defaults = { + 'CinderSvfAvailabilityZone' => lookup('cinder::backend::ibm_svf::backend_availability_zone', undef, undef, undef), + 'CinderSvfSanIp' => lookup('cinder::backend::ibm_svf::san_ip', undef, undef, undef), + 'CinderSvfSanLogin' => lookup('cinder::backend::ibm_svf::san_login', undef, undef, undef), + 'CinderSvfSanPassword' => lookup('cinder::backend::ibm_svf::san_password', undef, undef, undef), + 'CinderSvfAllowTenantQos' => lookup('cinder::backend::ibm_svf::storwize_svc_allow_tenant_qos', undef, undef, undef), + 'CinderSvfConnectionProtocol' => lookup('cinder::backend::ibm_svf::storwize_svc_connection_protocol', undef, undef, undef), + 'CinderSvfIscsiChapEnabled' => lookup('cinder::backend::ibm_svf::storwize_svc_iscsi_chap_enabled', undef, undef, undef), + 'CinderSvfRetainAuxVolume' => lookup('cinder::backend::ibm_svf::storwize_svc_retain_aux_volume', undef, undef, undef), + 'CinderSvfVolumePoolName' => lookup('cinder::backend::ibm_svf::storwize_svc_volpool_name', undef, undef, undef), + } + + any2array($backend_name).each |String $backend| { + $backend_config = merge($backend_defaults, pick($multi_config[$backend], {})) + + create_resources('cinder::backend::ibm_svf', { $backend => delete_undef_values({ + 'backend_availability_zone' => $backend_config['CinderSvfAvailabilityZone'], + 'san_ip' => $backend_config['CinderSvfSanIp'], + 'san_login' => $backend_config['CinderSvfSanLogin'], + 'san_password' => $backend_config['CinderSvfSanPassword'], + 'storwize_svc_allow_tenant_qos' => $backend_config['CinderSvfAllowTenantQos'], + 'storwize_svc_connection_protocol' => $backend_config['CinderSvfConnectionProtocol'], + 'storwize_svc_iscsi_chap_enabled' => $backend_config['CinderSvfIscsiChapEnabled'], + 'storwize_svc_retain_aux_volume' => $backend_config['CinderSvfRetainAuxVolume'], + 'storwize_svc_volpool_name' => $backend_config['CinderSvfVolumePoolName'], + })}) + } + } + +} diff --git a/releasenotes/notes/Add-support-for-ibm_svf-driver-01924479bb11063c.yaml b/releasenotes/notes/Add-support-for-ibm_svf-driver-01924479bb11063c.yaml new file mode 100644 index 000000000..70ca1f3f0 --- /dev/null +++ b/releasenotes/notes/Add-support-for-ibm_svf-driver-01924479bb11063c.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Add support for Cinder IBM Spectrum virtualize family (Svf) driver. diff --git a/spec/classes/tripleo_profile_base_cinder_volume_ibm_svf_spec.rb b/spec/classes/tripleo_profile_base_cinder_volume_ibm_svf_spec.rb new file mode 100644 index 000000000..66003afe9 --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_volume_ibm_svf_spec.rb @@ -0,0 +1,78 @@ +# +# Copyright (C) 2016 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# + +require 'spec_helper' + +describe 'tripleo::profile::base::cinder::volume::ibm_svf' do + shared_examples_for 'tripleo::profile::base::cinder::volume::ibm_svf' do + before :each do + facts.merge!({ :step => params[:step] }) + end + + context 'with step less than 4' do + let(:params) { { :step => 3 } } + + it 'should do nothing' do + is_expected.to contain_class('tripleo::profile::base::cinder::volume::ibm_svf') + is_expected.to contain_class('tripleo::profile::base::cinder::volume') + is_expected.to contain_class('tripleo::profile::base::cinder') + is_expected.to_not contain_cinder__backend__ibm_svf('tripleo_ibm_svf') + end + end + + context 'with step 4' do + let(:params) { { + :step => 4, + } } + + it 'should trigger complete configuration' do + is_expected.to contain_cinder__backend__ibm_svf('tripleo_ibm_svf') + end + + context 'with multiple backends' do + let(:params) { { + :backend_name => ['tripleo_ibm_svf_1', 'tripleo_ibm_svf_2'], + :multi_config => { 'tripleo_ibm_svf_1' => { + 'CinderSvfAllowTenantQos' => 'true', + }, + 'tripleo_ibm_svf_2' => { + 'CinderSvfConnectionProtocol' => 'FC', + }, + }, + :step => 4, + } } + it 'should configure each backend' do + is_expected.to contain_cinder__backend__ibm_svf('tripleo_ibm_svf_1') + is_expected.to contain_cinder_config('tripleo_ibm_svf_1/storwize_svc_allow_tenant_qos').with_value('true') + is_expected.to contain_cinder_config('tripleo_ibm_svf_1/volume_driver').with_value('cinder.volume.drivers.ibm.storwize_svc.storwize_svc_iscsi.StorwizeSVCISCSIDriver') + is_expected.to contain_cinder__backend__ibm_svf('tripleo_ibm_svf_2') + is_expected.to contain_cinder_config('tripleo_ibm_svf_2/storwize_svc_allow_tenant_qos').with_value('') + is_expected.to contain_cinder_config('tripleo_ibm_svf_2/volume_driver').with_value('cinder.volume.drivers.ibm.storwize_svc.storwize_svc_fc.StorwizeSVCFCDriver') + end + end + end + end + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge(OSDefaults.get_facts({ :hostname => 'node.example.com' })) + end + + it_behaves_like 'tripleo::profile::base::cinder::volume::ibm_svf' + end + end +end diff --git a/spec/classes/tripleo_profile_base_cinder_volume_spec.rb b/spec/classes/tripleo_profile_base_cinder_volume_spec.rb index 94141b430..432a79db1 100644 --- a/spec/classes/tripleo_profile_base_cinder_volume_spec.rb +++ b/spec/classes/tripleo_profile_base_cinder_volume_spec.rb @@ -302,6 +302,34 @@ describe 'tripleo::profile::base::cinder::volume' do end end + context 'with only ibm_svf' do + before :each do + params.merge!({ + :cinder_enable_ibm_svf_backend => true, + :cinder_enable_iscsi_backend => false, + }) + end + it 'should configure only ibm_svf' do + is_expected.to contain_class('tripleo::profile::base::cinder::volume::ibm_svf') + is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::iscsi') + is_expected.to contain_class('tripleo::profile::base::cinder::volume') + is_expected.to contain_class('tripleo::profile::base::cinder') + is_expected.to contain_class('cinder::volume') + is_expected.to contain_class('cinder::backends').with( + :enabled_backends => ['tripleo_ibm_svf'] + ) + end + context 'with multiple ibm_svf backends' do + # Step 5's hiera specifies two ibm_svf backend names + let(:params) { { :step => 5 } } + it 'should enable each backend' do + is_expected.to contain_class('cinder::backends').with( + :enabled_backends => ['tripleo_ibm_svf_1', 'tripleo_ibm_svf_2'] + ) + end + end + end + context 'with only netapp' do before :each do params.merge!({ @@ -396,14 +424,15 @@ describe 'tripleo::profile::base::cinder::volume' do }) end it 'should configure only user backend' do - is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::iscsi') is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::pure') - is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::dellemc_sc') - is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::dellemc_xtremio') is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::dellsc') + is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::dellemc_sc') is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::dellemc_powerflex') is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::dellemc_powermax') is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::dellemc_powerstore') + is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::dellemc_xtremio') + is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::ibm_svf') + is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::iscsi') is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::netapp') is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::nfs') is_expected.to_not contain_class('tripleo::profile::base::cinder::volume::rbd') @@ -419,28 +448,30 @@ describe 'tripleo::profile::base::cinder::volume' do context 'with all tripleo backends' do before :each do params.merge!({ - :cinder_enable_nfs_backend => true, - :cinder_enable_rbd_backend => true, - :cinder_enable_iscsi_backend => true, :cinder_enable_pure_backend => true, + :cinder_enable_dellsc_backend => true, + :cinder_enable_dellemc_sc_backend => true, :cinder_enable_dellemc_powerflex_backend => true, :cinder_enable_dellemc_powermax_backend => true, :cinder_enable_dellemc_powerstore_backend => true, - :cinder_enable_dellemc_sc_backend => true, - :cinder_enable_dellsc_backend => true, :cinder_enable_dellemc_xtremio_backend => true, + :cinder_enable_ibm_svf_backend => true, + :cinder_enable_iscsi_backend => true, :cinder_enable_netapp_backend => true, + :cinder_enable_nfs_backend => true, + :cinder_enable_rbd_backend => true, }) end it 'should configure all backends' do - is_expected.to contain_class('tripleo::profile::base::cinder::volume::iscsi') is_expected.to contain_class('tripleo::profile::base::cinder::volume::pure') - is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellemc_sc') - is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellemc_xtremio') is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellsc') + is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellemc_sc') is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellemc_powerflex') is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellemc_powermax') is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellemc_powerstore') + is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellemc_xtremio') + is_expected.to contain_class('tripleo::profile::base::cinder::volume::ibm_svf') + is_expected.to contain_class('tripleo::profile::base::cinder::volume::iscsi') is_expected.to contain_class('tripleo::profile::base::cinder::volume::netapp') is_expected.to contain_class('tripleo::profile::base::cinder::volume::nfs') is_expected.to contain_class('tripleo::profile::base::cinder::volume::rbd') @@ -448,8 +479,20 @@ describe 'tripleo::profile::base::cinder::volume' do is_expected.to contain_class('tripleo::profile::base::cinder') is_expected.to contain_class('cinder::volume') is_expected.to contain_class('cinder::backends').with( - :enabled_backends => ['tripleo_iscsi', 'tripleo_ceph', 'tripleo_pure', 'tripleo_dellsc', 'tripleo_dellemc_sc','tripleo_dellemc_powerflex', - 'tripleo_dellemc_powermax', 'tripleo_dellemc_powerstore','tripleo_dellemc_xtremio','tripleo_netapp','tripleo_nfs'] + :enabled_backends => [ + 'tripleo_iscsi', + 'tripleo_ceph', + 'tripleo_pure', + 'tripleo_dellsc', + 'tripleo_dellemc_sc', + 'tripleo_dellemc_powerflex', + 'tripleo_dellemc_powermax', + 'tripleo_dellemc_powerstore', + 'tripleo_dellemc_xtremio', + 'tripleo_ibm_svf', + 'tripleo_netapp', + 'tripleo_nfs' + ] ) end end diff --git a/spec/fixtures/hieradata/default.yaml b/spec/fixtures/hieradata/default.yaml index 7442e58b2..7285195e4 100644 --- a/spec/fixtures/hieradata/default.yaml +++ b/spec/fixtures/hieradata/default.yaml @@ -67,6 +67,11 @@ cinder::backend::dellsc_iscsi::dell_sc_ssn: '64720' cinder::backend::emc_vnx::san_ip: '127.0.0.2' cinder::backend::emc_vnx::san_password: 'password' cinder::backend::emc_vnx::storage_vnx_pool_names: 'emc-storage-pool' +cinder::backend::ibm_svf::san_ip: '127.0.0.5' +cinder::backend::ibm_svf::san_login: 'ibmsvf' +cinder::backend::ibm_svf::san_password: 'password' +cinder::backend::ibm_svf::storwize_svc_volpool_name: 'svf-pool' +cinder::backend::ibm_svf::storwize_svc_connection_protocol: 'iSCSI' cinder::backend::netapp::netapp_login: 'netapp' cinder::backend::netapp::netapp_password: 'password' cinder::backend::netapp::netapp_server_hostname: '127.0.0.2' diff --git a/spec/fixtures/hieradata/step5.yaml b/spec/fixtures/hieradata/step5.yaml index e30962da0..32c46d56f 100644 --- a/spec/fixtures/hieradata/step5.yaml +++ b/spec/fixtures/hieradata/step5.yaml @@ -31,6 +31,9 @@ cinder::backend::emc_vnx::volume_backend_name: cinder::backend::dellemc_xtremio::volume_backend_name: - 'tripleo_dellemc_xtremio_1' - 'tripleo_dellemc_xtremio_2' +cinder::backend::ibm_svf::volume_backend_name: + - 'tripleo_ibm_svf_1' + - 'tripleo_ibm_svf_2' cinder::backend::netapp::volume_backend_name: - 'tripleo_netapp_1' - 'tripleo_netapp_2'