Merge pull request #253 from puppetlabs/master

backport changes to folsom branch
This commit is contained in:
Dan Bode 2013-03-21 11:08:42 -07:00
commit 1b52cc1216
6 changed files with 209 additions and 29 deletions

View File

@ -25,13 +25,13 @@ class nova::api(
$admin_password = 'passw0rd',
$api_bind_address = '0.0.0.0',
$enabled_apis = 'ec2,osapi_compute,metadata',
$volume_api_class = 'nova.volume.cinder.API'
$volume_api_class = 'nova.volume.cinder.API',
$sync_db = true
) {
include nova::params
require keystone::python
Package<| title == 'nova-api' |> -> Exec['nova-db-sync']
Package<| title == 'nova-api' |> -> Nova_paste_api_ini<| |>
Package<| title == 'nova-common' |> -> Class['nova::api']
@ -89,12 +89,14 @@ class nova::api(
}
}
# I need to ensure that I better understand this resource
# this is potentially constantly resyncing a central DB
exec { "nova-db-sync":
command => "/usr/bin/nova-manage db sync",
refreshonly => "true",
subscribe => Exec['post-nova_config'],
# 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-api' |> -> Exec['nova-db-sync']
exec { "nova-db-sync":
command => "/usr/bin/nova-manage db sync",
refreshonly => "true",
subscribe => Exec['post-nova_config'],
}
}
}

View File

@ -15,6 +15,16 @@ class nova::compute::libvirt (
}
}
if($::osfamily == 'RedHat') {
service { 'messagebus':
ensure => running,
enable => true,
provider => $::nova::params::special_service_provider,
}
Package['libvirt'] -> Service['messagebus'] -> Service['libvirt']
}
if $migration_support {
if $vncserver_listen != '0.0.0.0' {
fail("For migration support to work, you MUST set vncserver_listen to '0.0.0.0'")

View File

@ -6,12 +6,11 @@ class nova::db::mysql(
$dbname = 'nova',
$user = 'nova',
$host = '127.0.0.1',
$charset = 'latin1',
$allowed_hosts = undef,
$cluster_id = 'localzone'
) {
include 'nova::params'
require 'mysql::python'
# Create the db instance before openstack-nova if its installed
Mysql::Db[$dbname] -> Anchor<| title == "nova-start" |>
@ -21,7 +20,7 @@ class nova::db::mysql(
user => $user,
password => $password,
host => $host,
charset => $nova::params::nova_db_charset,
charset => $charset,
# I may want to inject some sql
require => Class['mysql::config'],
}

View File

@ -35,7 +35,6 @@ class nova::params {
# redhat specific config defaults
$root_helper = 'sudo nova-rootwrap'
$lock_path = '/var/lib/nova/tmp'
$nova_db_charset = 'latin1'
}
'Debian': {
# package names
@ -65,7 +64,6 @@ class nova::params {
# debian specific nova config
$root_helper = 'sudo nova-rootwrap'
$lock_path = '/var/lock/nova'
$nova_db_charset = 'latin1'
case $::operatingsystem {
'Debian': {
$consoleauth_package_name = 'nova-console'

View File

@ -0,0 +1,144 @@
require 'spec_helper'
describe 'nova::compute::libvirt' do
let :pre_condition do
"include nova\ninclude nova::compute"
end
describe 'on debian platforms' do
let :facts do
{ :osfamily => 'Debian' }
end
describe 'with default parameters' do
it { should include_class('nova::params')}
it { should contain_package('nova-compute-kvm').with(
:ensure => 'present',
:before => 'Package[nova-compute]'
) }
it { should contain_package('libvirt').with(
:name => 'libvirt-bin',
:ensure => 'present'
) }
it { should contain_service('libvirt').with(
:name => 'libvirt-bin',
:ensure => 'running',
:provider => 'upstart',
:require => 'Package[libvirt]',
:before => 'Service[nova-compute]'
)}
it { should contain_nova_config('compute_driver').with_value('libvirt.LibvirtDriver')}
it { should contain_nova_config('libvirt_type').with_value('kvm')}
it { should contain_nova_config('connection_type').with_value('libvirt')}
it { should contain_nova_config('vncserver_listen').with_value('127.0.0.1')}
end
describe 'with params' do
let :params do
{ :libvirt_type => 'qemu',
:vncserver_listen => '0.0.0.0'
}
end
it { should contain_nova_config('libvirt_type').with_value('qemu')}
it { should contain_nova_config('vncserver_listen').with_value('0.0.0.0')}
end
describe 'with migration_support enabled' do
context 'with vncserver_listen set to 0.0.0.0' do
let :params do
{ :vncserver_listen => '0.0.0.0',
:migration_support => true }
end
it { should include_class('nova::migration::libvirt')}
it { should contain_nova_config('vncserver_listen').with_value('0.0.0.0')}
end
context 'with vncserver_listen not set to 0.0.0.0' do
let :params do
{ :vncserver_listen => '127.0.0.1',
:migration_support => true }
end
it { expect { should contain_class('nova::compute::libvirt') }.to \
raise_error(Puppet::Error, /For migration support to work, you MUST set vncserver_listen to '0.0.0.0'/) }
end
end
end
describe 'on rhel platforms' do
let :facts do
{ :osfamily => 'RedHat' }
end
describe 'with default parameters' do
it { should include_class('nova::params')}
it { should contain_package('libvirt').with(
:name => 'libvirt',
:ensure => 'present'
) }
it { should contain_service('libvirt').with(
:name => 'libvirtd',
:ensure => 'running',
:provider => 'init',
:require => 'Package[libvirt]',
:before => 'Service[nova-compute]'
)}
it { should contain_service('messagebus').with(
:ensure => 'running',
:enable => true,
:before => 'Service[libvirt]'
) }
it { should contain_nova_config('compute_driver').with_value('libvirt.LibvirtDriver')}
it { should contain_nova_config('libvirt_type').with_value('kvm')}
it { should contain_nova_config('connection_type').with_value('libvirt')}
it { should contain_nova_config('vncserver_listen').with_value('127.0.0.1')}
end
describe 'with params' do
let :params do
{ :libvirt_type => 'qemu',
:vncserver_listen => '0.0.0.0'
}
end
it { should contain_nova_config('libvirt_type').with_value('qemu')}
it { should contain_nova_config('vncserver_listen').with_value('0.0.0.0')}
end
describe 'with migration_support enabled' do
context 'with vncserver_listen set to 0.0.0.0' do
let :params do
{ :vncserver_listen => '0.0.0.0',
:migration_support => true }
end
it { should include_class('nova::migration::libvirt')}
it { should contain_nova_config('vncserver_listen').with_value('0.0.0.0')}
end
context 'with vncserver_listen not set to 0.0.0.0' do
let :params do
{ :vncserver_listen => '127.0.0.1',
:migration_support => true }
end
it { expect { should contain_class('nova::compute::libvirt') }.to \
raise_error(Puppet::Error, /For migration support to work, you MUST set vncserver_listen to '0.0.0.0'/) }
end
end
end
end

View File

@ -1,34 +1,61 @@
require 'spec_helper'
describe 'nova::db::mysql' do
let :required_params do
{ :password => "qwerty" }
end
context 'on a Debian osfamily' do
let :facts do
{ :osfamily => "Debian" }
end
let :params do
{ :password => "qwerty" }
context 'with only required parameters' do
let :params do
required_params
end
it { should contain_mysql__db('nova').with(
:user => 'nova',
:password => 'qwerty',
:charset => 'latin1',
:require => "Class[Mysql::Config]"
)}
end
context 'when overriding charset' do
let :params do
{ :charset => 'utf8' }.merge(required_params)
end
it { should contain_mysql__db('nova').with_charset(params[:charset]) }
end
it { should contain_mysql__db('nova').with(
:user => 'nova',
:password => 'qwerty',
:charset => 'latin1',
:require => "Class[Mysql::Config]"
)}
end
context 'on a RedHat osfamily' do
let :facts do
{ :osfamily => 'RedHat' }
end
let :params do
{ :password => 'qwerty' }
context 'with only required parameters' do
let :params do
required_params
end
it { should contain_mysql__db('nova').with(
:user => 'nova',
:password => 'qwerty',
:charset => 'latin1',
:require => "Class[Mysql::Config]"
)}
end
context 'when overriding charset' do
let :params do
{ :charset => 'utf8' }.merge(required_params)
end
it { should contain_mysql__db('nova').with_charset(params[:charset]) }
end
it { should contain_mysql__db('nova').with(
:user => 'nova',
:password => 'qwerty',
:charset => 'latin1',
:require => "Class[Mysql::Config]"
)}
end
end