Merge pull request #41 from bodepd/allow_enabled

Add enabled parameter to glance services.
This commit is contained in:
Branan Purvine-Riley 2012-06-18 10:36:51 -07:00
commit 9071ed1743
4 changed files with 52 additions and 29 deletions

View File

@ -46,7 +46,8 @@ class glance::api(
$auth_uri = "http://127.0.0.1:5000/",
$keystone_tenant = 'admin',
$keystone_user = 'admin',
$keystone_password = 'ChangeMe'
$keystone_password = 'ChangeMe',
$enabled = true
) inherits glance {
# used to configure concat
@ -100,10 +101,16 @@ class glance::api(
content => template('glance/glance-cache.conf.erb'),
}
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
service { 'glance-api':
name => $::glance::params::api_service_name,
ensure => running,
enable => true,
ensure => $service_ensure,
enable => $enabled,
hasstatus => true,
hasrestart => true,
subscribe => Concat['/etc/glance/glance-api.conf'],

View File

@ -13,7 +13,8 @@ class glance::registry(
$auth_uri = 'http://127.0.0.1:5000/',
$keystone_tenant = 'admin',
$keystone_user = 'admin',
$keystone_password = 'ChangeMe'
$keystone_password = 'ChangeMe',
$enabled = true
) inherits glance {
require 'keystone::python'
@ -35,21 +36,26 @@ class glance::registry(
content => template('glance/glance-registry-paste.ini.erb'),
}
exec { 'glance-manage db_sync':
command => $::glance::params::db_sync_command,
path => '/usr/bin',
user => 'glance',
refreshonly => true,
logoutput => on_failure,
subscribe => [Package['glance'], File['/etc/glance/glance-registry.conf']],
notify => Service['glance-registry'],
}
if $enabled {
exec { 'glance-manage db_sync':
command => $::glance::params::db_sync_command,
path => '/usr/bin',
user => 'glance',
refreshonly => true,
logoutput => on_failure,
subscribe => [Package['glance'], File['/etc/glance/glance-registry.conf']],
notify => Service['glance-registry'],
}
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
service { 'glance-registry':
name => $::glance::params::registry_service_name,
ensure => running,
enable => true,
ensure => $service_ensure,
enable => $enabled,
hasstatus => true,
hasrestart => true,
subscribe => File['/etc/glance/glance-registry.conf'],

View File

@ -18,7 +18,8 @@ describe 'glance::api' do
:registry_host => '0.0.0.0',
:registry_port => '9191',
:log_file => '/var/log/glance/api.log',
:auth_type => 'keystone'
:auth_type => 'keystone',
:enabled => true
}
end
@ -31,7 +32,8 @@ describe 'glance::api' do
:registry_host => '127.0.0.1',
:registry_port => '9111',
:log_file => '/var/log/glance-api.log',
:auth_type => 'not_keystone'
:auth_type => 'not_keystone',
:enabled => false
}
].each do |param_set|
@ -48,7 +50,8 @@ describe 'glance::api' do
it { should contain_class 'glance' }
it { should contain_service('glance-api').with(
'ensure' => 'running',
'ensure' => param_hash[:enabled] ? 'running': 'stopped',
'enable' => param_hash[:enabled],
'hasstatus' => 'true',
'hasrestart' => 'true',
'subscribe' => 'Concat[/etc/glance/glance-api.conf]'

View File

@ -16,7 +16,8 @@ describe 'glance::registry' do
:bind_port => '9191',
:log_file => '/var/log/glance/registry.log',
:sql_connection => 'sqlite:///var/lib/glance/glance.sqlite',
:sql_idle_timeout => '3600'
:sql_idle_timeout => '3600',
:enabled => true
}
end
@ -29,7 +30,8 @@ describe 'glance::registry' do
:bind_port => '9111',
:log_file => '/var/log/glance-registry.log',
:sql_connection => 'sqlite:///var/lib/glance.sqlite',
:sql_idle_timeout => '360'
:sql_idle_timeout => '360',
:enabled => false
}
].each do |param_set|
@ -45,21 +47,26 @@ describe 'glance::registry' do
it { should contain_class 'glance::registry' }
it { should contain_service('glance-registry').with(
'ensure' => 'running',
'enable' => 'true',
'ensure' => param_hash[:enabled] ? 'running' : 'stopped',
'enable' => param_hash[:enabled],
'hasstatus' => 'true',
'hasrestart' => 'true',
'subscribe' => 'File[/etc/glance/glance-registry.conf]',
'require' => 'Class[Glance]'
)}
it { should contain_exec('glance-manage db_sync').with(
'path' => '/usr/bin',
'refreshonly' => true,
'logoutput' => 'on_failure',
'subscribe' => ['Package[glance]', 'File[/etc/glance/glance-registry.conf]'],
'notify' => 'Service[glance-registry]'
)}
it 'should only sync the db if the service is enabled' do
if param_hash[:enabled]
should contain_exec('glance-manage db_sync').with(
'path' => '/usr/bin',
'refreshonly' => true,
'logoutput' => 'on_failure',
'subscribe' => ['Package[glance]', 'File[/etc/glance/glance-registry.conf]'],
'notify' => 'Service[glance-registry]'
)
end
end
it 'should compile the template based on the class parameters' do
content = param_value(subject, 'file', '/etc/glance/glance-registry.conf', 'content')