multi backends: factorize code between single and multi backends
Code is duplicated between single volume backend (cinder::volume::*) and multi backends (cinder::backend::*). This commits updates the single volume backends to make use of the respective multiple backends classes. Change-Id: I26a796fb6131fa469f007af54cb96b3605c0f74d
This commit is contained in:
parent
9b9e216802
commit
c914f0ceb3
@ -13,7 +13,9 @@ define cinder::backend::nfs (
|
||||
$nfs_disk_util = undef,
|
||||
$nfs_sparsed_volumes = undef,
|
||||
$nfs_mount_point_base = undef,
|
||||
$nfs_shares_config = '/etc/cinder/shares.conf'
|
||||
$nfs_shares_config = '/etc/cinder/shares.conf',
|
||||
$nfs_used_ratio = '0.95',
|
||||
$nfs_oversub_ratio = '1.0',
|
||||
) {
|
||||
|
||||
file {$nfs_shares_config:
|
||||
@ -31,5 +33,7 @@ define cinder::backend::nfs (
|
||||
"${name}/nfs_disk_util": value => $nfs_disk_util;
|
||||
"${name}/nfs_sparsed_volumes": value => $nfs_sparsed_volumes;
|
||||
"${name}/nfs_mount_point_base": value => $nfs_mount_point_base;
|
||||
"${name}/nfs_used_ratio": value => $nfs_used_ratio;
|
||||
"${name}/nfs_oversub_ratio": value => $nfs_oversub_ratio;
|
||||
}
|
||||
}
|
||||
|
@ -5,42 +5,9 @@ class cinder::volume::iscsi (
|
||||
$iscsi_helper = 'tgtadm'
|
||||
) {
|
||||
|
||||
include cinder::params
|
||||
|
||||
cinder_config {
|
||||
'DEFAULT/iscsi_ip_address': value => $iscsi_ip_address;
|
||||
'DEFAULT/iscsi_helper': value => $iscsi_helper;
|
||||
'DEFAULT/volume_group': value => $volume_group;
|
||||
cinder::backend::iscsi { 'DEFAULT':
|
||||
iscsi_ip_address => $iscsi_ip_address,
|
||||
volume_group => $volume_group,
|
||||
iscsi_helper => $iscsi_helper
|
||||
}
|
||||
|
||||
case $iscsi_helper {
|
||||
'tgtadm': {
|
||||
package { 'tgt':
|
||||
ensure => present,
|
||||
name => $::cinder::params::tgt_package_name,
|
||||
}
|
||||
|
||||
if($::osfamily == 'RedHat') {
|
||||
file_line { 'cinder include':
|
||||
path => '/etc/tgt/targets.conf',
|
||||
line => 'include /etc/cinder/volumes/*',
|
||||
match => '#?include /',
|
||||
require => Package['tgt'],
|
||||
notify => Service['tgtd'],
|
||||
}
|
||||
}
|
||||
|
||||
service { 'tgtd':
|
||||
ensure => running,
|
||||
name => $::cinder::params::tgt_service_name,
|
||||
enable => true,
|
||||
require => Class['cinder::volume'],
|
||||
}
|
||||
}
|
||||
|
||||
default: {
|
||||
fail("Unsupported iscsi helper: ${iscsi_helper}.")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -171,28 +171,26 @@ class cinder::volume::netapp (
|
||||
$netapp_webservice_path = '/devmgr/v2',
|
||||
) {
|
||||
|
||||
cinder_config {
|
||||
'DEFAULT/volume_driver': value => 'cinder.volume.drivers.netapp.common.NetAppDriver';
|
||||
'DEFAULT/netapp_login': value => $netapp_login;
|
||||
'DEFAULT/netapp_password': value => $netapp_password, secret => true;
|
||||
'DEFAULT/netapp_server_hostname': value => $netapp_server_hostname;
|
||||
'DEFAULT/netapp_server_port': value => $netapp_server_port;
|
||||
'DEFAULT/netapp_size_multiplier': value => $netapp_size_multiplier;
|
||||
'DEFAULT/netapp_storage_family': value => $netapp_storage_family;
|
||||
'DEFAULT/netapp_storage_protocol': value => $netapp_storage_protocol;
|
||||
'DEFAULT/netapp_transport_type': value => $netapp_transport_type;
|
||||
'DEFAULT/netapp_vfiler': value => $netapp_vfiler;
|
||||
'DEFAULT/netapp_volume_list': value => $netapp_volume_list;
|
||||
'DEFAULT/netapp_vserver': value => $netapp_vserver;
|
||||
'DEFAULT/expiry_thres_minutes': value => $expiry_thres_minutes;
|
||||
'DEFAULT/thres_avl_size_perc_start': value => $thres_avl_size_perc_start;
|
||||
'DEFAULT/thres_avl_size_perc_stop': value => $thres_avl_size_perc_stop;
|
||||
'DEFAULT/nfs_shares_config': value => $nfs_shares_config;
|
||||
'DEFAULT/netapp_copyoffload_tool_path': value => $netapp_copyoffload_tool_path;
|
||||
'DEFAULT/netapp_controller_ips': value => $netapp_controller_ips;
|
||||
'DEFAULT/netapp_sa_password': value => $netapp_sa_password;
|
||||
'DEFAULT/netapp_storage_pools': value => $netapp_storage_pools;
|
||||
'DEFAULT/netapp_webservice_path': value => $netapp_webservice_path;
|
||||
cinder::backend::netapp { 'DEFAULT':
|
||||
netapp_login => $netapp_login,
|
||||
netapp_password => $netapp_password,
|
||||
netapp_server_hostname => $netapp_server_hostname,
|
||||
netapp_server_port => $netapp_server_port,
|
||||
netapp_size_multiplier => $netapp_size_multiplier,
|
||||
netapp_storage_family => $netapp_storage_family,
|
||||
netapp_storage_protocol => $netapp_storage_protocol,
|
||||
netapp_transport_type => $netapp_transport_type,
|
||||
netapp_vfiler => $netapp_vfiler,
|
||||
netapp_volume_list => $netapp_volume_list,
|
||||
netapp_vserver => $netapp_vserver,
|
||||
expiry_thres_minutes => $expiry_thres_minutes,
|
||||
thres_avl_size_perc_start => $thres_avl_size_perc_start,
|
||||
thres_avl_size_perc_stop => $thres_avl_size_perc_stop,
|
||||
nfs_shares_config => $nfs_shares_config,
|
||||
netapp_copyoffload_tool_path => $netapp_copyoffload_tool_path,
|
||||
netapp_controller_ips => $netapp_controller_ips,
|
||||
netapp_sa_password => $netapp_sa_password,
|
||||
netapp_storage_pools => $netapp_storage_pools,
|
||||
netapp_webservice_path => $netapp_webservice_path,
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,21 +10,14 @@ class cinder::volume::nfs (
|
||||
$nfs_oversub_ratio = '1.0',
|
||||
) {
|
||||
|
||||
file {$nfs_shares_config:
|
||||
content => join($nfs_servers, "\n"),
|
||||
require => Package['cinder'],
|
||||
notify => Service['cinder-volume']
|
||||
}
|
||||
|
||||
cinder_config {
|
||||
'DEFAULT/volume_driver': value =>
|
||||
'cinder.volume.drivers.nfs.NfsDriver';
|
||||
'DEFAULT/nfs_shares_config': value => $nfs_shares_config;
|
||||
'DEFAULT/nfs_mount_options': value => $nfs_mount_options;
|
||||
'DEFAULT/nfs_disk_util': value => $nfs_disk_util;
|
||||
'DEFAULT/nfs_sparsed_volumes': value => $nfs_sparsed_volumes;
|
||||
'DEFAULT/nfs_mount_point_base': value => $nfs_mount_point_base;
|
||||
'DEFAULT/nfs_used_ratio': value => $nfs_used_ratio;
|
||||
'DEFAULT/nfs_oversub_ratio': value => $nfs_oversub_ratio;
|
||||
cinder::backend::nfs { 'DEFAULT':
|
||||
nfs_servers => $nfs_servers,
|
||||
nfs_mount_options => $nfs_mount_options,
|
||||
nfs_disk_util => $nfs_disk_util,
|
||||
nfs_sparsed_volumes => $nfs_sparsed_volumes,
|
||||
nfs_mount_point_base => $nfs_mount_point_base,
|
||||
nfs_shares_config => $nfs_shares_config,
|
||||
nfs_used_ratio => $nfs_used_ratio,
|
||||
nfs_oversub_ratio => $nfs_oversub_ratio,
|
||||
}
|
||||
}
|
||||
|
@ -51,54 +51,14 @@ class cinder::volume::rbd (
|
||||
$glance_api_version = undef,
|
||||
) {
|
||||
|
||||
include cinder::params
|
||||
|
||||
if $glance_api_version {
|
||||
warning('The glance_api_version is deprecated, use glance_api_version of cinder::glance class instead.')
|
||||
cinder::backend::rbd { 'DEFAULT':
|
||||
rbd_pool => $rbd_pool,
|
||||
rbd_user => $rbd_user,
|
||||
rbd_ceph_conf => $rbd_ceph_conf,
|
||||
rbd_flatten_volume_from_snapshot => $rbd_flatten_volume_from_snapshot,
|
||||
rbd_secret_uuid => $rbd_secret_uuid,
|
||||
volume_tmp_dir => $volume_tmp_dir,
|
||||
rbd_max_clone_depth => $rbd_max_clone_depth,
|
||||
glance_api_version => $glance_api_version,
|
||||
}
|
||||
|
||||
cinder_config {
|
||||
'DEFAULT/volume_driver': value => 'cinder.volume.drivers.rbd.RBDDriver';
|
||||
'DEFAULT/rbd_ceph_conf': value => $rbd_ceph_conf;
|
||||
'DEFAULT/rbd_user': value => $rbd_user;
|
||||
'DEFAULT/rbd_pool': value => $rbd_pool;
|
||||
'DEFAULT/rbd_max_clone_depth': value => $rbd_max_clone_depth;
|
||||
'DEFAULT/rbd_flatten_volume_from_snapshot': value => $rbd_flatten_volume_from_snapshot;
|
||||
}
|
||||
|
||||
if $rbd_secret_uuid {
|
||||
cinder_config {'DEFAULT/rbd_secret_uuid': value => $rbd_secret_uuid;}
|
||||
} else {
|
||||
cinder_config {'DEFAULT/rbd_secret_uuid': ensure => absent;}
|
||||
}
|
||||
|
||||
if $volume_tmp_dir {
|
||||
cinder_config {'DEFAULT/volume_tmp_dir': value => $volume_tmp_dir;}
|
||||
} else {
|
||||
cinder_config {'DEFAULT/volume_tmp_dir': ensure => absent;}
|
||||
}
|
||||
|
||||
case $::osfamily {
|
||||
'Debian': {
|
||||
$override_line = "env CEPH_ARGS=\"--id ${rbd_user}\""
|
||||
}
|
||||
'RedHat': {
|
||||
$override_line = "export CEPH_ARGS=\"--id ${rbd_user}\""
|
||||
}
|
||||
default: {
|
||||
fail("unsuported osfamily ${::osfamily}, currently Debian and Redhat are the only supported platforms")
|
||||
}
|
||||
}
|
||||
|
||||
# Creates an empty file if it doesn't yet exist
|
||||
file { $::cinder::params::ceph_init_override:
|
||||
ensure => present,
|
||||
}
|
||||
|
||||
file_line { 'set initscript env':
|
||||
line => $override_line,
|
||||
path => $::cinder::params::ceph_init_override,
|
||||
notify => Service['cinder-volume'],
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -58,25 +58,15 @@ class cinder::volume::vmdk(
|
||||
$wsdl_location = undef
|
||||
) {
|
||||
|
||||
cinder_config {
|
||||
'DEFAULT/volume_driver': value => 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver';
|
||||
'DEFAULT/vmware_host_ip': value => $host_ip;
|
||||
'DEFAULT/vmware_host_username': value => $host_username;
|
||||
'DEFAULT/vmware_host_password': value => $host_password;
|
||||
'DEFAULT/vmware_volume_folder': value => $volume_folder;
|
||||
'DEFAULT/vmware_api_retry_count': value => $api_retry_count;
|
||||
'DEFAULT/vmware_max_object_retrieval': value => $max_object_retrieval;
|
||||
'DEFAULT/vmware_task_poll_interval': value => $task_poll_interval;
|
||||
'DEFAULT/vmware_image_transfer_timeout_secs': value => $image_transfer_timeout_secs;
|
||||
}
|
||||
|
||||
if $wsdl_location {
|
||||
cinder_config {
|
||||
'DEFAULT/vmware_wsdl_location': value => $wsdl_location;
|
||||
}
|
||||
}
|
||||
|
||||
package{ 'python-suds':
|
||||
ensure => present,
|
||||
cinder::backend::vmdk { 'DEFAULT':
|
||||
host_ip => $host_ip,
|
||||
host_username => $host_username,
|
||||
host_password => $host_password,
|
||||
volume_folder => $volume_folder,
|
||||
api_retry_count => $api_retry_count,
|
||||
max_object_retrieval => $max_object_retrieval,
|
||||
task_poll_interval => $task_poll_interval,
|
||||
image_transfer_timeout_secs => $image_transfer_timeout_secs,
|
||||
wsdl_location => $wsdl_location,
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ describe 'cinder::backend::nfs' do
|
||||
:nfs_disk_util => 'du',
|
||||
:nfs_sparsed_volumes => true,
|
||||
:nfs_mount_point_base => '/cinder_mount_point',
|
||||
:nfs_used_ratio => '0.7',
|
||||
:nfs_oversub_ratio => '0.9'
|
||||
}
|
||||
end
|
||||
|
||||
@ -32,6 +34,10 @@ describe 'cinder::backend::nfs' do
|
||||
'/cinder_mount_point')
|
||||
should contain_cinder_config('hippo/nfs_disk_util').with_value(
|
||||
'du')
|
||||
should contain_cinder_config('hippo/nfs_used_ratio').with_value(
|
||||
'0.7')
|
||||
should contain_cinder_config('hippo/nfs_oversub_ratio').with_value(
|
||||
'0.9')
|
||||
should contain_file('/etc/cinder/other_shares.conf').with(
|
||||
:content => "10.10.10.10:/shares\n10.10.10.10:/shares2",
|
||||
:require => 'Package[cinder]',
|
||||
|
Loading…
x
Reference in New Issue
Block a user