Add NVMeOF support to configure cinder backend

Depends-On: I74ca80b10e25cbb36f073b8c0310da0c8784fb1f
Change-Id: I33545b5de5d4196848255d7333e799dc481540e2
This commit is contained in:
Hamdy Khader 2018-04-05 10:13:25 +03:00
parent ccd4053d0a
commit 7f592470a8
3 changed files with 140 additions and 1 deletions

View File

@ -74,6 +74,10 @@
# (Optional) Whether to enable the Veritas HyperScale backend
# Defaults to false
#
#[*cinder_enable_nvmeof_backend*]
# (Optional) Whether to enable the NVMeOF backend
# Defaults to false
#
# [*cinder_user_enabled_backends*]
# (Optional) List of additional backend stanzas to activate
# Defaults to hiera('cinder_user_enabled_backends')
@ -102,6 +106,7 @@ class tripleo::profile::base::cinder::volume (
$cinder_enable_rbd_backend = false,
$cinder_enable_scaleio_backend = false,
$cinder_enable_vrts_hs_backend = false,
$cinder_enable_nvmeof_backend = false,
$cinder_user_enabled_backends = hiera('cinder_user_enabled_backends', undef),
$cinder_rbd_client_name = hiera('tripleo::profile::base::cinder::volume::rbd::cinder_rbd_user_name','openstack'),
$step = Integer(hiera('step')),
@ -228,6 +233,13 @@ class tripleo::profile::base::cinder::volume (
$cinder_veritas_hyperscale_backend_name = undef
}
if $cinder_enable_nvmeof_backend {
include ::tripleo::profile::base::cinder::volume::nvmeof
$cinder_nvmeof_backend_name = hiera('cinder::backend::nvmeof::volume_backend_name', 'tripleo_nvmeof')
} else {
$cinder_nvmeof_backend_name = undef
}
$backends = delete_undef_values(concat([], $cinder_iscsi_backend_name,
$cinder_rbd_backend_name,
$cinder_rbd_extra_backend_names,
@ -243,7 +255,8 @@ class tripleo::profile::base::cinder::volume (
$cinder_nfs_backend_name,
$cinder_scaleio_backend_name,
$cinder_veritas_hyperscale_backend_name,
$cinder_user_enabled_backends))
$cinder_user_enabled_backends,
$cinder_nvmeof_backend_name))
# NOTE(aschultz): during testing it was found that puppet 3 may incorrectly
# include a "" in the previous array which is not removed by the
# delete_undef_values function. So we need to make sure we don't have any

View File

@ -0,0 +1,74 @@
#
# == Class: tripleo::profile::base::cinder::volume::nvmeof
#
# NVMeOF Cinder Volume profile for tripleo
#
# === Parameters
#
# [*target_ip_address*]
# (Required) The IP address of NVMe target
#
# [*target_port*]
# (Required) Port that NVMe target is listening on
#
# [*target_helper*]
# (Required) Target user-land tool to use
#
# [*target_protocol*]
# (Required) Target rotocol to use
#
# [*target_prefix*]
# (Optional) Prefix for LVM volumes
# Defaults to 'nvme-subsystem'
#
# [*nvmet_port_id*]
# (Optional) Port id of the NVMe target
# Defaults to '1'
#
# [*nvmet_ns_id*]
# (Optional) The namespace id associated with the subsystem
# Defaults to '10'
#
# [*volume_backend_name*]
# (Optional) Name given to the Cinder backend
# Defaults to 'tripleo_nvmeof'
#
# [*volume_driver*]
# (Optional) Driver to use for volume creation
# Defaults to 'cinder.volume.drivers.lvm.LVMVolumeDriver'
#
# [*step*]
# (Optional) The current step in deployment. See tripleo-heat-templates
# for more details.
# Defaults to hiera('step')
#
class tripleo::profile::base::cinder::volume::nvmeof (
$target_ip_address,
$target_port,
$target_helper,
$target_protocol,
$target_prefix = 'nvme-subsystem',
$nvmet_port_id = '1',
$nvmet_ns_id = '10',
$volume_backend_name = hiera('cinder::backend::nvmeof::volume_backend_name', 'tripleo_nvmeof'),
$volume_driver = 'cinder.volume.drivers.lvm.LVMVolumeDriver',
$step = Integer(hiera('step')),
) {
include ::tripleo::profile::base::cinder::volume
if $step >= 4 {
cinder::backend::nvmeof { $volume_backend_name :
target_ip_address => normalize_ip_for_uri($target_ip_address),
target_port => $target_port,
target_helper => $target_helper,
target_protocol => $target_protocol,
target_prefix => $target_prefix,
nvmet_port_id => $nvmet_port_id,
nvmet_ns_id => $nvmet_ns_id,
volume_backend_name => $volume_backend_name,
volume_driver => $volume_driver,
}
}
}

View File

@ -0,0 +1,52 @@
require 'spec_helper'
describe 'tripleo::profile::base::cinder::volume::nvmeof' do
shared_examples_for 'tripleo::profile::base::cinder::volume::nvmeof' do
before :each do
facts.merge!({ :step => params[:step] })
end
context 'with step less than 4' do
let(:params) { {
:target_ip_address => '127.0.0.1',
:target_port => '4420',
:target_helper => 'nvmet',
:target_protocol => 'nvmet_rdma',
:step => 3
} }
it 'should do nothing' do
is_expected.to contain_class('tripleo::profile::base::cinder::volume::nvmeof')
is_expected.to contain_class('tripleo::profile::base::cinder::volume')
is_expected.to contain_class('tripleo::profile::base::cinder')
is_expected.to_not contain_class('cinder::setup_test_volume')
is_expected.to_not contain_cinder__backend__nvmeof('tripleo_nvmeof')
end
end
context 'with step 4' do
let(:params) { {
:target_ip_address => '127.0.0.1',
:target_port => '4420',
:target_helper => 'nvmet',
:target_protocol => 'nvmet_rdma',
:step => 4,
} }
context 'with defaults' do
it 'should trigger complete configuration' do
is_expected.to contain_cinder__backend__nvmeof('tripleo_nvmeof').with(
:target_ip_address => '127.0.0.1',
:target_port => '4420',
:target_helper => 'nvmet',
:target_protocol => 'nvmet_rdma',
:nvmet_port_id => '1',
:nvmet_ns_id => '10',
)
end
end
end
end
end