Glance: add "local" backend

As an option, allow to configure Glance with "local" backend.
It is a option to use when not having Ceph in the environment.

For backward compatibility, we set 'rbd' as default backend.

Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
Emilien Macchi
2014-07-04 19:23:16 +02:00
parent 3c6c6d8671
commit efe125f5eb
2 changed files with 48 additions and 13 deletions

View File

@@ -67,6 +67,11 @@
# (optional) Syslog facility to receive log lines
# Defaults to 'LOG_LOCAL0'
#
# [*backend*]
# (optionnal) Backend to use to store images
# Can be 'rbd' or 'file'.
# Defaults to 'rbd' to maintain backward compatibility
#
class cloud::image::api(
$glance_db_host = '127.0.0.1',
@@ -88,7 +93,9 @@ class cloud::image::api(
$verbose = true,
$debug = true,
$log_facility = 'LOG_LOCAL0',
$use_syslog = true
$use_syslog = true,
$backend = 'rbd',
$filesystem_store_datadir = undef
) {
# Disable twice logging if syslog is enabled
@@ -138,6 +145,7 @@ class cloud::image::api(
'DEFAULT/notifier_driver': value => 'noop';
}
if ($backend == 'rbd') {
class { 'glance::backend::rbd':
rbd_store_user => $glance_rbd_user,
rbd_store_pool => $glance_rbd_pool
@@ -152,6 +160,13 @@ class cloud::image::api(
notify => Service['glance-api','glance-registry']
}
Concat::Fragment <<| title == 'ceph-client-os' |>>
} elsif ($backend == 'file') {
class { 'glance::backend::file':
filesystem_store_datadir => $filesystem_store_datadir
}
} else {
fail("${backend} is not a Glance supported backend.")
}
class { 'glance::cache::cleaner': }
class { 'glance::cache::pruner': }

View File

@@ -35,6 +35,7 @@ describe 'cloud::image::api' do
:rabbit_password => 'secrete',
:glance_rbd_user => 'glance',
:glance_rbd_pool => 'images',
:backend => 'rbd',
:debug => true,
:verbose => true,
:use_syslog => true,
@@ -92,6 +93,25 @@ describe 'cloud::image::api' do
should contain_class('glance::cache::pruner')
end
context 'with file Glance backend' do
before :each do
params.merge!(:backend => 'file')
end
it 'configure Glance with file backend' do
should contain_class('glance::backend::file')
should_not contain_class('glance::backend::rbd')
should contain_glance_api_config('DEFAULT/filesystem_store_datadir').with('value' => '/var/lib/glance/images/')
should contain_glance_api_config('DEFAULT/default_store').with('value' => 'file')
end
end
context 'with wrong Glance backend' do
before :each do
params.merge!(:backend => 'Something')
end
it { should compile.and_raise_error(/Something is not a Glance supported backend./) }
end
end
context 'on Debian platforms' do