Multi-Backend follow-up

- Update fixtures.yml to stable/havana
- Transform configuration hash
- Allow multiple backends with same driver
- Improve unit tests

Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
Emilien Macchi
2014-03-18 15:15:46 +01:00
parent 4b80f42930
commit 76eadfa9d2
7 changed files with 356 additions and 134 deletions

View File

@@ -2,7 +2,7 @@ fixtures:
repositories: repositories:
'cinder': 'cinder':
repo: 'git://github.com/enovance/puppet-cinder' repo: 'git://github.com/enovance/puppet-cinder'
ref: '164163a7a267ae4139e2d97bab1a385a6da2ac5f' ref: '3a0f09995625b1c2f6ec446cc2a2571348a7af0b'
'keystone': 'keystone':
repo: 'git://github.com/enovance/puppet-keystone.git' repo: 'git://github.com/enovance/puppet-keystone.git'
ref: '9802add6566646dc1e4a2812d19c2ab4724ff594' ref: '9802add6566646dc1e4a2812d19c2ab4724ff594'

View File

@@ -0,0 +1,200 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Configure NetApp backend for Cinder
#
#
# === Parameters
#
# [*netapp_login*]
# (required) Administrative user account name used to access the storage
# system or proxy server.
#
# [*netapp_password*]
# (required) Password for the administrative user account specified in the
# netapp_login parameter.
#
# [*netapp_server_hostname*]
# (required) The hostname (or IP address) for the storage system or proxy
# server.
#
# [*netapp_server_port*]
# (optional) The TCP port to use for communication with ONTAPI on the
# storage system. Traditionally, port 80 is used for HTTP and port 443 is
# used for HTTPS; however, this value should be changed if an alternate
# port has been configured on the storage system or proxy server.
# Defaults to 80
#
# [*netapp_size_multiplier*]
# (optional) The quantity to be multiplied by the requested volume size to
# ensure enough space is available on the virtual storage server (Vserver) to
# fulfill the volume creation request.
# Defaults to 1.2
#
# [*netapp_storage_family*]
# (optional) The storage family type used on the storage system; valid values
# are ontap_7mode for using Data ONTAP operating in 7-Mode or ontap_cluster
# for using clustered Data ONTAP, or eseries for NetApp E-Series.
# Defaults to ontap_cluster
#
# [*netapp_storage_protocol*]
# (optional) The storage protocol to be used on the data path with the storage
# system; valid values are iscsi or nfs.
# Defaults to nfs
#
# [*netapp_transport_type*]
# (optional) The transport protocol used when communicating with ONTAPI on the
# storage system or proxy server. Valid values are http or https.
# Defaults to http
#
# [*netapp_vfiler*]
# (optional) The vFiler unit on which provisioning of block storage volumes
# will be done. This parameter is only used by the driver when connecting to
# an instance with a storage family of Data ONTAP operating in 7-Mode and the
# storage protocol selected is iSCSI. Only use this parameter when utilizing
# the MultiStore feature on the NetApp storage system.
# Defaults to ''
#
# [*netapp_volume_list*]
# (optional) This parameter is only utilized when the storage protocol is
# configured to use iSCSI. This parameter is used to restrict provisioning to
# the specified controller volumes. Specify the value of this parameter to be
# a comma separated list of NetApp controller volume names to be used for
# provisioning.
# Defaults to ''
#
# [*netapp_vserver*]
# (optional) This parameter specifies the virtual storage server (Vserver)
# name on the storage cluster on which provisioning of block storage volumes
# should occur. If using the NFS storage protocol, this parameter is mandatory
# for storage service catalog support (utilized by Cinder volume type
# extra_specs support). If this parameter is specified, the exports belonging
# to the Vserver will only be used for provisioning in the future. Block
# storage volumes on exports not belonging to the Vserver specified by
# this parameter will continue to function normally.
# Defaults to ''
#
# [*expiry_thres_minutes*]
# (optional) This parameter specifies the threshold for last access time for
# images in the NFS image cache. When a cache cleaning cycle begins, images
# in the cache that have not been accessed in the last M minutes, where M is
# the value of this parameter, will be deleted from the cache to create free
# space on the NFS share.
# Defaults to 720
#
# [*thres_avl_size_perc_start*]
# (optional) If the percentage of available space for an NFS share has
# dropped below the value specified by this parameter, the NFS image cache
# will be cleaned.
# Defaults to 20
#
# [*thres_avl_size_perc_stop*]
# (optional) When the percentage of available space on an NFS share has
# reached the percentage specified by this parameter, the driver will stop
# clearing files from the NFS image cache that have not been accessed in the
# last M minutes, where M is the value of the expiry_thres_minutes parameter.
# Defaults to 60
#
# [*nfs_shares_config*]
# (optional) File with the list of available NFS shares
# Defaults to ''
#
# [*netapp_copyoffload_tool_path*]
# (optional) This option specifies the path of the NetApp Copy Offload tool
# binary. Ensure that the binary has execute permissions set which allow the
# effective user of the cinder-volume process to execute the file.
# Defaults to ''
#
# [*netapp_controller_ips*]
# (optional) This option is only utilized when the storage family is
# configured to eseries. This option is used to restrict provisioning to the
# specified controllers. Specify the value of this option to be a comma
# separated list of controller hostnames or IP addresses to be used for
# provisioning.
# Defaults to ''
#
# [*netapp_sa_password*]
# (optional) Password for the NetApp E-Series storage array.
# Defaults to ''
#
# [*netapp_storage_pools*]
# (optional) This option is used to restrict provisioning to the specified
# storage pools. Only dynamic disk pools are currently supported. Specify the
# value of this option to be a comma separated list of disk pool names to be
# used for provisioning.
# Defaults to ''
#
# [*netapp_webservice_path*]
# (optional) This option is used to specify the path to the E-Series proxy
# application on a proxy server. The value is combined with the value of the
# netapp_transport_type, netapp_server_hostname, and netapp_server_port
# options to create the URL used by the driver to connect to the proxy
# application.
# Defaults to '/devmgr/v2'
#
define cloud::volume::backend::netapp (
$netapp_login,
$netapp_password,
$netapp_server_hostname,
$volume_backend_name = $name,
$netapp_server_port = '80',
$netapp_size_multiplier = '1.2',
$netapp_storage_family = 'ontap_cluster',
$netapp_storage_protocol = 'nfs',
$netapp_transport_type = 'http',
$netapp_vfiler = '',
$netapp_volume_list = '',
$netapp_vserver = '',
$expiry_thres_minutes = '720',
$thres_avl_size_perc_start = '20',
$thres_avl_size_perc_stop = '60',
$nfs_shares_config = '',
$netapp_copyoffload_tool_path = '',
$netapp_controller_ips = '',
$netapp_sa_password = '',
$netapp_storage_pools = '',
$netapp_webservice_path = '/devmgr/v2',
) {
cinder::backend::netapp { $name:
netapp_server_hostname => $netapp_server_hostname,
netapp_login => $netapp_login,
netapp_password => $netapp_password,
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,
}
@cinder::type { $volume_backend_name:
set_key => 'volume_backend_name',
set_value => $volume_backend_name
}
}

View File

@@ -0,0 +1,83 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Configure RBD backend for Cinder
#
#
# === Parameters
#
# [*rbd_pool*]
# (required) Specifies the pool name for the block device driver.
#
# [*rbd_user*]
# (required) A required parameter to configure OS init scripts and cephx.
#
# [*volume_backend_name*]
# Allows for the volume_backend_name to be separate of $name.
#
# [*rbd_ceph_conf*]
# (optional) Path to the ceph configuration file to use
# Defaults to '/etc/ceph/ceph.conf'
#
# [*rbd_flatten_volume_from_snapshot*]
# (optional) Enable flatten volumes created from snapshots.
# Defaults to false
#
# [*rbd_secret_uuid*]
# (optional) A required parameter to use cephx.
# Defaults to false
#
# [*volume_tmp_dir*]
# (optional) Location to store temporary image files if the volume
# driver does not write them directly to the volume
# Defaults to false
#
# [*rbd_max_clone_depth*]
# (optional) Maximum number of nested clones that can be taken of a
# volume before enforcing a flatten prior to next clone.
# A value of zero disables cloning
# Defaults to '5'
#
define cloud::volume::backend::rbd (
$rbd_pool,
$rbd_user,
$volume_backend_name = $name,
$rbd_ceph_conf = '/etc/ceph/ceph.conf',
$rbd_flatten_volume_from_snapshot = false,
$rbd_secret_uuid = false,
$volume_tmp_dir = false,
$rbd_max_clone_depth = '5',
) {
cinder::backend::rbd { $volume_backend_name:
rbd_pool => $rbd_pool,
rbd_user => $rbd_user,
rbd_secret_uuid => $rbd_secret_uuid,
rbd_ceph_conf => $rbd_ceph_conf,
rbd_flatten_volume_from_snapshot => $rbd_flatten_volume_from_snapshot,
rbd_max_clone_depth => $rbd_max_clone_depth,
}
# Configure Ceph keyring
Ceph::Key <<| title == $rbd_user |>>
ensure_resource('file', "/etc/ceph/ceph.client.${rbd_user}.keyring", {'owner' => 'cinder', 'group' => 'cinder', 'mode' => '0400', 'require' => "Ceph::Key[$rbd_user]" })
Concat::Fragment <<| title == 'ceph-client-os' |>>
@cinder::type { $volume_backend_name:
set_key => 'volume_backend_name',
set_value => $volume_backend_name
}
}

View File

@@ -17,29 +17,6 @@
# #
# === Parameters # === Parameters
# #
# [*cinder_rbd_pool*]
# (optional) Specifies the pool name for the block device driver.
#
# [*cinder_rbd_user*]
# (optional) A required parameter to configure OS init scripts and cephx.
#
# [*cinder_rbd_secret_uuid*]
# (optional) A required parameter to use cephx.
#
# [*cinder_rbd_conf*]
# (optional) Path to the ceph configuration file to use
# Defaults to '/etc/ceph/ceph.conf'
#
# [*cinder_rbd_flatten_volume_from_snapshot*]
# (optional) Enalbe flatten volumes created from snapshots.
# Defaults to false
#
# [*cinder_rbd_max_clone_depth*]
# (optional) Maximum number of nested clones that can be taken of a
# volume before enforcing a flatten prior to next clone.
# A value of zero disables cloning
# Defaults to '5'
#
# [*ks_keystone_internal_proto*] # [*ks_keystone_internal_proto*]
# (optional) Protocol used to connect to API. Could be 'http' or 'https'. # (optional) Protocol used to connect to API. Could be 'http' or 'https'.
# Defaults to 'http' # Defaults to 'http'
@@ -58,7 +35,17 @@
# #
# [*cinder_backends*] # [*cinder_backends*]
# (optionnal) Hash of the Cinder backends to enable # (optionnal) Hash of the Cinder backends to enable
# Defaults to undef # Example:
# cinder_backends = {
# 'rbd' => {
# 'lowcost' => { 'rbd_pool' => 'slow', 'rbd_user' => 'cinder', 'rbd_secret_uuid' => '123' },
# 'standard' => { 'rbd_pool' => 'normal', 'rbd_user' => 'cinder', 'rbd_secret_uuid' => '123' }
# }
# 'netapp' => {
# 'premium' => { 'netapp_server_hostname' => 'netapp.host', 'netapp_login' => 'joe', 'netapp_password' => 'secret' }
# }
# }
# Defaults to undef to maintain backward compatibility.
# #
@@ -90,22 +77,19 @@ class cloud::volume::storage(
if has_key($cinder_backends, 'netapp') { if has_key($cinder_backends, 'netapp') {
$netapp_backends = $cinder_backends['netapp'] $netapp_backends = $cinder_backends['netapp']
create_resources('cloud::volume::storage::netapp', create_resources('cloud::volume::backend::netapp', $netapp_backends)
$netapp_backends)
} }
else { else {
$netapp_backends = { } $netapp_backends = { }
} }
class { 'cinder::backends': class { 'cinder::backends':
enabled_backends => keys(merge($rbd_backends, enabled_backends => keys(merge($rbd_backends, $netapp_backends))
$netapp_backends))
} }
# Manage Volume types. # Manage Volume types.
# It allows to the end-user to choose from which backend he would like to provision a volume. # It allows to the end-user to choose from which backend he would like to provision a volume.
# Cinder::Type requires keystone credentials # Cinder::Type requires keystone credentials
Cinder::Type <| |> { Cinder::Type <| |> {
os_tenant_name => 'services', os_tenant_name => 'services',
os_username => 'cinder', os_username => 'cinder',
@@ -113,21 +97,18 @@ class cloud::volume::storage(
os_auth_url => "${ks_keystone_internal_proto}://${ks_keystone_internal_host}:${ks_keystone_internal_port}/v2.0" os_auth_url => "${ks_keystone_internal_proto}://${ks_keystone_internal_host}:${ks_keystone_internal_port}/v2.0"
} }
} }
# For backward compatibility when not using multi-backend
else { else {
$rbd_backends = { 'DEFAULT' => { } } $rbd_backends = { 'DEFAULT' => { } }
} }
if ! empty($rbd_backends) { if ! empty($rbd_backends) {
create_resources("cloud::volume::storage::rbd", create_resources('cloud::volume::backend::rbd', $rbd_backends,
$rbd_backends, { rbd_pool => $cinder_rbd_pool,
{ rbd_user => $cinder_rbd_user,
rbd_pool => $cinder_rbd_pool, rbd_secret_uuid => $cinder_rbd_secret_uuid,
rbd_user => $cinder_rbd_user, rbd_ceph_conf => $cinder_rbd_conf,
rbd_secret_uuid => $cinder_rbd_secret_uuid, rbd_flatten_volume_from_snapshot => $cinder_rbd_flatten_volume_from_snapshot,
rbd_ceph_conf => $cinder_rbd_conf, rbd_max_clone_depth => $cinder_rbd_max_clone_depth })
rbd_flatten_volume_from_snapshot => $cinder_rbd_flatten_volume_from_snapshot,
rbd_max_clone_depth => $cinder_rbd_max_clone_depth,
glance_api_version => $glance_api_version,
})
} }
} }

View File

@@ -1,37 +0,0 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Volume Ceph storage
#
define cloud::volume::storage::netapp (
$volume_backend_name = $name,
$netapp_backend = false,
$netapp_server_hostname = '127.0.0.1',
$netapp_login = 'netapp',
$netapp_password = 'secrete',
) {
cinder::backend::netapp { $name:
netapp_server_hostname => $netapp_server_hostname,
netapp_login => $netapp_login,
netapp_password => $netapp_password,
}
@cinder::type { $volume_backend_name:
set_key => 'volume_backend_name',
set_value => $volume_backend_name
}
}

View File

@@ -1,54 +0,0 @@
#
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Volume Ceph storage
#
define cloud::volume::storage::rbd (
$volume_backend_name = $name,
$rbd_pool,
$glance_api_version,
$rbd_user,
$rbd_secret_uuid,
$rbd_ceph_conf,
$rbd_flatten_volume_from_snapshot,
$rbd_max_clone_depth,
) {
cinder::backend::rbd { $volume_backend_name:
rbd_pool => $rbd_pool,
glance_api_version => $glance_api_version,
rbd_user => $rbd_user,
rbd_secret_uuid => $rbd_secret_uuid,
rbd_ceph_conf => $rbd_ceph_conf,
rbd_flatten_volume_from_snapshot => $rbd_flatten_volume_from_snapshot,
rbd_max_clone_depth => $rbd_max_clone_depth,
}
# Configure Ceph keyring
Ceph::Key <<| title == $rbd_user |>>
file { "/etc/ceph/ceph.client.${rbd_user}.keyring":
owner => 'cinder',
group => 'cinder',
mode => '0400',
require => Ceph::Key[$rbd_user]
}
Concat::Fragment <<| title == 'ceph-client-os' |>>
@cinder::type { $volume_backend_name:
set_key => 'volume_backend_name',
set_value => $volume_backend_name
}
}

View File

@@ -122,6 +122,56 @@ describe 'cloud::volume::storage' do
end end
end end
# This context can't work now, because of https://bugs.launchpad.net/puppet-cinder/+bug/1294138
# context 'with two RBD backends' do
# before :each do
# params.merge!(
# :cinder_backends => {
# 'rbd' => {
# 'lowcost' => {
# 'rbd_pool' => 'low',
# 'rbd_user' => 'cinder',
# 'rbd_secret_uuid' => 'secret',
# },
# 'normal' => {
# 'rbd_pool' => 'normal',
# 'rbd_user' => 'cinder',
# 'rbd_secret_uuid' => 'secret',
# }
# }
# }
# )
# end
#
#
# it 'configures two rbd volume backends' do
# should contain_cinder_config('lowcost/volume_backend_name').with_value('lowcost')
# should contain_cinder_config('lowcost/rbd_pool').with_value('low')
# should contain_cinder_config('lowcost/rbd_user').with_value('cinder')
# should contain_cinder_config('lowcost/rbd_secret_uuid').with_value('secret')
# should contain_cinder__type('lowcost').with(
# :set_key => 'volume_backend_name',
# :set_value => 'lowcost',
# :os_tenant_name => 'services',
# :os_username => 'cinder',
# :os_password => 'secret',
# :os_auth_url => 'http://keystone.host:5000/v2.0'
# )
# should contain_cinder_config('normal/volume_backend_name').with_value('normal')
# should contain_cinder_config('normal/rbd_pool').with_value('normal')
# should contain_cinder_config('normal/rbd_user').with_value('cinder')
# should contain_cinder_config('normal/rbd_secret_uuid').with_value('secret')
# should contain_cinder__type('normal').with(
# :set_key => 'volume_backend_name',
# :set_value => 'normal',
# :os_tenant_name => 'services',
# :os_username => 'cinder',
# :os_password => 'secret',
# :os_auth_url => 'http://keystone.host:5000/v2.0'
# )
# end
# end
context 'with all backends enabled' do context 'with all backends enabled' do
it 'configure all cinder backends' do it 'configure all cinder backends' do
should contain_class('cinder::backends').with( should contain_class('cinder::backends').with(
@@ -143,8 +193,7 @@ describe 'cloud::volume::storage' do
:rbd_secret_uuid => 'secret', :rbd_secret_uuid => 'secret',
:rbd_ceph_conf => '/etc/ceph/ceph.conf', :rbd_ceph_conf => '/etc/ceph/ceph.conf',
:rbd_flatten_volume_from_snapshot => false, :rbd_flatten_volume_from_snapshot => false,
:rbd_max_clone_depth => '10', :rbd_max_clone_depth => '10'
:glance_api_version => '2'
) )
end end
end end