Merge "Configure database parameters on the right nodes" into stable/juno
This commit is contained in:
commit
2a5c1eac6b
|
@ -176,6 +176,7 @@ class nova::api(
|
|||
$conductor_workers = undef,
|
||||
) {
|
||||
|
||||
include nova::db
|
||||
include nova::params
|
||||
include nova::policy
|
||||
require keystone::python
|
||||
|
|
|
@ -27,6 +27,7 @@ class nova::conductor(
|
|||
$workers = undef,
|
||||
) {
|
||||
|
||||
include nova::db
|
||||
include nova::params
|
||||
|
||||
nova::generic_service { 'conductor':
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
#
|
||||
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Emilien Macchi <emilien.macchi@enovance.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# == Class: nova::db
|
||||
# Configures the nova database.
|
||||
#
|
||||
# == Parameters
|
||||
#
|
||||
# [*database_connection*]
|
||||
# (optional) Connection url to connect to nova database.
|
||||
# Defaults to undef
|
||||
#
|
||||
# [*database_idle_timeout*]
|
||||
# (optional) Timeout before idle db connections are reaped.
|
||||
# Defaults to undef
|
||||
#
|
||||
class nova::db (
|
||||
$database_connection = undef,
|
||||
$database_idle_timeout = undef,
|
||||
) {
|
||||
|
||||
$database_connection_real = pick($database_connection, $::nova::database_connection, false)
|
||||
$database_idle_timeout_real = pick($database_idle_timeout, $::nova::database_idle_timeout, false)
|
||||
|
||||
if $database_connection_real {
|
||||
if($database_connection_real =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
} elsif($database_connection_real =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
|
||||
} elsif($database_connection_real =~ /sqlite:\/\//) {
|
||||
|
||||
} else {
|
||||
fail("Invalid db connection ${database_connection_real}")
|
||||
}
|
||||
nova_config {
|
||||
'database/connection': value => $database_connection_real, secret => true;
|
||||
'database/idle_timeout': value => $database_idle_timeout_real;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -336,6 +336,9 @@ class nova(
|
|||
$os_region_name = undef,
|
||||
) inherits nova::params {
|
||||
|
||||
# maintain backward compatibility
|
||||
include nova::db
|
||||
|
||||
if $mysql_module {
|
||||
warning('The mysql_module parameter is deprecated. The latest 2.x mysql module will be used.')
|
||||
}
|
||||
|
@ -498,39 +501,6 @@ class nova(
|
|||
refreshonly => true,
|
||||
}
|
||||
|
||||
if $sql_connection {
|
||||
warning('The sql_connection parameter is deprecated, use database_connection instead.')
|
||||
$database_connection_real = $sql_connection
|
||||
} else {
|
||||
$database_connection_real = $database_connection
|
||||
}
|
||||
|
||||
if $sql_idle_timeout {
|
||||
warning('The sql_idle_timeout parameter is deprecated, use database_idle_timeout instead.')
|
||||
$database_idle_timeout_real = $sql_idle_timeout
|
||||
} else {
|
||||
$database_idle_timeout_real = $database_idle_timeout
|
||||
}
|
||||
|
||||
# both the database_connection and rabbit_host are things
|
||||
# that may need to be collected from a remote host
|
||||
if $database_connection_real {
|
||||
if($database_connection_real =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
} elsif($database_connection_real =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
|
||||
} elsif($database_connection_real =~ /sqlite:\/\//) {
|
||||
|
||||
} else {
|
||||
fail("Invalid db connection ${database_connection_real}")
|
||||
}
|
||||
nova_config {
|
||||
'database/connection': value => $database_connection_real, secret => true;
|
||||
'database/idle_timeout': value => $database_idle_timeout_real;
|
||||
}
|
||||
}
|
||||
|
||||
nova_config { 'DEFAULT/image_service': value => $image_service }
|
||||
|
||||
if $image_service == 'nova.image.glance.GlanceImageService' {
|
||||
|
|
|
@ -22,6 +22,7 @@ class nova::scheduler(
|
|||
$ensure_package = 'present'
|
||||
) {
|
||||
|
||||
include nova::db
|
||||
include nova::params
|
||||
|
||||
nova::generic_service { 'scheduler':
|
||||
|
|
|
@ -234,6 +234,29 @@ describe 'nova::api' do
|
|||
|
||||
it { should contain_service('nova-api').without_ensure }
|
||||
end
|
||||
|
||||
context 'with default database parameters' do
|
||||
let :pre_condition do
|
||||
"include nova"
|
||||
end
|
||||
|
||||
it { should_not contain_nova_config('database/connection') }
|
||||
it { should_not contain_nova_config('database/idle_timeout').with_value('3600') }
|
||||
end
|
||||
|
||||
context 'with overridden database parameters' do
|
||||
let :pre_condition do
|
||||
"class { 'nova':
|
||||
database_connection => 'mysql://user:pass@db/db',
|
||||
database_idle_timeout => '30',
|
||||
}
|
||||
"
|
||||
end
|
||||
|
||||
it { should contain_nova_config('database/connection').with_value('mysql://user:pass@db/db').with_secret(true) }
|
||||
it { should contain_nova_config('database/idle_timeout').with_value('30') }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
|
|
|
@ -6,42 +6,98 @@ describe 'nova::conductor' do
|
|||
'include nova'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :enabled => true }
|
||||
end
|
||||
|
||||
shared_examples 'nova-conductor' do
|
||||
|
||||
|
||||
it { should contain_package('nova-conductor').with(
|
||||
:name => platform_params[:conductor_package_name],
|
||||
:ensure => 'present'
|
||||
) }
|
||||
|
||||
it { should contain_service('nova-conductor').with(
|
||||
:name => platform_params[:conductor_service_name],
|
||||
:hasstatus => 'true',
|
||||
:ensure => 'running'
|
||||
)}
|
||||
|
||||
context 'with manage_service as false' do
|
||||
let :params do
|
||||
{ :enabled => true,
|
||||
:manage_service => false
|
||||
}
|
||||
end
|
||||
it { should contain_service('nova-conductor').without_ensure }
|
||||
end
|
||||
|
||||
context 'with package version' do
|
||||
let :params do
|
||||
{ :ensure_package => '2012.1-2' }
|
||||
end
|
||||
|
||||
it { should contain_package('nova-conductor').with(
|
||||
:ensure => params[:ensure_package]
|
||||
)}
|
||||
end
|
||||
|
||||
context 'with overriden workers parameter' do
|
||||
before do
|
||||
params.merge!({:workers => '5' })
|
||||
end
|
||||
it { should contain_nova_config('conductor/workers').with_value('5') }
|
||||
end
|
||||
|
||||
context 'with default database parameters' do
|
||||
let :pre_condition do
|
||||
"include nova"
|
||||
end
|
||||
|
||||
it { should_not contain_nova_config('database/connection') }
|
||||
it { should_not contain_nova_config('database/idle_timeout').with_value('3600') }
|
||||
end
|
||||
|
||||
context 'with overridden database parameters' do
|
||||
let :pre_condition do
|
||||
"class { 'nova':
|
||||
database_connection => 'mysql://user:pass@db/db',
|
||||
database_idle_timeout => '30',
|
||||
}
|
||||
"
|
||||
end
|
||||
|
||||
it { should contain_nova_config('database/connection').with_value('mysql://user:pass@db/db').with_secret(true) }
|
||||
it { should contain_nova_config('database/idle_timeout').with_value('30') }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_behaves_like 'generic nova service', {
|
||||
:name => 'nova-conductor',
|
||||
:package_name => 'nova-conductor',
|
||||
:service_name => 'nova-conductor' }
|
||||
|
||||
it { should_not contain_nova_config('conductor/workers') }
|
||||
|
||||
describe 'when overriding params' do
|
||||
let :params do
|
||||
{:workers => '5' }
|
||||
end
|
||||
it { should contain_nova_config('conductor/workers').with_value('5') }
|
||||
let :platform_params do
|
||||
{ :conductor_package_name => 'nova-conductor',
|
||||
:conductor_service_name => 'nova-conductor' }
|
||||
end
|
||||
|
||||
it_configures 'nova-conductor'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
context 'on Redhat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_behaves_like 'generic nova service', {
|
||||
:name => 'nova-conductor',
|
||||
:package_name => 'openstack-nova-conductor',
|
||||
:service_name => 'openstack-nova-conductor' }
|
||||
it { should_not contain_nova_config('conductor/workers') }
|
||||
|
||||
describe 'when overriding params' do
|
||||
let :params do
|
||||
{:workers => '5' }
|
||||
end
|
||||
it { should contain_nova_config('conductor/workers').with_value('5') }
|
||||
let :platform_params do
|
||||
{ :conductor_package_name => 'openstack-nova-conductor',
|
||||
:conductor_service_name => 'openstack-nova-conductor' }
|
||||
end
|
||||
|
||||
it_configures 'nova-conductor'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'nova::db' do
|
||||
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
shared_examples 'nova-db' do
|
||||
|
||||
context 'with default parameters' do
|
||||
it { should_not contain_nova_config('database/connection') }
|
||||
it { should_not contain_nova_config('database/idle_timeout') }
|
||||
end
|
||||
|
||||
context 'with overriden parameters' do
|
||||
before :each do
|
||||
params.merge!(
|
||||
:database_connection => 'mysql://user:pass@db/db',
|
||||
:database_idle_timeout => '30',
|
||||
)
|
||||
end
|
||||
|
||||
it { should contain_nova_config('database/connection').with_value('mysql://user:pass@db/db').with_secret(true) }
|
||||
it { should contain_nova_config('database/idle_timeout').with_value('30') }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_configures 'nova-db'
|
||||
end
|
||||
|
||||
context 'on Redhat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_configures 'nova-db'
|
||||
end
|
||||
|
||||
end
|
|
@ -64,11 +64,6 @@ describe 'nova' do
|
|||
:refreshonly => true
|
||||
)}
|
||||
|
||||
it 'configures database' do
|
||||
should_not contain_nova_config('database/connection')
|
||||
should_not contain_nova_config('database/idle_timeout').with_value('3600')
|
||||
end
|
||||
|
||||
it 'configures image service' do
|
||||
should contain_nova_config('DEFAULT/image_service').with_value('nova.image.glance.GlanceImageService')
|
||||
should contain_nova_config('glance/api_servers').with_value('localhost:9292')
|
||||
|
@ -112,9 +107,7 @@ describe 'nova' do
|
|||
context 'with overridden parameters' do
|
||||
|
||||
let :params do
|
||||
{ :database_connection => 'mysql://user:pass@db/db',
|
||||
:database_idle_timeout => '30',
|
||||
:verbose => true,
|
||||
{ :verbose => true,
|
||||
:debug => true,
|
||||
:log_dir => '/var/log/nova2',
|
||||
:image_service => 'nova.image.local.LocalImageService',
|
||||
|
@ -165,11 +158,6 @@ describe 'nova' do
|
|||
should contain_package('python-nova').with('ensure' => '2012.1.1-15.el6')
|
||||
end
|
||||
|
||||
it 'configures database' do
|
||||
should contain_nova_config('database/connection').with_value('mysql://user:pass@db/db').with_secret(true)
|
||||
should contain_nova_config('database/idle_timeout').with_value('30')
|
||||
end
|
||||
|
||||
it 'configures image service' do
|
||||
should contain_nova_config('DEFAULT/image_service').with_value('nova.image.local.LocalImageService')
|
||||
should_not contain_nova_config('glance/api_servers')
|
||||
|
@ -246,18 +234,6 @@ describe 'nova' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with deprecated sql parameters' do
|
||||
let :params do
|
||||
{ :sql_connection => 'mysql://user:pass@db/db',
|
||||
:sql_idle_timeout => '30' }
|
||||
end
|
||||
|
||||
it 'configures database' do
|
||||
should contain_nova_config('database/connection').with_value('mysql://user:pass@db/db').with_secret(true)
|
||||
should contain_nova_config('database/idle_timeout').with_value('30')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with syslog enabled' do
|
||||
let :params do
|
||||
{ :use_syslog => 'true' }
|
||||
|
|
|
@ -6,25 +6,91 @@ describe 'nova::scheduler' do
|
|||
'include nova'
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :enabled => true }
|
||||
end
|
||||
|
||||
shared_examples 'nova-scheduler' do
|
||||
|
||||
|
||||
it { should contain_package('nova-scheduler').with(
|
||||
:name => platform_params[:scheduler_package_name],
|
||||
:ensure => 'present'
|
||||
) }
|
||||
|
||||
it { should contain_service('nova-scheduler').with(
|
||||
:name => platform_params[:scheduler_service_name],
|
||||
:hasstatus => 'true',
|
||||
:ensure => 'running'
|
||||
)}
|
||||
|
||||
context 'with manage_service as false' do
|
||||
let :params do
|
||||
{ :enabled => true,
|
||||
:manage_service => false
|
||||
}
|
||||
end
|
||||
it { should contain_service('nova-scheduler').without_ensure }
|
||||
end
|
||||
|
||||
context 'with package version' do
|
||||
let :params do
|
||||
{ :ensure_package => '2012.1-2' }
|
||||
end
|
||||
|
||||
it { should contain_package('nova-scheduler').with(
|
||||
:ensure => params[:ensure_package]
|
||||
)}
|
||||
end
|
||||
|
||||
context 'with default database parameters' do
|
||||
let :pre_condition do
|
||||
"include nova"
|
||||
end
|
||||
|
||||
it { should_not contain_nova_config('database/connection') }
|
||||
it { should_not contain_nova_config('database/idle_timeout').with_value('3600') }
|
||||
end
|
||||
|
||||
context 'with overridden database parameters' do
|
||||
let :pre_condition do
|
||||
"class { 'nova':
|
||||
database_connection => 'mysql://user:pass@db/db',
|
||||
database_idle_timeout => '30',
|
||||
}
|
||||
"
|
||||
end
|
||||
|
||||
it { should contain_nova_config('database/connection').with_value('mysql://user:pass@db/db').with_secret(true) }
|
||||
it { should contain_nova_config('database/idle_timeout').with_value('30') }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
it_behaves_like 'generic nova service', {
|
||||
:name => 'nova-scheduler',
|
||||
:package_name => 'nova-scheduler',
|
||||
:service_name => 'nova-scheduler' }
|
||||
let :platform_params do
|
||||
{ :scheduler_package_name => 'nova-scheduler',
|
||||
:scheduler_service_name => 'nova-scheduler' }
|
||||
end
|
||||
|
||||
it_configures 'nova-scheduler'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
context 'on Redhat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
it_behaves_like 'generic nova service', {
|
||||
:name => 'nova-scheduler',
|
||||
:package_name => 'openstack-nova-scheduler',
|
||||
:service_name => 'openstack-nova-scheduler' }
|
||||
let :platform_params do
|
||||
{ :scheduler_package_name => 'openstack-nova-scheduler',
|
||||
:scheduler_service_name => 'openstack-nova-scheduler' }
|
||||
end
|
||||
|
||||
it_configures 'nova-scheduler'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue