Rewriting the code to fit puppet style

- The code has been modified to fit the puppet style
  without functional changes
  (https://docs.puppetlabs.com/guides/style_guide.html)
- Fixed typo in descriptions of several classes
- Fixed typo in rbd.pp on line 45

Change-Id: I6ce8ce53abe3fa4f00606259330be0604e1347e4
This commit is contained in:
Alexander Noskov 2016-01-22 15:39:16 +03:00
parent dab3a5291e
commit 27fe0790f8
15 changed files with 260 additions and 235 deletions

View File

@ -1,2 +1,2 @@
$fuel_settings = parseyaml($astute_settings_yaml)
class {'plugin_cinder_netapp::cinder': }
class { 'plugin_cinder_netapp::cinder': }

View File

@ -1,2 +1,2 @@
$fuel_settings = parseyaml($astute_settings_yaml)
class {'plugin_cinder_netapp::compute': }
class { 'plugin_cinder_netapp::compute': }

View File

@ -1,2 +1,2 @@
$fuel_settings = parseyaml($astute_settings_yaml)
class {'plugin_cinder_netapp::controller': }
class { 'plugin_cinder_netapp::controller': }

View File

@ -2,7 +2,7 @@
#
# [iscsi_ip_address] The IP address that the iSCSI daemon is listening on
# [iscsi_helper] iSCSI target user-land tool to use
# [volume_group] Name for the VG that will contain exported volumes)
# [volume_group] Name for the VG that will contain exported volumes
#
# === Examples
#
@ -12,16 +12,17 @@
# $volume_group = 'cinder' ,
# }
#
class plugin_cinder_netapp::backend::iscsi(
$volume_group = 'cinder'
)
{
$iscsi_ip_address = $::internal_address
$iscsi_helper = $cinder::params::iscsi_helper
cinder_config {
"cinder_isci/volume_backend_name": value => 'cinder_isci';
"cinder_isci/iscsi_ip_address": value => $iscsi_ip_address;
"cinder_isci/iscsi_helper": value => $iscsi_helper;
"cinder_isci/volume_group": value => $volume_group;
}
}
class plugin_cinder_netapp::backend::iscsi (
$volume_group = 'cinder',
$iscsi_ip_address = $::internal_address,
$iscsi_helper = $::cinder::params::iscsi_helper,
) {
cinder_config {
'cinder_iscsi/volume_backend_name': value => 'cinder_iscsi';
'cinder_iscsi/iscsi_ip_address': value => $iscsi_ip_address;
'cinder_iscsi/iscsi_helper': value => $iscsi_helper;
'cinder_iscsi/volume_group': value => $volume_group;
}
}

View File

@ -1,7 +1,7 @@
# this can be used to create a netapp volume backend for cinder
#
# [section] name of the sectoin of cinder.conf on which netapp parameters should be inserted
# [backends] name of the other backends in a multibackend config (optionnal)
# [section] name of the section of cinder.conf on which netapp parameters should be inserted
# [backends] name of the other backends in a multibackend config (optional)
#
# === Examples
#
@ -11,46 +11,51 @@
#
define plugin_cinder_netapp::backend::netapp (
$section = $name,
$backends = "",
$backends = '',
$backend_name = 'cinder_netapp',
$mutlibackends = false,
$cinder_node = false
) {
include cinder::client
#Ensure that $ symbole is correctly escaped in netapp password
$netapp_password = regsubst($::fuel_settings['cinder_netapp']['netapp_password'],'\$','$$','G')
$backend_name = 'cinder_netapp'
cinder::backend::netapp { "${backend_name}":
volume_backend_name => $section,
netapp_login => $::fuel_settings['cinder_netapp']['netapp_login'],
netapp_password => $netapp_password,
netapp_server_hostname => $::fuel_settings['cinder_netapp']['netapp_server_hostname'],
netapp_server_port => $::fuel_settings['cinder_netapp']['netapp_server_port'],
netapp_transport_type => $::fuel_settings['cinder_netapp']['netapp_transport_type'],
netapp_storage_family => $::fuel_settings['cinder_netapp']['netapp_storage_family'],
netapp_storage_protocol => $::fuel_settings['cinder_netapp']['netapp_storage_protocol'],
netapp_vserver => $::fuel_settings['cinder_netapp']['netapp_vserver'],
netapp_controller_ips => $::fuel_settings['cinder_netapp']['netapp_controller_ips'],
netapp_sa_password => $::fuel_settings['cinder_netapp']['netapp_sa_password'],
netapp_storage_pools => $::fuel_settings['cinder_netapp']['netapp_storage_pools'],
netapp_size_multiplier => $::fuel_settings['cinder_netapp']['netapp_size_multiplier'],
netapp_vfiler => $::fuel_settings['cinder_netapp']['netapp_vfiler'],
netapp_volume_list => $::fuel_settings['cinder_netapp']['netapp_volume_list'],
expiry_thres_minutes => $::fuel_settings['cinder_netapp']['expiry_thres_minutes'],
thres_avl_size_perc_start => $::fuel_settings['cinder_netapp']['thres_avl_size_perc_start'],
thres_avl_size_perc_stop => $::fuel_settings['cinder_netapp']['thres_avl_size_perc_stop'],
netapp_copyoffload_tool_path => $::fuel_settings['cinder_netapp']['netapp_copyoffload_tool_path'],
$cinder_node = false,
) {
include cinder::client
# Ensure that $ symbole is correctly escaped in netapp password
$netapp_password = regsubst($::fuel_settings['cinder_netapp']['netapp_password'],'\$','$$','G')
cinder::backend::netapp { $backend_name:
volume_backend_name => $section,
netapp_login => $::fuel_settings['cinder_netapp']['netapp_login'],
netapp_password => $netapp_password,
netapp_server_hostname => $::fuel_settings['cinder_netapp']['netapp_server_hostname'],
netapp_server_port => $::fuel_settings['cinder_netapp']['netapp_server_port'],
netapp_transport_type => $::fuel_settings['cinder_netapp']['netapp_transport_type'],
netapp_storage_family => $::fuel_settings['cinder_netapp']['netapp_storage_family'],
netapp_storage_protocol => $::fuel_settings['cinder_netapp']['netapp_storage_protocol'],
netapp_vserver => $::fuel_settings['cinder_netapp']['netapp_vserver'],
netapp_controller_ips => $::fuel_settings['cinder_netapp']['netapp_controller_ips'],
netapp_sa_password => $::fuel_settings['cinder_netapp']['netapp_sa_password'],
netapp_storage_pools => $::fuel_settings['cinder_netapp']['netapp_storage_pools'],
netapp_size_multiplier => $::fuel_settings['cinder_netapp']['netapp_size_multiplier'],
netapp_vfiler => $::fuel_settings['cinder_netapp']['netapp_vfiler'],
netapp_volume_list => $::fuel_settings['cinder_netapp']['netapp_volume_list'],
expiry_thres_minutes => $::fuel_settings['cinder_netapp']['expiry_thres_minutes'],
thres_avl_size_perc_start => $::fuel_settings['cinder_netapp']['thres_avl_size_perc_start'],
thres_avl_size_perc_stop => $::fuel_settings['cinder_netapp']['thres_avl_size_perc_stop'],
netapp_copyoffload_tool_path => $::fuel_settings['cinder_netapp']['netapp_copyoffload_tool_path'],
}
$index = $::fuel_settings['cinder_netapp']['nb_share']
if $mutlibackends {
cinder_config {
'DEFAULT/enabled_backends': value => "${backends},${backend_name}";
}
$index = $::fuel_settings['cinder_netapp']['nb_share']
if $mutlibackends{
cinder_config {
"DEFAULT/enabled_backends": value => "${backends},${backend_name}";
}
}
if $cinder_node{
plugin_cinder_netapp::backend::share{ "share-${index}":
index => $index
}
}
if $cinder_node {
plugin_cinder_netapp::backend::share{ "share-${index}":
index => $index
}
}
}

View File

@ -1,4 +1,4 @@
# this can be used to inssert into cinder_rbd section rbd configuration parameters
# this can be used to insert into cinder_rbd section rbd configuration parameters
#
# [rbd_pool] The RADOS pool where rbd volumes are stored
# [rbd_user] The RADOS client name for accessing rbd volumes
@ -6,7 +6,7 @@
# [rbd_flatten_volume_from_snapshot] Flatten volumes created from snapshots to remove dependency
# [rbd_secret_uuid] The libvirt uuid of the secret for the rbd_user volumes
# [volume_tmp_dir] Directory where temporary image files are stored when the
# volume driver does not write them directly to the volum)
# volume driver does not write them directly to the volume)
# [rbd_max_clone_depth] Maximum number of nested volume clones that are taken before
# a flatten occurs. Set to 0 to disable cloning.
# [glance_api_version] Version of the glance API to use
@ -24,7 +24,7 @@
# $glance_api_version = undef,
# }
#
class plugin_cinder_netapp::backend::rbd(
class plugin_cinder_netapp::backend::rbd (
$rbd_pool = 'volumes',
$rbd_user = 'volumes',
$rbd_ceph_conf = '/etc/ceph/ceph.conf',
@ -33,16 +33,17 @@ class plugin_cinder_netapp::backend::rbd(
$volume_tmp_dir = false,
$rbd_max_clone_depth = '5',
$glance_api_version = undef,
) {
){
cinder_config {
"cinder_rbd/volume_backend_name": value => 'cinder_rbd';
"cinder_rbd/volume_driver": value => 'cinder.volume.drivers.rbd.RBDDriver';
"cinder_rbd/rbd_ceph_conf": value => $rbd_ceph_conf;
"cinder_rbd/rbd_user": value => $rbd_user;
"cinder_rbd/rbd_pool": value => $rbd_pool;
"cinder_rbd/rbd_max_clone_depth": value => $rbd_max_clone_depth;
"cinder_rbd{name}/rbd_flatten_volume_from_snapshot": value => $rbd_flatten_volume_from_snapshot;
"cinder_rbd/host": value => "rbd:${rbd_pool}";
}
}
cinder_config {
'cinder_rbd/volume_backend_name': value => 'cinder_rbd';
'cinder_rbd/volume_driver': value => 'cinder.volume.drivers.rbd.RBDDriver';
'cinder_rbd/rbd_ceph_conf': value => $rbd_ceph_conf;
'cinder_rbd/rbd_user': value => $rbd_user;
'cinder_rbd/rbd_pool': value => $rbd_pool;
'cinder_rbd/rbd_max_clone_depth': value => $rbd_max_clone_depth;
'cinder_rbd/rbd_flatten_volume_from_snapshot': value => $rbd_flatten_volume_from_snapshot;
'cinder_rbd/host': value => "rbd:${rbd_pool}";
}
}

View File

@ -1,6 +1,6 @@
# this can be used to create recurively n shares for tnetapp volume backend
# this can be used to create recursively in shares for netapp volume backend
# [index] index of the current share
# [shares] shares previsouly create onf the followinf format <ip>:<share1>\n><ip>:<share2>\n....
# [shares] shares previously created of the following format <ip>:<share1>\n><ip>:<share2>\n....
#
# === Examples
#
@ -11,23 +11,24 @@
#
define plugin_cinder_netapp::backend::share (
$index,
$shares = ""
) {
$ip=$::fuel_settings['cinder_netapp']['nfs_server_ip']
$share=$::fuel_settings['cinder_netapp']["nfs_server_share${index}"]
$minus1 = inline_template('<%= index.to_i - 1 %>')
if ("${minus1}" == '0') {
# last share is reached, write information into shares.conf
file { '/etc/cinder/shares.conf':
content => "${ip}:${share}\n${shares}"
} ~>
service { $::cinder::params::volume_service:
}
} else{
# recurse until index 1 is reached
plugin_cinder_netapp::backend::share { "share-${minus1}":
index => $minus1,
shares => "${ip}:${share}\n${shares}",
}
$shares = '',
) {
$ip = $::fuel_settings['cinder_netapp']['nfs_server_ip']
$share = $::fuel_settings['cinder_netapp']["nfs_server_share${index}"]
$minus1 = inline_template('<%= index.to_i - 1 %>')
if ($minus1 == '0') {
# last share is reached, write information into shares.conf
file { '/etc/cinder/shares.conf':
content => "${ip}:${share}\n${shares}"
} ~>
service { $::cinder::params::volume_service: }
} else {
# recurse until index 1 is reached
plugin_cinder_netapp::backend::share { "share-${minus1}":
index => $minus1,
shares => "${ip}:${share}\n${shares}",
}
}
}
}

View File

@ -3,16 +3,20 @@
# cinder will used the netapp backend and the ceph or lvm (according to intial configuration)
# as multibackend storage
#
class plugin_cinder_netapp::cinder
inherits plugin_cinder_netapp::params {
$cinder_hash = $::fuel_settings['cinder']
if $::fuel_settings['cinder_netapp']['multibackend'] {
class { 'plugin_cinder_netapp::multibackend_cinder':}
} else {
$section = 'DEFAULT'
plugin_cinder_netapp::backend::netapp{ "cinder_netapp":
section => $section,
cinder_node => true
}
}
class plugin_cinder_netapp::cinder (
$cinder_hash = $::fuel_settings['cinder'],
) {
include plugin_cinder_netapp::params
if $::fuel_settings['cinder_netapp']['multibackend'] {
class { 'plugin_cinder_netapp::multibackend_cinder': }
} else {
$section = 'DEFAULT'
plugin_cinder_netapp::backend::netapp{ 'cinder_netapp':
section => $section,
cinder_node => true,
}
}
}

View File

@ -32,18 +32,17 @@
define plugin_cinder_netapp::cinder::type (
$os_password,
$volume_name = $name,
$set_key = undef,
$set_value = undef,
$os_tenant_name = 'admin',
$os_username = 'admin',
$os_auth_url = 'http://127.0.0.1:5000/v2.0/',
$os_region_name = undef,
) {
) {
$volume_name = $name
# TODO: (xarses) This should be moved to a ruby provider so that among other
# reasons, the credential discovery magic can occur like in neutron.
# TODO: (xarses) This should be moved to a ruby provider so that among other
# reasons, the credential discovery magic can occur like in neutron.
$cinder_env = [
"OS_TENANT_NAME=${os_tenant_name}",
@ -59,7 +58,7 @@ define plugin_cinder_netapp::cinder::type (
$region_env = []
}
exec {"cinder type-create ${volume_name}":
exec { "cinder type-create ${volume_name}":
command => "cinder type-create ${volume_name}",
unless => "cinder type-list | grep -qP '\\b${volume_name}\\b'",
environment => concat($cinder_env, $region_env),
@ -70,13 +69,14 @@ define plugin_cinder_netapp::cinder::type (
if ($set_value and $set_key) {
Exec["cinder type-create ${volume_name}"] ->
plugin_cinder_netapp::cinder::type_set { $set_value:
type => $volume_name,
key => $set_key,
os_password => $os_password,
os_tenant_name => $os_tenant_name,
os_username => $os_username,
os_auth_url => $os_auth_url,
os_region_name => $os_region_name,
type => $volume_name,
key => $set_key,
os_password => $os_password,
os_tenant_name => $os_tenant_name,
os_username => $os_username,
os_auth_url => $os_auth_url,
os_region_name => $os_region_name,
}
}
}
}

View File

@ -37,10 +37,10 @@ define plugin_cinder_netapp::cinder::type_set (
$os_username = 'admin',
$os_auth_url = 'http://127.0.0.1:5000/v2.0/',
$os_region_name = undef,
) {
) {
# TODO: (xarses) This should be moved to a ruby provider so that among other
# reasons, the credential discovery magic can occur like in neutron.
# TODO: (xarses) This should be moved to a ruby provider so that among other
# reasons, the credential discovery magic can occur like in neutron.
$cinder_env = [
"OS_TENANT_NAME=${os_tenant_name}",
@ -63,4 +63,5 @@ define plugin_cinder_netapp::cinder::type_set (
environment => concat($cinder_env, $region_env),
require => Package['python-cinderclient']
}
}
}

View File

@ -1,29 +1,30 @@
# This can be used to to install on compute required depedencies to use netapp volume
# This can be used to install on compute required depedencies to use netapp volume
#
class plugin_cinder_netapp::compute
{
include cinder::params
$cinder_hash = $::fuel_settings['cinder']
class plugin_cinder_netapp::compute {
case $::osfamily {
'Debian': {
package { 'nfs-common':
}
}
'RedHat': {
package { 'nfs-utils': } ->
service {'rpcbind':
ensure => running,
} ->
service {'rpcidmapd':
ensure => running,
} ->
service {'nfs':
ensure => running,
}
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports osfamily RedHat and Debian")
include cinder::params
$cinder_hash = $::fuel_settings['cinder']
case $::osfamily {
'Debian': {
package { 'nfs-common':
}
}
'RedHat': {
package { 'nfs-utils': } ->
service {'rpcbind':
ensure => running,
} ->
service {'rpcidmapd':
ensure => running,
} ->
service {'nfs':
ensure => running,
}
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports osfamily RedHat and Debian")
}
}
}

View File

@ -1,25 +1,28 @@
# The plugin_cinder_netapp class is able to inder to use netapp as a storage backend
# The plugin_cinder_netapp class is able to cinder to use netapp as a storage backend
# (7Mode and cluster mode storage familly). If the multibackend option is checked
# cinder will used the netapp backend and the ceph or lvm (according to intial configuration)
# as multibackend storage
#
class plugin_cinder_netapp::controller
inherits plugin_cinder_netapp::params {
class plugin_cinder_netapp::controller {
cinder_config {
"DEFAULT/host": value => "str:netapp";
include plugin_cinder_netapp::params
cinder_config {
'DEFAULT/host': value => 'str:netapp';
}
$cinder_hash = $::fuel_settings['cinder']
if $::fuel_settings['cinder_netapp']['multibackend'] {
class { 'plugin_cinder_netapp::multibackend_controller':
cinder_user_password => $cinder_hash['user_password'],
auth_host => hiera('management_vip', undef),
}
} else {
$section = 'DEFAULT'
plugin_cinder_netapp::backend::netapp{ 'cinder_netapp':
section => $section,
}
}
$cinder_hash = $::fuel_settings['cinder']
if $::fuel_settings['cinder_netapp']['multibackend'] {
class { 'plugin_cinder_netapp::multibackend_controller':
cinder_user_password => $cinder_hash[user_password],
auth_host => hiera('management_vip', undef)
}
} else {
$section = 'DEFAULT'
plugin_cinder_netapp::backend::netapp{ "cinder_netapp":
section => $section
}
}
}

View File

@ -1,14 +1,16 @@
# this can be used to insert into cinder_iscsi section lvm configuration parameters
#
class plugin_cinder_netapp::multibackend_cinder
inherits plugin_cinder_netapp::params {
include cinder::params
class plugin_cinder_netapp::multibackend_cinder {
include plugin_cinder_netapp::params
include cinder::params
class { $plugin_cinder_netapp::params::backend_class: } ->
plugin_cinder_netapp::backend::netapp{ 'cinder_netapp':
backends => $plugin_cinder_netapp::params::backends,
mutlibackends => true,
cinder_node => true,
}
class { $plugin_cinder_netapp::params::backend_class :} ->
plugin_cinder_netapp::backend::netapp{ "cinder_netapp":
backends => $plugin_cinder_netapp::params::backends,
mutlibackends => true,
cinder_node => true
}
}

View File

@ -1,12 +1,12 @@
# this can be used to insert into cinder_iscsi section lvm configuration parameters
# and setup multibaclend configuration conttroller
# and setup multibackend configuration controller
#
# [$cinder_user_password] password of the cinder user
# [$keystone_tenant] tenant services
# [$keystone_user] name of the cinder user
# [$keystone_auth_protocol] auth protocol for keystone
# [$auth_host] ip/hostname for kauthentication endpoint
# [$keystone_auth_port] nport for keystone
# [$auth_host] ip/hostname for authentication endpoint
# [$keystone_auth_port] port for keystone
#
# === Examples
#
@ -19,36 +19,41 @@
# $keystone_auth_port = '35357', ,
# }
#
class plugin_cinder_netapp::multibackend_controller(
class plugin_cinder_netapp::multibackend_controller (
$cinder_user_password,
$auth_host,
$keystone_tenant = 'services',
$keystone_user = 'cinder',
$keystone_auth_protocol = 'http',
$auth_host,
$keystone_auth_port = '35357',
$os_region_name = 'RegionOne',
)inherits plugin_cinder_netapp::params {
include cinder::params
$os_auth_url = "${keystone_auth_protocol}://${auth_host}:${keystone_auth_port}/v2.0/"
Plugin_cinder_netapp::Cinder::Type {
os_password => $cinder_user_password,
os_tenant_name => $keystone_tenant,
os_username => $keystone_user,
os_auth_url => $os_auth_url,
os_region_name => $os_region_name
}
#TODO use type from cinder module when bug 1461485 is fix
class { $plugin_cinder_netapp::params::backend_class :} ->
plugin_cinder_netapp::backend::netapp{ "cinder_netapp":
backends => $plugin_cinder_netapp::params::backends,
mutlibackends => true
}->
plugin_cinder_netapp::cinder::type {'netapp':
set_key => 'volume_backend_name',
set_value => 'cinder_netapp'
}->
plugin_cinder_netapp::cinder::type {"${plugin_cinder_netapp::params::backends}":
set_key => 'volume_backend_name',
set_value => "${plugin_cinder_netapp::params::backends}",
}
$os_auth_url = "${keystone_auth_protocol}://${auth_host}:${keystone_auth_port}/v2.0/",
) {
include plugin_cinder_netapp::params
include cinder::params
Plugin_cinder_netapp::Cinder::Type {
os_password => $cinder_user_password,
os_tenant_name => $keystone_tenant,
os_username => $keystone_user,
os_auth_url => $os_auth_url,
os_region_name => $os_region_name,
}
#TODO use type from cinder module when bug 1461485 is fix
class { $plugin_cinder_netapp::params::backend_class: } ->
plugin_cinder_netapp::backend::netapp{ 'cinder_netapp':
backends => $plugin_cinder_netapp::params::backends,
mutlibackends => true,
} ->
plugin_cinder_netapp::cinder::type { 'netapp':
set_key => 'volume_backend_name',
set_value => 'cinder_netapp',
} ->
plugin_cinder_netapp::cinder::type { $plugin_cinder_netapp::params::backends:
set_key => 'volume_backend_name',
set_value => $plugin_cinder_netapp::params::backends,
}
}

View File

@ -1,37 +1,38 @@
class plugin_cinder_netapp::params
{
include cinder::params
$cinder_hash = $::fuel_settings['cinder']
$storage_hash = $::fuel_settings['storage']
class plugin_cinder_netapp::params {
case $::osfamily {
'Debian': {
package { 'nfs-common':
before => Cinder::Backend::Netapp['cinder_netapp'],
}
}
'RedHat': {
package { 'nfs-utils': } ->
service {'rpcbind':
ensure => running,
} ->
service {'rpcidmapd':
ensure => running,
} ->
service {'nfs':
ensure => running,
before => Cinder::Backend::Netapp['cinder_netapp'],
}
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports osfamily RedHat and Debian")
include cinder::params
$cinder_hash = $::fuel_settings['cinder']
$storage_hash = $::fuel_settings['storage']
case $::osfamily {
'Debian': {
package { 'nfs-common':
before => Cinder::Backend::Netapp['cinder_netapp'],
}
}
if ($storage_hash['volumes_lvm']) {
$backends = 'cinder_isci'
$backend_class = 'plugin_cinder_netapp::backend::iscsi'
} elsif ($storage_hash['volumes_ceph']) {
$backends = 'cinder_rbd'
$backend_class = 'plugin_cinder_netapp::backend::rbd'
'RedHat': {
package { 'nfs-utils': } ->
service {'rpcbind':
ensure => running,
} ->
service {'rpcidmapd':
ensure => running,
} ->
service {'nfs':
ensure => running,
before => Cinder::Backend::Netapp['cinder_netapp'],
}
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports osfamily RedHat and Debian")
}
}
if ($storage_hash['volumes_lvm']) {
$backends = 'cinder_iscsi'
$backend_class = 'plugin_cinder_netapp::backend::iscsi'
} elsif ($storage_hash['volumes_ceph']) {
$backends = 'cinder_rbd'
$backend_class = 'plugin_cinder_netapp::backend::rbd'
}
}