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:
@@ -67,6 +67,11 @@
|
|||||||
# (optional) Syslog facility to receive log lines
|
# (optional) Syslog facility to receive log lines
|
||||||
# Defaults to 'LOG_LOCAL0'
|
# 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(
|
class cloud::image::api(
|
||||||
$glance_db_host = '127.0.0.1',
|
$glance_db_host = '127.0.0.1',
|
||||||
@@ -88,7 +93,9 @@ class cloud::image::api(
|
|||||||
$verbose = true,
|
$verbose = true,
|
||||||
$debug = true,
|
$debug = true,
|
||||||
$log_facility = 'LOG_LOCAL0',
|
$log_facility = 'LOG_LOCAL0',
|
||||||
$use_syslog = true
|
$use_syslog = true,
|
||||||
|
$backend = 'rbd',
|
||||||
|
$filesystem_store_datadir = undef
|
||||||
) {
|
) {
|
||||||
|
|
||||||
# Disable twice logging if syslog is enabled
|
# Disable twice logging if syslog is enabled
|
||||||
@@ -138,6 +145,7 @@ class cloud::image::api(
|
|||||||
'DEFAULT/notifier_driver': value => 'noop';
|
'DEFAULT/notifier_driver': value => 'noop';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($backend == 'rbd') {
|
||||||
class { 'glance::backend::rbd':
|
class { 'glance::backend::rbd':
|
||||||
rbd_store_user => $glance_rbd_user,
|
rbd_store_user => $glance_rbd_user,
|
||||||
rbd_store_pool => $glance_rbd_pool
|
rbd_store_pool => $glance_rbd_pool
|
||||||
@@ -152,6 +160,13 @@ class cloud::image::api(
|
|||||||
notify => Service['glance-api','glance-registry']
|
notify => Service['glance-api','glance-registry']
|
||||||
}
|
}
|
||||||
Concat::Fragment <<| title == 'ceph-client-os' |>>
|
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::cleaner': }
|
||||||
class { 'glance::cache::pruner': }
|
class { 'glance::cache::pruner': }
|
||||||
|
@@ -35,6 +35,7 @@ describe 'cloud::image::api' do
|
|||||||
:rabbit_password => 'secrete',
|
:rabbit_password => 'secrete',
|
||||||
:glance_rbd_user => 'glance',
|
:glance_rbd_user => 'glance',
|
||||||
:glance_rbd_pool => 'images',
|
:glance_rbd_pool => 'images',
|
||||||
|
:backend => 'rbd',
|
||||||
:debug => true,
|
:debug => true,
|
||||||
:verbose => true,
|
:verbose => true,
|
||||||
:use_syslog => true,
|
:use_syslog => true,
|
||||||
@@ -92,6 +93,25 @@ describe 'cloud::image::api' do
|
|||||||
should contain_class('glance::cache::pruner')
|
should contain_class('glance::cache::pruner')
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'on Debian platforms' do
|
context 'on Debian platforms' do
|
||||||
|
Reference in New Issue
Block a user