Refactor cinder plugin and extend it with multiple backends support

Closes-Bug: rhbz#1139246
Change-Id: I9803939d45e9bafea9b21274a4c64248a037cd33
This commit is contained in:
Lukas Bezdicka
2014-09-03 09:39:35 -04:00
parent 67b98ec179
commit 770d5da931
14 changed files with 786 additions and 753 deletions

View File

@@ -163,8 +163,7 @@ Cinder Config parameters
The password to use for the Cinder to authenticate with Keystone. The password to use for the Cinder to authenticate with Keystone.
**CONFIG_CINDER_BACKEND** **CONFIG_CINDER_BACKEND**
The Cinder backend to use ['lvm', 'gluster', 'nfs', 'vmdk', 'netapp']. A comma separated ordered list of the Cinder backends to use, valid options are: lvm, gluster, nfs, vmdk.
Cinder volume create Config parameters Cinder volume create Config parameters
-------------------------------------- --------------------------------------

File diff suppressed because it is too large Load Diff

View File

@@ -511,11 +511,11 @@ def create_compute_manifest(config, messages):
manifestdata += getManifestTemplate("nova_compute_libvirt.pp") manifestdata += getManifestTemplate("nova_compute_libvirt.pp")
if (config['CONFIG_VMWARE_BACKEND'] != 'y' and if (config['CONFIG_VMWARE_BACKEND'] != 'y' and
config['CONFIG_CINDER_INSTALL'] == 'y' and config['CONFIG_CINDER_INSTALL'] == 'y' and
config['CONFIG_CINDER_BACKEND'] == 'gluster'): 'gluster' in config['CONFIG_CINDER_BACKEND']):
manifestdata += getManifestTemplate("nova_gluster.pp") manifestdata += getManifestTemplate("nova_gluster.pp")
if (config['CONFIG_VMWARE_BACKEND'] != 'y' and if (config['CONFIG_VMWARE_BACKEND'] != 'y' and
config['CONFIG_CINDER_INSTALL'] == 'y' and config['CONFIG_CINDER_INSTALL'] == 'y' and
config['CONFIG_CINDER_BACKEND'] == 'nfs'): 'nfs' in config['CONFIG_CINDER_BACKEND']):
manifestdata += getManifestTemplate("nova_nfs.pp") manifestdata += getManifestTemplate("nova_nfs.pp")
manifestfile = "%s_nova.pp" % host manifestfile = "%s_nova.pp" % host

View File

@@ -1,16 +1,16 @@
cinder_config { cinder_config {
"DEFAULT/glance_host": value => "%(CONFIG_STORAGE_HOST)s"; "DEFAULT/glance_host": value => "%(CONFIG_STORAGE_HOST)s";
} }
package {'python-keystone': package {'python-keystone':
notify => Class['cinder::api'], notify => Class['cinder::api'],
} }
class {'cinder::api': class {'cinder::api':
keystone_password => '%(CONFIG_CINDER_KS_PW)s', keystone_password => '%(CONFIG_CINDER_KS_PW)s',
keystone_tenant => "services", keystone_tenant => "services",
keystone_user => "cinder", keystone_user => "cinder",
keystone_auth_host => "%(CONFIG_CONTROLLER_HOST)s", keystone_auth_host => "%(CONFIG_CONTROLLER_HOST)s",
} }
class {'cinder::scheduler': class {'cinder::scheduler':
@@ -19,3 +19,17 @@ class {'cinder::scheduler':
class {'cinder::volume': class {'cinder::volume':
} }
class {'cinder::client':
}
# Cinder::Type requires keystone credentials
Cinder::Type {
os_password => '%(CONFIG_CINDER_KS_PW)s',
os_tenant_name => "services",
os_username => "cinder",
os_auth_url => "http://%(CONFIG_CONTROLLER_HOST)s:5000/v2.0/",
}
class { 'cinder::backends':
enabled_backends => %(CONFIG_CINDER_BACKEND)s,
}

View File

@@ -1,8 +1,8 @@
class {'cinder::backup': class { 'cinder::backup':
} }
class {'cinder::backup::swift': class { 'cinder::backup::swift':
backup_swift_url => 'http://%(CONFIG_CONTROLLER_HOST)s:8080/v1/AUTH_' backup_swift_url => 'http://%(CONFIG_CONTROLLER_HOST)s:8080/v1/AUTH_'
} }
Class['cinder::api'] ~> Service['cinder-backup'] Class['cinder::api'] ~> Service['cinder-backup']

View File

@@ -1,6 +1,13 @@
package { 'glusterfs-fuse': ensure => present } package { 'glusterfs-fuse': ensure => present }
class { 'cinder::volume::glusterfs': cinder::backend::glusterfs { 'gluster':
glusterfs_shares => [%(CONFIG_CINDER_GLUSTER_MOUNTS)s], glusterfs_shares => [%(CONFIG_CINDER_GLUSTER_MOUNTS)s],
require => Package['glusterfs-fuse'], require => Package['glusterfs-fuse'],
glusterfs_shares_config => '/etc/cinder/glusterfs_shares.conf',
}
cinder::type { 'glusterfs':
set_key => 'volume_backend_name',
set_value => 'gluster',
require => Class['cinder::api'],
} }

View File

@@ -1,9 +1,81 @@
class { 'cinder::setup_test_volume':
package { 'lvm2': size => '%(CONFIG_CINDER_VOLUMES_SIZE)s',
ensure => installed, loopback_device => '/dev/loop2',
volume_path => '/var/lib/cinder',
volume_name => 'cinder-volumes',
} }
class {'cinder::volume::iscsi': # Add loop device on boot
$el_releases = ["RedHat", "CentOS", "Scientific"]
if $::operatingsystem in $el_releases and $::operatingsystemmajrelease < 7 {
file_line{ 'rc.local_losetup_cinder_volume':
path => '/etc/rc.d/rc.local',
match => '^.*/var/lib/cinder/cinder-volumes.*$',
line => 'losetup -f /var/lib/cinder/cinder-volumes && service openstack-cinder-volume restart',
}
file { '/etc/rc.d/rc.local':
mode => '0755',
}
} else {
file { 'openstack-losetup':
path => '/usr/lib/systemd/system/openstack-losetup.service',
before => Service['openstack-losetup'],
notify => Exec['/usr/bin/systemctl daemon-reload'],
content => '[Unit]
Description=Setup cinder-volume loop device
DefaultDependencies=false
Before=openstack-cinder-volume.service
After=local-fs.target
[Service]
Type=oneshot
ExecStart=/usr/bin/sh -c \'/usr/sbin/losetup -j /var/lib/cinder/cinder-volumes | /usr/bin/grep /var/lib/cinder/cinder-volumes || /usr/sbin/losetup -f /var/lib/cinder/cinder-volumes\'
ExecStop=/usr/bin/sh -c \'/usr/sbin/losetup -j /var/lib/cinder/cinder-volumes | /usr/bin/cut -d : -f 1 | /usr/bin/xargs /usr/sbin/losetup -d\'
TimeoutSec=60
RemainAfterExit=yes
[Install]
RequiredBy=openstack-cinder-volume.service',
}
exec { '/usr/bin/systemctl daemon-reload':
refreshonly => true,
before => Service['openstack-losetup'],
}
service { 'openstack-losetup':
ensure => running,
enable => true,
require => Class['cinder::setup_test_volume'],
}
}
file_line { 'snapshot_autoextend_threshold':
path => '/etc/lvm/lvm.conf',
match => '^ *snapshot_autoextend_threshold +=.*',
line => ' snapshot_autoextend_threshold = 80',
require => Package['lvm2'],
}
file_line { 'snapshot_autoextend_percent':
path => '/etc/lvm/lvm.conf',
match => '^ *snapshot_autoextend_percent +=.*',
line => ' snapshot_autoextend_percent = 20',
require => Package['lvm2'],
}
cinder::backend::iscsi { 'lvm':
iscsi_ip_address => '%(CONFIG_STORAGE_HOST)s', iscsi_ip_address => '%(CONFIG_STORAGE_HOST)s',
require => Package['lvm2'], require => Package['lvm2'],
} }
cinder::type { 'iscsi':
set_key => 'volume_backend_name',
set_value => 'lvm',
require => Class['cinder::api'],
}

View File

@@ -2,11 +2,7 @@
package { 'iscsi-initiator-utils': ensure => present } package { 'iscsi-initiator-utils': ensure => present }
cinder_config { cinder::backend::netapp { 'netapp':
"DEFAULT/enabled_backends": value => "myBackend";
}
cinder::backend::netapp{ 'myBackend':
netapp_login => "%(CONFIG_CINDER_NETAPP_LOGIN)s", netapp_login => "%(CONFIG_CINDER_NETAPP_LOGIN)s",
netapp_password => "%(CONFIG_CINDER_NETAPP_PASSWORD)s", netapp_password => "%(CONFIG_CINDER_NETAPP_PASSWORD)s",
netapp_server_hostname => "%(CONFIG_CINDER_NETAPP_HOSTNAME)s", netapp_server_hostname => "%(CONFIG_CINDER_NETAPP_HOSTNAME)s",
@@ -17,6 +13,11 @@ cinder::backend::netapp{ 'myBackend':
netapp_transport_type => "%(CONFIG_CINDER_NETAPP_TRANSPORT_TYPE)s", netapp_transport_type => "%(CONFIG_CINDER_NETAPP_TRANSPORT_TYPE)s",
netapp_vfiler => "%(CONFIG_CINDER_NETAPP_VFILER)s", netapp_vfiler => "%(CONFIG_CINDER_NETAPP_VFILER)s",
netapp_volume_list => ["%(CONFIG_CINDER_NETAPP_VOLUME_LIST)s"], netapp_volume_list => ["%(CONFIG_CINDER_NETAPP_VOLUME_LIST)s"],
require => Package['iscsi-initiator-utils'],
require => Package['iscsi-initiator-utils'], }
cinder::type { 'cinder_netapp_7mode_iscsi':
set_key => 'volume_backend_name',
set_value => 'netapp',
require => Class['cinder::api'],
} }

View File

@@ -2,11 +2,7 @@
package { 'nfs-utils': ensure => present } package { 'nfs-utils': ensure => present }
cinder_config { cinder::backend::netapp { 'netapp':
"DEFAULT/enabled_backends": value => "myBackend";
}
cinder::backend::netapp{ 'myBackend':
netapp_login => "%(CONFIG_CINDER_NETAPP_LOGIN)s", netapp_login => "%(CONFIG_CINDER_NETAPP_LOGIN)s",
netapp_password => "%(CONFIG_CINDER_NETAPP_PASSWORD)s", netapp_password => "%(CONFIG_CINDER_NETAPP_PASSWORD)s",
netapp_server_hostname => "%(CONFIG_CINDER_NETAPP_HOSTNAME)s", netapp_server_hostname => "%(CONFIG_CINDER_NETAPP_HOSTNAME)s",
@@ -18,6 +14,11 @@ cinder::backend::netapp{ 'myBackend':
thres_avl_size_perc_start => "%(CONFIG_CINDER_NETAPP_THRES_AVL_SIZE_PERC_START)s", thres_avl_size_perc_start => "%(CONFIG_CINDER_NETAPP_THRES_AVL_SIZE_PERC_START)s",
thres_avl_size_perc_stop => "%(CONFIG_CINDER_NETAPP_THRES_AVL_SIZE_PERC_STOP)s", thres_avl_size_perc_stop => "%(CONFIG_CINDER_NETAPP_THRES_AVL_SIZE_PERC_STOP)s",
nfs_shares_config => "%(CONFIG_CINDER_NETAPP_NFS_SHARES_CONFIG)s", nfs_shares_config => "%(CONFIG_CINDER_NETAPP_NFS_SHARES_CONFIG)s",
require => Package['nfs-utils'],
require => Package['nfs-utils'], }
cinder::type { 'cinder_netapp_7mode_nfs':
set_key => 'volume_backend_name',
set_value => 'netapp',
require => Class['cinder::api'],
} }

View File

@@ -2,11 +2,7 @@
package { 'iscsi-initiator-utils': ensure => present } package { 'iscsi-initiator-utils': ensure => present }
cinder_config { cinder::backend::netapp { 'netapp':
"DEFAULT/enabled_backends": value => "myBackend";
}
cinder::backend::netapp{ 'myBackend':
netapp_login => "%(CONFIG_CINDER_NETAPP_LOGIN)s", netapp_login => "%(CONFIG_CINDER_NETAPP_LOGIN)s",
netapp_password => "%(CONFIG_CINDER_NETAPP_PASSWORD)s", netapp_password => "%(CONFIG_CINDER_NETAPP_PASSWORD)s",
netapp_server_hostname => "%(CONFIG_CINDER_NETAPP_HOSTNAME)s", netapp_server_hostname => "%(CONFIG_CINDER_NETAPP_HOSTNAME)s",
@@ -16,6 +12,11 @@ cinder::backend::netapp{ 'myBackend':
netapp_storage_protocol => "%(CONFIG_CINDER_NETAPP_STORAGE_PROTOCOL)s", netapp_storage_protocol => "%(CONFIG_CINDER_NETAPP_STORAGE_PROTOCOL)s",
netapp_transport_type => "%(CONFIG_CINDER_NETAPP_TRANSPORT_TYPE)s", netapp_transport_type => "%(CONFIG_CINDER_NETAPP_TRANSPORT_TYPE)s",
netapp_vserver => "%(CONFIG_CINDER_NETAPP_VSERVER)s", netapp_vserver => "%(CONFIG_CINDER_NETAPP_VSERVER)s",
require => Package['iscsi-initiator-utils'],
require => Package['iscsi-initiator-utils'], }
cinder::type { 'cinder_netapp_cdot_iscsi':
set_key => 'volume_backend_name',
set_value => 'netapp',
require => Class['cinder::api'],
} }

View File

@@ -2,11 +2,7 @@
package { 'nfs-utils': ensure => present } package { 'nfs-utils': ensure => present }
cinder_config { cinder::backend::netapp { 'netapp':
"DEFAULT/enabled_backends": value => "myBackend";
}
cinder::backend::netapp{ 'myBackend':
netapp_login => "%(CONFIG_CINDER_NETAPP_LOGIN)s", netapp_login => "%(CONFIG_CINDER_NETAPP_LOGIN)s",
netapp_password => "%(CONFIG_CINDER_NETAPP_PASSWORD)s", netapp_password => "%(CONFIG_CINDER_NETAPP_PASSWORD)s",
netapp_server_hostname => "%(CONFIG_CINDER_NETAPP_HOSTNAME)s", netapp_server_hostname => "%(CONFIG_CINDER_NETAPP_HOSTNAME)s",
@@ -19,6 +15,11 @@ cinder::backend::netapp{ 'myBackend':
thres_avl_size_perc_start => "%(CONFIG_CINDER_NETAPP_THRES_AVL_SIZE_PERC_START)s", thres_avl_size_perc_start => "%(CONFIG_CINDER_NETAPP_THRES_AVL_SIZE_PERC_START)s",
thres_avl_size_perc_stop => "%(CONFIG_CINDER_NETAPP_THRES_AVL_SIZE_PERC_STOP)s", thres_avl_size_perc_stop => "%(CONFIG_CINDER_NETAPP_THRES_AVL_SIZE_PERC_STOP)s",
nfs_shares_config => "%(CONFIG_CINDER_NETAPP_NFS_SHARES_CONFIG)s", nfs_shares_config => "%(CONFIG_CINDER_NETAPP_NFS_SHARES_CONFIG)s",
require => Package['nfs-utils'],
require => Package['nfs-utils'], }
cinder::type { 'cinder_netapp_cdot_nfs':
set_key => 'volume_backend_name',
set_value => 'netapp',
require => Class['cinder::api'],
} }

View File

@@ -2,11 +2,7 @@
package { 'iscsi-initiator-utils': ensure => present } package { 'iscsi-initiator-utils': ensure => present }
cinder_config { cinder::backend::netapp { 'netapp':
"DEFAULT/enabled_backends": value => "myBackend";
}
cinder::backend::netapp{ 'myBackend':
netapp_login => "%(CONFIG_CINDER_NETAPP_LOGIN)s", netapp_login => "%(CONFIG_CINDER_NETAPP_LOGIN)s",
netapp_password => "%(CONFIG_CINDER_NETAPP_PASSWORD)s", netapp_password => "%(CONFIG_CINDER_NETAPP_PASSWORD)s",
netapp_server_hostname => "%(CONFIG_CINDER_NETAPP_HOSTNAME)s", netapp_server_hostname => "%(CONFIG_CINDER_NETAPP_HOSTNAME)s",
@@ -18,6 +14,11 @@ cinder::backend::netapp{ 'myBackend':
netapp_sa_password => "%(CONFIG_CINDER_NETAPP_SA_PASSWORD)s", netapp_sa_password => "%(CONFIG_CINDER_NETAPP_SA_PASSWORD)s",
netapp_storage_pools => "%(CONFIG_CINDER_NETAPP_STORAGE_POOLS)s", netapp_storage_pools => "%(CONFIG_CINDER_NETAPP_STORAGE_POOLS)s",
netapp_webservice_path => "%(CONFIG_CINDER_NETAPP_WEBSERVICE_PATH)s", netapp_webservice_path => "%(CONFIG_CINDER_NETAPP_WEBSERVICE_PATH)s",
require => Package['iscsi-initiator-utils'],
require => Package['iscsi-initiator-utils'], }
cinder::type { 'cinder_netapp_eseries':
set_key => 'volume_backend_name',
set_value => 'netapp',
require => Class['cinder::api'],
} }

View File

@@ -1,6 +1,13 @@
package { 'nfs-utils': ensure => present } package { 'nfs-utils': ensure => present }
class { 'cinder::volume::nfs': cinder::backend::nfs { 'nfs':
nfs_servers => [%(CONFIG_CINDER_NFS_MOUNTS)s], nfs_servers => [%(CONFIG_CINDER_NFS_MOUNTS)s],
require => Package['nfs-utils'], require => Package['nfs-utils'],
nfs_shares_config => '/etc/cinder/nfs_shares.conf',
}
cinder::type { 'nfs':
set_key => 'volume_backend_name',
set_value => 'nfs',
require => Class['cinder::api'],
} }

View File

@@ -1,5 +1,11 @@
class { 'cinder::volume::vmdk': cinder::backend::vmdk { 'vmdk':
host_ip => "%(CONFIG_VCENTER_HOST)s", host_ip => "%(CONFIG_VCENTER_HOST)s",
host_username => "%(CONFIG_VCENTER_USER)s", host_username => "%(CONFIG_VCENTER_USER)s",
host_password => "%(CONFIG_VCENTER_PASSWORD)s", host_password => "%(CONFIG_VCENTER_PASSWORD)s",
} }
cinder::type { 'vmdk':
set_key => 'volume_backend_name',
set_value => 'vmdk',
require => Class['cinder::api'],
}