Merge "Creation of glance::db::sync"

This commit is contained in:
Jenkins 2015-09-11 14:42:00 +00:00 committed by Gerrit Code Review
commit 1a6a0b9162
5 changed files with 68 additions and 27 deletions

View File

@ -258,9 +258,6 @@ class glance::api(
# adding all of this stuff b/c it devstack says glance-api uses the
# db now
Glance_api_config<||> ~> Exec<| title == 'glance-manage db_sync' |>
Glance_cache_config<||> ~> Exec<| title == 'glance-manage db_sync' |>
Exec<| title == 'glance-manage db_sync' |> ~> Service['glance-api']
Glance_api_config<||> ~> Service['glance-api']
Glance_cache_config<||> ~> Service['glance-api']
Class['glance::policy'] ~> Service['glance-api']

23
manifests/db/sync.pp Normal file
View File

@ -0,0 +1,23 @@
#
# Class to execute glance dbsync
#
class glance::db::sync {
include ::glance::params
Package<| tag == 'glance-package' |> ~> Exec['glance-manage db_sync']
Exec['glance-manage db_sync'] ~> Service<| tag == 'glance-service' |>
Glance_registry_config<||> ~> Exec['glance-manage db_sync']
Glance_api_config<||> ~> Exec['glance-manage db_sync']
Glance_cache_config<||> ~> Exec['glance-manage db_sync']
exec { 'glance-manage db_sync':
command => $::glance::params::db_sync_command,
path => '/usr/bin',
user => 'glance',
refreshonly => true,
logoutput => on_failure,
}
}

View File

@ -184,7 +184,6 @@ class glance::registry(
Package[$glance::params::registry_package_name] -> File['/etc/glance/']
Glance_registry_config<||> ~> Exec<| title == 'glance-manage db_sync' |>
Glance_registry_config<||> ~> Service['glance-registry']
File {
@ -369,16 +368,7 @@ class glance::registry(
}
if $sync_db {
Exec['glance-manage db_sync'] ~> Service['glance-registry']
exec { 'glance-manage db_sync':
command => $::glance::params::db_sync_command,
path => '/usr/bin',
user => 'glance',
refreshonly => true,
logoutput => on_failure,
subscribe => [Package[$glance::params::registry_package_name], File['/etc/glance/glance-registry.conf']],
}
include ::glance::db::sync
}
if $manage_service {

View File

@ -0,0 +1,44 @@
require 'spec_helper'
describe 'glance::db::sync' do
shared_examples_for 'glance-dbsync' do
it 'runs glance-manage db_sync' do
is_expected.to contain_exec('glance-manage db_sync').with(
:command => 'glance-manage --config-file=/etc/glance/glance-registry.conf db_sync',
:path => '/usr/bin',
:user => 'glance',
:refreshonly => 'true',
:logoutput => 'on_failure'
)
end
end
context 'on a RedHat osfamily' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystemrelease => '7.0',
:concat_basedir => '/var/lib/puppet/concat'
}
end
it_configures 'glance-dbsync'
end
context 'on a Debian osfamily' do
let :facts do
{
:operatingsystemrelease => '7.8',
:operatingsystem => 'Debian',
:osfamily => 'Debian',
:concat_basedir => '/var/lib/puppet/concat'
}
end
it_configures 'glance-dbsync'
end
end

View File

@ -79,19 +79,6 @@ describe 'glance::registry' do
'tag' => 'glance-service',
)}
it 'is_expected.to only sync the db if sync_db is enabled' do
if param_hash[:sync_db]
is_expected.to contain_exec('glance-manage db_sync').with(
'path' => '/usr/bin',
'command' => 'glance-manage --config-file=/etc/glance/glance-registry.conf db_sync',
'refreshonly' => true,
'logoutput' => 'on_failure',
'subscribe' => ['Package[glance-registry]', 'File[/etc/glance/glance-registry.conf]'],
'notify' => ["Service[glance-registry]"]
)
end
end
it 'is_expected.to not sync the db if sync_db is set to false' do
if !param_hash[:sync_db]