From 670b3231ba411b93f8040eac0f8e4fdeb5dd4151 Mon Sep 17 00:00:00 2001 From: Jens-Christian Fischer Date: Tue, 9 Jul 2013 15:24:45 +0200 Subject: [PATCH] Add rbd option to cinder configuration Extend the support of cinder for rbd volume types by adding the configuration variables needed (including parametrizing the cinder_volume_driver to either 'iscsi' or 'rdb') and passing them on to the cinder puppet module. Change-Id: Id01e6346be85f9b4b70b11696b2395a09213ef05 --- manifests/cinder/storage.pp | 35 +++++++++++++------ manifests/compute.pp | 9 ++++- spec/classes/openstack_cinder_storage_spec.rb | 18 ++++++++++ spec/classes/openstack_compute_spec.rb | 27 ++++++++++++++ 4 files changed, 78 insertions(+), 11 deletions(-) diff --git a/manifests/cinder/storage.pp b/manifests/cinder/storage.pp index 316b1b4..61f88d3 100644 --- a/manifests/cinder/storage.pp +++ b/manifests/cinder/storage.pp @@ -11,6 +11,9 @@ class openstack::cinder::storage( $volume_package_ensure = 'present', $volume_group = 'cinder-volumes', $enabled = true, + $rbd_user = 'volumes', + $rbd_pool = 'volumes', + $rbd_secret_uuid = false, $volume_driver = 'iscsi', $iscsi_ip_address = '127.0.0.1', $setup_test_volume = false, @@ -36,17 +39,29 @@ class openstack::cinder::storage( enabled => $enabled, } - if $volume_driver == 'iscsi' { - class { 'cinder::volume::iscsi': - iscsi_ip_address => $iscsi_ip_address, - volume_group => $volume_group, - } - if $setup_test_volume { - class {'::cinder::setup_test_volume': - volume_name => $volume_group, + case $volume_driver { + + 'iscsi': { + class { 'cinder::volume::iscsi': + iscsi_ip_address => $iscsi_ip_address, + volume_group => $volume_group, + } + if $setup_test_volume { + class {'::cinder::setup_test_volume': + volume_name => $volume_group, + } } } - } else { - warning("Unsupported volume driver: ${volume_driver}, make sure you are configuring this yourself") + 'rbd': { + + class { 'cinder::volume::rbd': + rbd_user => $rbd_user, + rbd_pool => $rbd_pool, + rbd_secret_uuid => $rbd_secret_uuid, + } + } + default: { + warning("Unsupported volume driver: ${volume_driver}, make sure you are configuring this yourself") + } } } diff --git a/manifests/compute.pp b/manifests/compute.pp index adce51e..3fef828 100644 --- a/manifests/compute.pp +++ b/manifests/compute.pp @@ -67,12 +67,16 @@ class openstack::compute ( $vncserver_listen = false, # cinder / volumes $manage_volumes = true, + $cinder_volume_driver = 'iscsi', $cinder_db_password = false, $cinder_db_user = 'cinder', $cinder_db_name = 'cinder', $volume_group = 'cinder-volumes', $iscsi_ip_address = '127.0.0.1', $setup_test_volume = false, + $cinder_rbd_user = 'volumes', + $cinder_rbd_pool = 'volumes', + $cinder_rbd_secret_uuid = false, # General $migration_support = false, $verbose = false, @@ -245,7 +249,10 @@ class openstack::compute ( enabled => $enabled, verbose => $verbose, setup_test_volume => $setup_test_volume, - volume_driver => 'iscsi', + rbd_user => $cinder_rbd_user, + rbd_pool => $cinder_rbd_pool, + rbd_secret_uuid => $cinter_rbd_secret_uuid, + volume_driver => $cinder_volume_driver, } # set in nova::api diff --git a/spec/classes/openstack_cinder_storage_spec.rb b/spec/classes/openstack_cinder_storage_spec.rb index eee80e9..ee6f222 100644 --- a/spec/classes/openstack_cinder_storage_spec.rb +++ b/spec/classes/openstack_cinder_storage_spec.rb @@ -65,4 +65,22 @@ describe 'openstack::cinder::storage' do end end + describe 'when setting up test volumes for rbd' do + before do + params.merge!( + :volume_driver => 'rbd', + :rbd_user => 'rbd', + :rbd_pool => 'rbd_pool', + :rbd_secret_uuid => 'secret' + ) + end + + it { should contain_class('cinder::volume::rbd').with( + :rbd_user => 'rbd', + :rbd_pool => 'rbd_pool', + :rbd_secret_uuid => 'secret' + ) } + + + end end diff --git a/spec/classes/openstack_compute_spec.rb b/spec/classes/openstack_compute_spec.rb index 325a876..4f46b5e 100644 --- a/spec/classes/openstack_compute_spec.rb +++ b/spec/classes/openstack_compute_spec.rb @@ -148,6 +148,33 @@ describe 'openstack::compute' do end + context 'with rbd storage' do + before do + params.merge!( + :cinder_volume_driver => 'rbd', + :cinder_rbd_user => 'volumes', + :cinder_rbd_pool => 'volumes' + ) + end + it do + should contain_class('openstack::cinder::storage').with( + :sql_connection => 'mysql://cinder:cinder_pass@127.0.0.1/cinder', + :rabbit_password => 'rabbit_pw', + :rabbit_userid => 'openstack', + :rabbit_host => '127.0.0.1', + :rabbit_virtual_host => '/', + :volume_group => 'cinder-volumes', + :iscsi_ip_address => '127.0.0.1', + :enabled => true, + :verbose => false, + :setup_test_volume => false, + :rbd_user => 'volumes', + :rbd_pool => 'volumes', + :volume_driver => 'rbd' + ) + end + end + describe 'when quantum is false' do describe 'configuring for multi host' do