implement class and defined type for cinder GPFS driver
implement class, defined type and tests for cinder IBM GPFS driver Change-Id: Iec7d569811d876390e40f00eab9d0a8d9ebe022f Closes-Bug: #1493336
This commit is contained in:
parent
15e72a64d4
commit
2d983e20b0
91
manifests/backend/gpfs.pp
Normal file
91
manifests/backend/gpfs.pp
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
# == define: cinder::backend::gpfs
|
||||||
|
#
|
||||||
|
# Configures Cinder to use the IBM GPFS Driver
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# [*gpfs_mount_point_base*]
|
||||||
|
# (required) Specifies the path of the GPFS directory where Block Storage
|
||||||
|
# volume and snapshot files are stored.
|
||||||
|
#
|
||||||
|
# [*gpfs_images_dir*]
|
||||||
|
# (optional) Specifies the path of the Image service repository in GPFS.
|
||||||
|
# Leave undefined if not storing images in GPFS. Defaults to "None" via
|
||||||
|
# driver.
|
||||||
|
# Defaults to <SERVICE DEFAULT>
|
||||||
|
#
|
||||||
|
# [*gpfs_images_share_mode*]
|
||||||
|
# (optional) Specifies the type of image copy to be used. Set this when the
|
||||||
|
# Image service repository also uses GPFS so that image files can be
|
||||||
|
# transferred efficiently from the Image service to the Block Storage
|
||||||
|
# service. There are two valid values: "copy" specifies that a full copy of
|
||||||
|
# the image is made; "copy_on_write" specifies that copy-on-write
|
||||||
|
# optimization strategy is used and unmodified blocks of the image file are
|
||||||
|
# shared efficiently. Defaults to "None" via driver.
|
||||||
|
# Defaults to <SERVICE DEFAULT>
|
||||||
|
#
|
||||||
|
# [*gpfs_max_clone_depth*]
|
||||||
|
# (optional) Specifies an upper limit on the number of indirections required
|
||||||
|
# to reach a specific block due to snapshots or clones. A lengthy chain of
|
||||||
|
# copy-on-write snapshots or clones can have a negative impact on
|
||||||
|
# performance, but improves space utilization. 0 indicates unlimited clone
|
||||||
|
# depth. Defaults to "0" via driver implementation
|
||||||
|
# Defaults to <SERVICE DEFAULT>
|
||||||
|
#
|
||||||
|
# [*gpfs_sparse_volumes*]
|
||||||
|
# (optional) Specifies that volumes are created as sparse files which
|
||||||
|
# initially consume no space. If set to False, the volume is created as a
|
||||||
|
# fully allocated file, in which case, creation may take a significantly
|
||||||
|
# longer time. Defaults to "True" via driver.
|
||||||
|
# Defaults to <SERVICE DEFAULT>
|
||||||
|
#
|
||||||
|
# [*gpfs_storage_pool*]
|
||||||
|
# (optional) Specifies the storage pool that volumes are assigned to. By
|
||||||
|
# default, the system storage pool is used. Defaults to "system" via driver.
|
||||||
|
# Defaults to <SERVICE DEFAULT>
|
||||||
|
#
|
||||||
|
# [*extra_options*]
|
||||||
|
# (optional) Hash of extra options to pass to the backend stanza
|
||||||
|
# Defaults to: {}
|
||||||
|
# Example :
|
||||||
|
# { 'gpfs_backend/param1' => { 'value' => value1 } }
|
||||||
|
#
|
||||||
|
# === Authors
|
||||||
|
#
|
||||||
|
# Benedikt von St. Vieth <b.von.st.vieth@fz-juelich.de>
|
||||||
|
#
|
||||||
|
# === Copyright
|
||||||
|
#
|
||||||
|
# Copyright 2015
|
||||||
|
#
|
||||||
|
define cinder::backend::gpfs (
|
||||||
|
$gpfs_mount_point_base,
|
||||||
|
$gpfs_images_dir = '<SERVICE DEFAULT>',
|
||||||
|
$gpfs_images_share_mode = '<SERVICE DEFAULT>',
|
||||||
|
$gpfs_max_clone_depth = '<SERVICE DEFAULT>',
|
||||||
|
$gpfs_sparse_volumes = '<SERVICE DEFAULT>',
|
||||||
|
$gpfs_storage_pool = '<SERVICE DEFAULT>',
|
||||||
|
$extra_options = {},
|
||||||
|
) {
|
||||||
|
|
||||||
|
if ! ($gpfs_images_share_mode in ['copy', 'copy_on_write', '<SERVICE DEFAULT>']) {
|
||||||
|
fail('gpfs_images_share_mode only support `copy` or `copy_on_write`')
|
||||||
|
}
|
||||||
|
if $gpfs_images_share_mode in ['copy', 'copy_on_write'] and $gpfs_images_dir == '<SERVICE DEFAULT>' {
|
||||||
|
fail('gpfs_images_share_mode only in conjunction with gpfs_images_dir')
|
||||||
|
}
|
||||||
|
|
||||||
|
cinder_config {
|
||||||
|
"${name}/volume_driver":
|
||||||
|
value => 'cinder.volume.drivers.ibm.gpfs.GPFSDriver';
|
||||||
|
"${name}/gpfs_max_clone_depth": value => $gpfs_max_clone_depth;
|
||||||
|
"${name}/gpfs_mount_point_base": value => $gpfs_mount_point_base;
|
||||||
|
"${name}/gpfs_sparse_volumes": value => $gpfs_sparse_volumes;
|
||||||
|
"${name}/gpfs_storage_pool": value => $gpfs_storage_pool;
|
||||||
|
"${name}/gpfs_images_share_mode": value => $gpfs_images_share_mode;
|
||||||
|
"${name}/gpfs_images_dir": value => $gpfs_images_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
create_resources('cinder_config', $extra_options)
|
||||||
|
|
||||||
|
}
|
79
manifests/volume/gpfs.pp
Normal file
79
manifests/volume/gpfs.pp
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# == Class: cinder::volume::gpfs
|
||||||
|
#
|
||||||
|
# Configures Cinder to use the IBM GPFS Driver
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# [*gpfs_mount_point_base*]
|
||||||
|
# (required) Specifies the path of the GPFS directory where Block Storage
|
||||||
|
# volume and snapshot files are stored.
|
||||||
|
#
|
||||||
|
# [*gpfs_images_dir*]
|
||||||
|
# (optional) Specifies the path of the Image service repository in GPFS.
|
||||||
|
# Leave undefined if not storing images in GPFS. Defaults to "None" via
|
||||||
|
# driver.
|
||||||
|
# Defaults to <SERVICE DEFAULT>
|
||||||
|
#
|
||||||
|
# [*gpfs_images_share_mode*]
|
||||||
|
# (optional) Specifies the type of image copy to be used. Set this when the
|
||||||
|
# Image service repository also uses GPFS so that image files can be
|
||||||
|
# transferred efficiently from the Image service to the Block Storage
|
||||||
|
# service. There are two valid values: "copy" specifies that a full copy of
|
||||||
|
# the image is made; "copy_on_write" specifies that copy-on-write
|
||||||
|
# optimization strategy is used and unmodified blocks of the image file are
|
||||||
|
# shared efficiently. Defaults to "None" via driver.
|
||||||
|
# Defaults to <SERVICE DEFAULT>
|
||||||
|
#
|
||||||
|
# [*gpfs_max_clone_depth*]
|
||||||
|
# (optional) Specifies an upper limit on the number of indirections required
|
||||||
|
# to reach a specific block due to snapshots or clones. A lengthy chain of
|
||||||
|
# copy-on-write snapshots or clones can have a negative impact on
|
||||||
|
# performance, but improves space utilization. 0 indicates unlimited clone
|
||||||
|
# depth. Defaults to "0" via driver implementation
|
||||||
|
# Defaults to <SERVICE DEFAULT>
|
||||||
|
#
|
||||||
|
# [*gpfs_sparse_volumes*]
|
||||||
|
# (optional) Specifies that volumes are created as sparse files which
|
||||||
|
# initially consume no space. If set to False, the volume is created as a
|
||||||
|
# fully allocated file, in which case, creation may take a significantly
|
||||||
|
# longer time. Defaults to "True" via driver.
|
||||||
|
# Defaults to <SERVICE DEFAULT>
|
||||||
|
#
|
||||||
|
# [*gpfs_storage_pool*]
|
||||||
|
# (optional) Specifies the storage pool that volumes are assigned to. By
|
||||||
|
# default, the system storage pool is used. Defaults to "system" via driver.
|
||||||
|
# Defaults to <SERVICE DEFAULT>
|
||||||
|
#
|
||||||
|
# [*extra_options*]
|
||||||
|
# (optional) Hash of extra options to pass to the backend stanza
|
||||||
|
# Defaults to: {}
|
||||||
|
# Example :
|
||||||
|
# { 'gpfs_backend/param1' => { 'value' => value1 } }
|
||||||
|
#
|
||||||
|
# === Authors
|
||||||
|
#
|
||||||
|
# Benedikt von St. Vieth <b.von.st.vieth@fz-juelich.de>
|
||||||
|
#
|
||||||
|
# === Copyright
|
||||||
|
#
|
||||||
|
# Copyright 2015
|
||||||
|
#
|
||||||
|
class cinder::volume::gpfs(
|
||||||
|
$gpfs_mount_point_base,
|
||||||
|
$gpfs_images_dir = '<SERVICE DEFAULT>',
|
||||||
|
$gpfs_images_share_mode = '<SERVICE DEFAULT>',
|
||||||
|
$gpfs_max_clone_depth = '<SERVICE DEFAULT>',
|
||||||
|
$gpfs_sparse_volumes = '<SERVICE DEFAULT>',
|
||||||
|
$gpfs_storage_pool = '<SERVICE DEFAULT>',
|
||||||
|
$extra_options = {}
|
||||||
|
) {
|
||||||
|
cinder::backend::gpfs { 'DEFAULT':
|
||||||
|
gpfs_mount_point_base => $gpfs_mount_point_base,
|
||||||
|
gpfs_images_dir => $gpfs_images_dir,
|
||||||
|
gpfs_images_share_mode => $gpfs_images_share_mode,
|
||||||
|
gpfs_max_clone_depth => $gpfs_max_clone_depth,
|
||||||
|
gpfs_sparse_volumes => $gpfs_sparse_volumes,
|
||||||
|
gpfs_storage_pool => $gpfs_storage_pool,
|
||||||
|
extra_options => $extra_options,
|
||||||
|
}
|
||||||
|
}
|
18
spec/classes/cinder_volume_gpfs_spec.rb
Normal file
18
spec/classes/cinder_volume_gpfs_spec.rb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'cinder::volume::gpfs' do
|
||||||
|
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:gpfs_mount_point_base => '/opt/gpfs/cinder/volumes',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'gpfs volume driver' do
|
||||||
|
|
||||||
|
it 'checks gpfs backend availability' do
|
||||||
|
is_expected.to contain_cinder__backend__gpfs('DEFAULT')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
95
spec/defines/cinder_backend_gpfs_spec.rb
Normal file
95
spec/defines/cinder_backend_gpfs_spec.rb
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'cinder::backend::gpfs' do
|
||||||
|
|
||||||
|
let (:title) { 'gpfs' }
|
||||||
|
|
||||||
|
let :params do
|
||||||
|
{
|
||||||
|
:gpfs_mount_point_base => '/opt/gpfs/cinder/volumes',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
let :default_params do
|
||||||
|
{
|
||||||
|
:gpfs_max_clone_depth => '<SERVICE DEFAULT>',
|
||||||
|
:gpfs_sparse_volumes => '<SERVICE DEFAULT>',
|
||||||
|
:gpfs_storage_pool => '<SERVICE DEFAULT>',
|
||||||
|
:gpfs_images_dir => '<SERVICE DEFAULT>',
|
||||||
|
:gpfs_images_share_mode => '<SERVICE DEFAULT>',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
let :custom_params do
|
||||||
|
{
|
||||||
|
:gpfs_max_clone_depth => 1,
|
||||||
|
:gpfs_sparse_volumes => false,
|
||||||
|
:gpfs_storage_pool => 'foo',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'gpfs volume driver' do
|
||||||
|
let :params_hash do
|
||||||
|
default_params.merge(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures gpfs volume driver' do
|
||||||
|
is_expected.to contain_cinder_config('gpfs/volume_driver').with_value(
|
||||||
|
'cinder.volume.drivers.ibm.gpfs.GPFSDriver')
|
||||||
|
params_hash.each_pair do |config,value|
|
||||||
|
is_expected.to contain_cinder_config("gpfs/#{config}").with_value( value )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with default parameters' do
|
||||||
|
it_configures 'gpfs volume driver'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with additional image parameters' do
|
||||||
|
before do
|
||||||
|
params.merge!({
|
||||||
|
:gpfs_images_dir => '/gpfs/glance/images',
|
||||||
|
:gpfs_images_share_mode => 'copy_on_write',
|
||||||
|
})
|
||||||
|
end
|
||||||
|
it_configures 'gpfs volume driver'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with custom parameters' do
|
||||||
|
before do
|
||||||
|
params.merge(custom_params)
|
||||||
|
end
|
||||||
|
it_configures 'gpfs volume driver'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with image share mode but without image path' do
|
||||||
|
before do
|
||||||
|
params.merge!({
|
||||||
|
:gpfs_images_share_mode => 'copy_on_write',
|
||||||
|
})
|
||||||
|
end
|
||||||
|
it_raises 'a Puppet::Error', /gpfs_images_share_mode only in conjunction with gpfs_images_dir/
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with wrong gpfs_images_share_mode' do
|
||||||
|
before do
|
||||||
|
params.merge!({
|
||||||
|
:gpfs_images_share_mode => 'foo',
|
||||||
|
})
|
||||||
|
end
|
||||||
|
it_raises 'a Puppet::Error', /gpfs_images_share_mode only support `copy` or `copy_on_write`/
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'gpfs backend with additional configuration' do
|
||||||
|
before do
|
||||||
|
params.merge!({:extra_options => {'gpfs/param1' => { 'value' => 'value1' }}})
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configure gpfs backend with additional configuration' do
|
||||||
|
is_expected.to contain_cinder_config('gpfs/param1').with({
|
||||||
|
:value => 'value1'
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user