image: Ensure Glance DB is populated

With an exec, we check that Glance database is populated with tables,
otherwise we do it "by hand".
This is an hack because we use Galera + HAproxy, which would not appear
in a simple use-case (with mysql on single node only).

Close #142

Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
Emilien Macchi
2014-02-03 19:07:49 +01:00
parent c75214e7f0
commit 6c779483a7
2 changed files with 16 additions and 0 deletions

View File

@@ -126,6 +126,15 @@ class cloud::image(
class { 'glance::cache::cleaner': } class { 'glance::cache::cleaner': }
class { 'glance::cache::pruner': } class { 'glance::cache::pruner': }
# Note(EmilienM):
# We check if DB tables are created, if not we populate Glance DB.
# It's a hack to fit with our setup where we run MySQL/Galera
exec {'glance_db_sync':
command => 'glance-manage db_sync',
path => '/usr/bin',
unless => 'mysql glance -e "show tables" | grep Tables'
}
# TODO(EmilienM) For later, I'll also add internal network support in HAproxy for all OpenStack API, to optimize North / South network traffic # TODO(EmilienM) For later, I'll also add internal network support in HAproxy for all OpenStack API, to optimize North / South network traffic
@@haproxy::balancermember{"${::fqdn}-glance_api": @@haproxy::balancermember{"${::fqdn}-glance_api":
listening_service => 'glance_api_cluster', listening_service => 'glance_api_cluster',

View File

@@ -95,6 +95,13 @@ describe 'cloud::image' do
should contain_class('glance::cache::pruner') should contain_class('glance::cache::pruner')
end end
it 'checks if Glance DB is populated' do
should contain_exec('glance_db_sync').with(
:command => 'glance-manage db_sync',
:path => '/usr/bin',
:unless => 'mysql glance -e "show tables" | grep Tables'
)
end
end end
context 'on Debian platforms' do context 'on Debian platforms' do