From 037996d16a4e2aaa3eb9127dbec43acdc7e169cb Mon Sep 17 00:00:00 2001 From: rajinir Date: Thu, 23 Apr 2020 16:40:49 -0500 Subject: [PATCH] Support for Dell EMC SC Volume Config Added support for SC volume config options. Supports both iSCSI and FC drivers. Supports deploying multiple instances of the cinder::backend::dellemc_sc backend (e.g. one iscsi + one fc, multiple iscsi, etc.). Change-Id: I2f441a9df5bda4e1c646b3259d233f760fd3e742 (cherry picked from commit bd15ac0a1f258363d947bff88ac8d8944b57d8da) --- manifests/profile/base/cinder/volume.pp | 13 +++ .../profile/base/cinder/volume/dellemc_sc.pp | 87 +++++++++++++++++++ .../notes/sc-driver-a428e372280c44e6.yaml | 5 ++ .../tripleo_profile_base_cinder_sc_spec.rb | 72 +++++++++++++++ ...tripleo_profile_base_cinder_volume_spec.rb | 50 +++++++++-- spec/fixtures/hieradata/step5.yaml | 3 + 6 files changed, 221 insertions(+), 9 deletions(-) create mode 100644 manifests/profile/base/cinder/volume/dellemc_sc.pp create mode 100644 releasenotes/notes/sc-driver-a428e372280c44e6.yaml create mode 100644 spec/classes/tripleo_profile_base_cinder_sc_spec.rb diff --git a/manifests/profile/base/cinder/volume.pp b/manifests/profile/base/cinder/volume.pp index d0a59100e..f2973beda 100644 --- a/manifests/profile/base/cinder/volume.pp +++ b/manifests/profile/base/cinder/volume.pp @@ -26,6 +26,10 @@ # (Optional) Whether to enable the delsc backend # Defaults to false # +# [*cinder_enable_dellemc_sc_backend*] +# (Optional) Whether to enable the sc backend +# Defaults to false +# # [*cinder_enable_dellemc_unity_backend*] # (Optional) Whether to enable the unity backend # Defaults to false @@ -126,6 +130,7 @@ class tripleo::profile::base::cinder::volume ( $cinder_enable_pure_backend = false, $cinder_enable_dellsc_backend = false, + $cinder_enable_dellemc_sc_backend = false, $cinder_enable_dellemc_unity_backend = false, $cinder_enable_dellemc_powermax_backend = false, $cinder_enable_dellemc_vmax_iscsi_backend = false, @@ -200,6 +205,13 @@ class tripleo::profile::base::cinder::volume ( $cinder_dellsc_backend_name = undef } + if $cinder_enable_dellemc_sc_backend { + include tripleo::profile::base::cinder::volume::dellemc_sc + $cinder_dellemc_sc_backend_name = hiera('cinder::backend::dellemc_sc::volume_backend_name', 'tripleo_dellemc_sc') + } else { + $cinder_dellemc_sc_backend_name = undef + } + if $cinder_enable_dellemc_unity_backend { include ::tripleo::profile::base::cinder::volume::dellemc_unity $cinder_dellemc_unity_backend_name = hiera('cinder::backend::dellemc_unity::volume_backend_name', 'tripleo_dellemc_unity') @@ -335,6 +347,7 @@ class tripleo::profile::base::cinder::volume ( $cinder_pure_backend_name, $cinder_dellps_backend_name, $cinder_dellsc_backend_name, + $cinder_dellemc_sc_backend_name, $cinder_dellemc_unity_backend_name, $cinder_dellemc_powermax_backend_name, $cinder_dellemc_vmax_iscsi_backend_name, diff --git a/manifests/profile/base/cinder/volume/dellemc_sc.pp b/manifests/profile/base/cinder/volume/dellemc_sc.pp new file mode 100644 index 000000000..60186edff --- /dev/null +++ b/manifests/profile/base/cinder/volume/dellemc_sc.pp @@ -0,0 +1,87 @@ +# Copyright (c) 2020 Dell Inc, or its subsidiaries. +# +# 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. +# +# == Class: tripleo::profile::base::cinder::volume::dellemc_sc +# +# Cinder Volume dellemc_sc profile for tripleo +# +# === Parameters +# +# [*backend_name*] +# (Optional) Name given to the Cinder backend stanza +# Defaults to 'tripleo_dellemc_sc' +# +# [*multi_config*] +# (Optional) A config hash when multiple backends are used. +# Defaults to hiera('cinder::backend::dellemc_sc::volume_multi_config', {}) +# +# [*step*] +# (Optional) The current step in deployment. See tripleo-heat-templates +# for more details. +# Defaults to hiera('step') +# +class tripleo::profile::base::cinder::volume::dellemc_sc ( + $backend_name = hiera('cinder::backend::dellemc_sc::volume_backend_name', ['tripleo_dellemc_sc']), + $multi_config = hiera('cinder::backend::dellemc_sc::volume_multi_config', {}), + $step = Integer(hiera('step')), +) { + include tripleo::profile::base::cinder::volume + + if $step >= 4 { + + $backend_defaults = { + 'CinderSCAvailabilityZone' => hiera('cinder::backend::dellemc_sc::backend_availability_zone', undef), + 'CinderSCSanIp' => hiera('cinder::backend::dellemc_sc::san_ip', undef), + 'CinderSCSanLogin' => hiera('cinder::backend::dellemc_sc::san_login', undef), + 'CinderSCSanPassword' => hiera('cinder::backend::dellemc_sc::san password', undef), + 'CinderSCStorageProtocol' => hiera('cinder::backend::dellemc_sc::sc_storage_protocol', undef), + 'CinderSCSSN' => hiera('cinder::backend::dellemc_sc::dell_sc_ssn', undef), + 'CinderSCTargetIpAddress' => hiera('cinder::backend::dellemc_sc::iscsi_ip_address', undef), + 'CinderSCTargetPort' => hiera('cinder::backend::dellemc_sc::iscsi_port', undef), + 'CinderSCApiPort' => hiera('cinder::backend::dellemc_sc::dell_sc_api_port', undef), + 'CinderSCServerFolder' => hiera('cinder::backend::dellemc_sc::dell_sc_server_folder', undef), + 'CinderSCVolumeFolder' => hiera('cinder::backend::dellemc_sc::dell_sc_volume_folder', undef), + 'CinderSCExcludedDomainIps' => hiera('cinder::backend::dellemc_sc::excluded_domain_ips', undef), + 'CinderSCSecondarySanIp' => hiera('cinder::backend::dellemc_sc::secondary_san_ip', undef), + 'CinderSCSecondarySanLogin' => hiera('cinder::backend::dellemc_sc::secondary_san_login', undef), + 'CinderSCSecondarySanPassword' => hiera('cinder::backend::dellemc_sc::secondary_san_password', undef), + 'CinderSCSecondaryApiPort' => hiera('cinder::backend::dellemc_sc::secondary_sc_api_port', undef), + 'CinderSCUseMultipathForImageXfer' => hiera('cinder::backend::dellemc_sc::use_multipath_for_image_xfer', undef), + } + + any2array($backend_name).each |String $backend| { + $backend_config = merge($backend_defaults, pick($multi_config[$backend], {})) + + cinder::backend::dellemc_sc { $backend : + backend_availability_zone => $backend_config['CinderSCAvailabilityZone'], + san_ip => $backend_config['CinderSCSanIp'], + san_login => $backend_config['CinderSCSanLogin'], + san_password => $backend_config['CinderSCSanPassword'], + sc_storage_protocol => $backend_config['CinderSCStorageProtocol'], + dell_sc_ssn => $backend_config['CinderSCSSN'], + target_ip_address => $backend_config['CinderSCTargetIpAddress'], + target_port => $backend_config['CinderSCTargetPort'], + dell_sc_api_port => $backend_config['CinderSCApiPort'], + dell_sc_server_folder => $backend_config['CinderSCServerFolder'], + dell_sc_volume_folder => $backend_config['CinderSCVolumeFolder'], + excluded_domain_ips => $backend_config['CinderSCExcludedDomainIps'], + secondary_san_ip => $backend_config['CinderSCSecondarySanIp'], + secondary_san_login => $backend_config['CinderSCSecondarySanLogin'], + secondary_san_password => $backend_config['CinderSCSecondarySanPassword'], + secondary_sc_api_port => $backend_config['CinderSCSecondaryApiPort'], + use_multipath_for_image_xfer => $backend_config['CinderSCUseMultipathForImageXfer'], + } + } + } +} diff --git a/releasenotes/notes/sc-driver-a428e372280c44e6.yaml b/releasenotes/notes/sc-driver-a428e372280c44e6.yaml new file mode 100644 index 000000000..6fc5bbae5 --- /dev/null +++ b/releasenotes/notes/sc-driver-a428e372280c44e6.yaml @@ -0,0 +1,5 @@ +--- +features: + - Add Dell EMC SC backend Cinder driver options. + Supports both iSCSI and FC volume drivers and + multiple backends as well. diff --git a/spec/classes/tripleo_profile_base_cinder_sc_spec.rb b/spec/classes/tripleo_profile_base_cinder_sc_spec.rb new file mode 100644 index 000000000..0f16b368c --- /dev/null +++ b/spec/classes/tripleo_profile_base_cinder_sc_spec.rb @@ -0,0 +1,72 @@ +# Copyright (c) 2020 Dell Inc, or its subsidiaries +# +# 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::dellemc_sc' do + shared_examples_for 'tripleo::profile::base::cinder::volume::dellemc_sc' 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::dellemc_sc') + 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__dellemc_sc('tripleo_dellemc_sc') + end + end + + context 'with step 4' do + let(:params) { { + :step => 4, + } } + + it 'should trigger complete configuration' do + is_expected.to contain_cinder__backend__dellemc_sc('tripleo_dellemc_sc') + end + + context 'with multiple backends' do + let(:params) { { + :backend_name => ['tripleo_dellemc_sc_1', 'tripleo_dellemc_sc_2'], + :multi_config => { 'tripleo_dellemc_sc_2' => { 'CinderSCStorageProtocol' => 'FC' }}, + :step => 4, + } } + + it 'should configure each backend' do + is_expected.to contain_cinder__backend__dellemc_sc('tripleo_dellemc_sc_1') + is_expected.to contain_cinder_config('tripleo_dellemc_sc_1/volume_driver') + .with_value('cinder.volume.drivers.dell_emc.sc.storagecenter_iscsi.SCISCSIDriver') + is_expected.to contain_cinder__backend__dellemc_sc('tripleo_dellemc_sc_2') + is_expected.to contain_cinder_config('tripleo_dellemc_sc_2/volume_driver') + .with_value('cinder.volume.drivers.dell_emc.sc.storagecenter_fc.SCFCDriver') + end + end + end + end + + on_supported_os.each do |os, facts| + context "on #{os}" do + let(:facts) do + facts.merge({ :hostname => 'node.example.com' }) + end + + it_behaves_like 'tripleo::profile::base::cinder::volume::dellemc_sc' + 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 b8be7f111..fbef1e35f 100644 --- a/spec/classes/tripleo_profile_base_cinder_volume_spec.rb +++ b/spec/classes/tripleo_profile_base_cinder_volume_spec.rb @@ -148,6 +148,34 @@ describe 'tripleo::profile::base::cinder::volume' do end end + context 'with only sc' do + before :each do + params.merge!({ + :cinder_enable_dellemc_sc_backend => true, + :cinder_enable_iscsi_backend => false, + }) + end + it 'should configure only sc' do + is_expected.to contain_class('tripleo::profile::base::cinder::volume::dellemc_sc') + 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_dellemc_sc'] + ) + end + context 'with multiple sc backends' do + # Step 5's hiera specifies multiple sc backend names + let(:params) { { :step => 5 } } + it 'should enable each backend' do + is_expected.to contain_class('cinder::backends').with( + :enabled_backends => ['tripleo_dellemc_sc_1', 'tripleo_dellemc_sc_2'] + ) + end + end + end + context 'with only dellsc' do before :each do params.merge!({ @@ -287,6 +315,7 @@ describe 'tripleo::profile::base::cinder::volume' do 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::dellps') @@ -306,20 +335,22 @@ 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_dellps_backend => true, - :cinder_enable_dellsc_backend => true, + :cinder_enable_nfs_backend => true, + :cinder_enable_rbd_backend => true, + :cinder_enable_iscsi_backend => true, + :cinder_enable_pure_backend => true, + :cinder_enable_dellemc_sc_backend => true, :cinder_enable_dellemc_xtremio_backend => true, - :cinder_enable_netapp_backend => true, - :cinder_enable_vrts_hs_backend => true, + :cinder_enable_dellps_backend => true, + :cinder_enable_dellsc_backend => true, + :cinder_enable_netapp_backend => true, + :cinder_enable_vrts_hs_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::dellps') @@ -331,7 +362,8 @@ 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_dellps', 'tripleo_dellsc', 'tripleo_dellemc_xtremio', + :enabled_backends => ['tripleo_iscsi', 'tripleo_ceph', 'tripleo_pure','tripleo_dellps', 'tripleo_dellsc', + 'tripleo_dellemc_sc', 'tripleo_dellemc_xtremio', 'tripleo_netapp','tripleo_nfs','Veritas_HyperScale'] ) end diff --git a/spec/fixtures/hieradata/step5.yaml b/spec/fixtures/hieradata/step5.yaml index e995a6484..b04af19d9 100644 --- a/spec/fixtures/hieradata/step5.yaml +++ b/spec/fixtures/hieradata/step5.yaml @@ -9,6 +9,9 @@ cinder::backend::pure::volume_backend_name: cinder::backend::dellemc_powermax::volume_backend_name: - 'tripleo_dellemc_powermax_1' - 'tripleo_dellemc_powermax_2' +cinder::backend::dellemc_sc::volume_backend_name: + - 'tripleo_dellemc_sc_1' + - 'tripleo_dellemc_sc_2' cinder::backend::dellemc_xtremio::volume_backend_name: - 'tripleo_dellemc_xtremio_1' - 'tripleo_dellemc_xtremio_2'