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:
Sylvain Baubeau 2014-03-25 17:43:36 +01:00
parent 9b9e216802
commit c914f0ceb3
7 changed files with 64 additions and 146 deletions

View File

@ -13,7 +13,9 @@ define cinder::backend::nfs (
$nfs_disk_util = undef, $nfs_disk_util = undef,
$nfs_sparsed_volumes = undef, $nfs_sparsed_volumes = undef,
$nfs_mount_point_base = 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: file {$nfs_shares_config:
@ -31,5 +33,7 @@ define cinder::backend::nfs (
"${name}/nfs_disk_util": value => $nfs_disk_util; "${name}/nfs_disk_util": value => $nfs_disk_util;
"${name}/nfs_sparsed_volumes": value => $nfs_sparsed_volumes; "${name}/nfs_sparsed_volumes": value => $nfs_sparsed_volumes;
"${name}/nfs_mount_point_base": value => $nfs_mount_point_base; "${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;
} }
} }

View File

@ -5,42 +5,9 @@ class cinder::volume::iscsi (
$iscsi_helper = 'tgtadm' $iscsi_helper = 'tgtadm'
) { ) {
include cinder::params cinder::backend::iscsi { 'DEFAULT':
iscsi_ip_address => $iscsi_ip_address,
cinder_config { volume_group => $volume_group,
'DEFAULT/iscsi_ip_address': value => $iscsi_ip_address; iscsi_helper => $iscsi_helper
'DEFAULT/iscsi_helper': value => $iscsi_helper;
'DEFAULT/volume_group': value => $volume_group;
}
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}.")
}
}
}

View File

@ -171,28 +171,26 @@ class cinder::volume::netapp (
$netapp_webservice_path = '/devmgr/v2', $netapp_webservice_path = '/devmgr/v2',
) { ) {
cinder_config { cinder::backend::netapp { 'DEFAULT':
'DEFAULT/volume_driver': value => 'cinder.volume.drivers.netapp.common.NetAppDriver'; netapp_login => $netapp_login,
'DEFAULT/netapp_login': value => $netapp_login; netapp_password => $netapp_password,
'DEFAULT/netapp_password': value => $netapp_password, secret => true; netapp_server_hostname => $netapp_server_hostname,
'DEFAULT/netapp_server_hostname': value => $netapp_server_hostname; netapp_server_port => $netapp_server_port,
'DEFAULT/netapp_server_port': value => $netapp_server_port; netapp_size_multiplier => $netapp_size_multiplier,
'DEFAULT/netapp_size_multiplier': value => $netapp_size_multiplier; netapp_storage_family => $netapp_storage_family,
'DEFAULT/netapp_storage_family': value => $netapp_storage_family; netapp_storage_protocol => $netapp_storage_protocol,
'DEFAULT/netapp_storage_protocol': value => $netapp_storage_protocol; netapp_transport_type => $netapp_transport_type,
'DEFAULT/netapp_transport_type': value => $netapp_transport_type; netapp_vfiler => $netapp_vfiler,
'DEFAULT/netapp_vfiler': value => $netapp_vfiler; netapp_volume_list => $netapp_volume_list,
'DEFAULT/netapp_volume_list': value => $netapp_volume_list; netapp_vserver => $netapp_vserver,
'DEFAULT/netapp_vserver': value => $netapp_vserver; expiry_thres_minutes => $expiry_thres_minutes,
'DEFAULT/expiry_thres_minutes': value => $expiry_thres_minutes; thres_avl_size_perc_start => $thres_avl_size_perc_start,
'DEFAULT/thres_avl_size_perc_start': value => $thres_avl_size_perc_start; thres_avl_size_perc_stop => $thres_avl_size_perc_stop,
'DEFAULT/thres_avl_size_perc_stop': value => $thres_avl_size_perc_stop; nfs_shares_config => $nfs_shares_config,
'DEFAULT/nfs_shares_config': value => $nfs_shares_config; netapp_copyoffload_tool_path => $netapp_copyoffload_tool_path,
'DEFAULT/netapp_copyoffload_tool_path': value => $netapp_copyoffload_tool_path; netapp_controller_ips => $netapp_controller_ips,
'DEFAULT/netapp_controller_ips': value => $netapp_controller_ips; netapp_sa_password => $netapp_sa_password,
'DEFAULT/netapp_sa_password': value => $netapp_sa_password; netapp_storage_pools => $netapp_storage_pools,
'DEFAULT/netapp_storage_pools': value => $netapp_storage_pools; netapp_webservice_path => $netapp_webservice_path,
'DEFAULT/netapp_webservice_path': value => $netapp_webservice_path;
} }
} }

View File

@ -10,21 +10,14 @@ class cinder::volume::nfs (
$nfs_oversub_ratio = '1.0', $nfs_oversub_ratio = '1.0',
) { ) {
file {$nfs_shares_config: cinder::backend::nfs { 'DEFAULT':
content => join($nfs_servers, "\n"), nfs_servers => $nfs_servers,
require => Package['cinder'], nfs_mount_options => $nfs_mount_options,
notify => Service['cinder-volume'] nfs_disk_util => $nfs_disk_util,
} nfs_sparsed_volumes => $nfs_sparsed_volumes,
nfs_mount_point_base => $nfs_mount_point_base,
cinder_config { nfs_shares_config => $nfs_shares_config,
'DEFAULT/volume_driver': value => nfs_used_ratio => $nfs_used_ratio,
'cinder.volume.drivers.nfs.NfsDriver'; nfs_oversub_ratio => $nfs_oversub_ratio,
'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;
} }
} }

View File

@ -51,54 +51,14 @@ class cinder::volume::rbd (
$glance_api_version = undef, $glance_api_version = undef,
) { ) {
include cinder::params cinder::backend::rbd { 'DEFAULT':
rbd_pool => $rbd_pool,
if $glance_api_version { rbd_user => $rbd_user,
warning('The glance_api_version is deprecated, use glance_api_version of cinder::glance class instead.') rbd_ceph_conf => $rbd_ceph_conf,
} rbd_flatten_volume_from_snapshot => $rbd_flatten_volume_from_snapshot,
rbd_secret_uuid => $rbd_secret_uuid,
cinder_config { volume_tmp_dir => $volume_tmp_dir,
'DEFAULT/volume_driver': value => 'cinder.volume.drivers.rbd.RBDDriver'; rbd_max_clone_depth => $rbd_max_clone_depth,
'DEFAULT/rbd_ceph_conf': value => $rbd_ceph_conf; glance_api_version => $glance_api_version,
'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'],
}
}

View File

@ -58,25 +58,15 @@ class cinder::volume::vmdk(
$wsdl_location = undef $wsdl_location = undef
) { ) {
cinder_config { cinder::backend::vmdk { 'DEFAULT':
'DEFAULT/volume_driver': value => 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver'; host_ip => $host_ip,
'DEFAULT/vmware_host_ip': value => $host_ip; host_username => $host_username,
'DEFAULT/vmware_host_username': value => $host_username; host_password => $host_password,
'DEFAULT/vmware_host_password': value => $host_password; volume_folder => $volume_folder,
'DEFAULT/vmware_volume_folder': value => $volume_folder; api_retry_count => $api_retry_count,
'DEFAULT/vmware_api_retry_count': value => $api_retry_count; max_object_retrieval => $max_object_retrieval,
'DEFAULT/vmware_max_object_retrieval': value => $max_object_retrieval; task_poll_interval => $task_poll_interval,
'DEFAULT/vmware_task_poll_interval': value => $task_poll_interval; image_transfer_timeout_secs => $image_transfer_timeout_secs,
'DEFAULT/vmware_image_transfer_timeout_secs': value => $image_transfer_timeout_secs; wsdl_location => $wsdl_location,
}
if $wsdl_location {
cinder_config {
'DEFAULT/vmware_wsdl_location': value => $wsdl_location;
}
}
package{ 'python-suds':
ensure => present,
} }
} }

View File

@ -12,6 +12,8 @@ describe 'cinder::backend::nfs' do
:nfs_disk_util => 'du', :nfs_disk_util => 'du',
:nfs_sparsed_volumes => true, :nfs_sparsed_volumes => true,
:nfs_mount_point_base => '/cinder_mount_point', :nfs_mount_point_base => '/cinder_mount_point',
:nfs_used_ratio => '0.7',
:nfs_oversub_ratio => '0.9'
} }
end end
@ -32,6 +34,10 @@ describe 'cinder::backend::nfs' do
'/cinder_mount_point') '/cinder_mount_point')
should contain_cinder_config('hippo/nfs_disk_util').with_value( should contain_cinder_config('hippo/nfs_disk_util').with_value(
'du') '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( should contain_file('/etc/cinder/other_shares.conf').with(
:content => "10.10.10.10:/shares\n10.10.10.10:/shares2", :content => "10.10.10.10:/shares\n10.10.10.10:/shares2",
:require => 'Package[cinder]', :require => 'Package[cinder]',