From 9c11b47dc492000012ac2767401764ac18f47017 Mon Sep 17 00:00:00 2001 From: Denis Egorenko Date: Wed, 23 Mar 2016 19:41:53 +0300 Subject: [PATCH] Update Cinder BDD backend configuration Currently Cinder BDD backend is used only fake iscsi_helper - which is allow to attach volumes only locally. Since [1] merged BlockDeviceDriver supports to attach volumes to any instance on any node. Hence we need to manage needed daemons. [1] Ic22f03860a43b767e9097ce6dc5b397cf9f3f076 Related-bug: #1560499 Change-Id: Ifee3fb8435cb48a3087f5924c3b01ec94275a5eb --- manifests/backend/bdd.pp | 41 +++++++++++++++++++++++-- spec/defines/cinder_backend_bdd_spec.rb | 6 ++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/manifests/backend/bdd.pp b/manifests/backend/bdd.pp index 9faf7e12..3d2ae44d 100644 --- a/manifests/backend/bdd.pp +++ b/manifests/backend/bdd.pp @@ -30,7 +30,7 @@ # # [*iscsi_helper*] # (Optional) iSCSI target user-land tool to use. -# Defaults to fake. +# Defaults to tgtadm. # # [*iscsi_protocol*] # (Optional) Protocol to use as iSCSI driver @@ -64,7 +64,7 @@ define cinder::backend::bdd ( $volume_driver = 'cinder.volume.drivers.block_device.BlockDeviceDriver', $volume_group = $::os_service_default, $volumes_dir = '/var/lib/cinder/volumes', - $iscsi_helper = 'fake', + $iscsi_helper = 'tgtadm', $iscsi_protocol = $::os_service_default, $volume_clear = $::os_service_default, $extra_options = {}, @@ -86,4 +86,41 @@ define cinder::backend::bdd ( create_resources('cinder_config', $extra_options) + case $iscsi_helper { + 'tgtadm': { + ensure_packages('tgt', { + ensure => present, + name => $::cinder::params::tgt_package_name}) + + ensure_resource('service', 'tgtd', { + ensure => present, + name => $::cinder::params::tgt_service_name, + require => Package['tgt']}) + + if($::osfamily == 'RedHat') { + ensure_resource('file_line', 'cinder include', { + path => '/etc/tgt/targets.conf', + line => "include ${volumes_dir}/*", + match => '#?include /', + require => Package['tgt'], + notify => Service['tgtd']}) + } + } + + 'lioadm': { + ensure_packages('targetcli', { + ensure => present, + name => $::cinder::params::lio_package_name}) + + ensure_resource('service', 'target', { + ensure => running, + enable => true, + require => Package['targetcli']}) + } + + default: { + fail("Unsupported iscsi helper: ${iscsi_helper}.") + } + } + } diff --git a/spec/defines/cinder_backend_bdd_spec.rb b/spec/defines/cinder_backend_bdd_spec.rb index cbb6d5c4..842af390 100644 --- a/spec/defines/cinder_backend_bdd_spec.rb +++ b/spec/defines/cinder_backend_bdd_spec.rb @@ -16,7 +16,7 @@ describe 'cinder::backend::bdd' do should contain_cinder_config('hippo/volume_backend_name').with_value('hippo') should contain_cinder_config('hippo/volume_driver').with_value('cinder.volume.drivers.block_device.BlockDeviceDriver') should contain_cinder_config('hippo/available_devices').with_value('/dev/sda') - should contain_cinder_config('hippo/iscsi_helper').with_value('fake') + should contain_cinder_config('hippo/iscsi_helper').with_value('tgtadm') should contain_cinder_config('hippo/volumes_dir').with_value('/var/lib/cinder/volumes') should contain_cinder_config('hippo/iscsi_ip_address').with_value('127.0.0.2') should contain_cinder_config('hippo/volume_group').with_value('') @@ -32,7 +32,8 @@ describe 'cinder::backend::bdd' do :available_devices => '/dev/sdb,/dev/sdc', :volumes_dir => '/var/lib/cinder/bdd-volumes', :volume_clear => 'zero', - :volume_group => 'cinder', + :volume_group => 'cinder', + :iscsi_helper => 'lioadm', }) end @@ -40,6 +41,7 @@ describe 'cinder::backend::bdd' do should contain_cinder_config('hippo/available_devices').with_value('/dev/sdb,/dev/sdc') should contain_cinder_config('hippo/volumes_dir').with_value('/var/lib/cinder/bdd-volumes') should contain_cinder_config('hippo/iscsi_ip_address').with_value('10.20.0.2') + should contain_cinder_config('hippo/iscsi_helper').with_value('lioadm') should contain_cinder_config('hippo/volume_group').with_value('cinder') should contain_cinder_config('hippo/volume_clear').with_value('zero') end