Creation of nova::db::sync

In order to standardize the way dbsync are run across our modules,
we create a new class nova::db::sync.
This class will be included if sync_db is enabled.

By making this transition the nova::db::sync class
can be returned by the ENC.

A use case would be in an highly available environment, with 3 galera
nodes, include nova::api on every node with sync_db set to false
and have the ENC return nova::db::sync just for one node.

Change-Id: I795178f83fe5b997a2574fe17263643688efc48c
This commit is contained in:
Yanis Guenane
2015-06-29 16:10:44 +02:00
parent 24f8b79c5c
commit d834a87a20
3 changed files with 65 additions and 8 deletions

View File

@@ -346,14 +346,7 @@ class nova::api(
# Added arg and if statement prevents this from being run
# where db is not active i.e. the compute
if $sync_db {
Package<| title == $::nova::params::api_package_name |> ~> Exec['nova-db-sync']
Package<| title == $::nova::params::common_package_name |> ~> Exec['nova-db-sync']
exec { 'nova-db-sync':
command => '/usr/bin/nova-manage db sync',
refreshonly => true,
subscribe => Exec['post-nova_config'],
}
include ::nova::db::sync
}
# Remove auth configuration from api-paste.ini

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

@@ -0,0 +1,22 @@
#
# Class to execute nova dbsync
#
class nova::db::sync {
include ::nova::params
Package<| tag =='nova-package' |> ~> Exec['nova-db-sync']
Exec['nova-db-sync'] ~> Service <| tag == 'nova-service' |>
Nova_config <||> -> Exec['nova-db-sync']
Nova_config <| title == 'database/connection' |> ~> Exec['nova-db-sync']
Exec<| title == 'post-nova_config' |> ~> Exec['nova-db-sync']
exec { 'nova-db-sync':
command => '/usr/bin/nova-manage db sync',
refreshonly => true,
logoutput => on_failure,
}
}

View File

@@ -0,0 +1,42 @@
require 'spec_helper'
describe 'nova::db::sync' do
shared_examples_for 'nova-dbsync' do
it 'runs nova-db-sync' do
is_expected.to contain_exec('nova-db-sync').with(
:command => '/usr/bin/nova-manage db sync',
: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 'nova-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 'nova-dbsync'
end
end