Merge pull request #41 from bodepd/allow_enabled
Add enabled parameter to glance services.
This commit is contained in:
commit
9071ed1743
@ -46,7 +46,8 @@ class glance::api(
|
|||||||
$auth_uri = "http://127.0.0.1:5000/",
|
$auth_uri = "http://127.0.0.1:5000/",
|
||||||
$keystone_tenant = 'admin',
|
$keystone_tenant = 'admin',
|
||||||
$keystone_user = 'admin',
|
$keystone_user = 'admin',
|
||||||
$keystone_password = 'ChangeMe'
|
$keystone_password = 'ChangeMe',
|
||||||
|
$enabled = true
|
||||||
) inherits glance {
|
) inherits glance {
|
||||||
|
|
||||||
# used to configure concat
|
# used to configure concat
|
||||||
@ -100,10 +101,16 @@ class glance::api(
|
|||||||
content => template('glance/glance-cache.conf.erb'),
|
content => template('glance/glance-cache.conf.erb'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if $enabled {
|
||||||
|
$service_ensure = 'running'
|
||||||
|
} else {
|
||||||
|
$service_ensure = 'stopped'
|
||||||
|
}
|
||||||
|
|
||||||
service { 'glance-api':
|
service { 'glance-api':
|
||||||
name => $::glance::params::api_service_name,
|
name => $::glance::params::api_service_name,
|
||||||
ensure => running,
|
ensure => $service_ensure,
|
||||||
enable => true,
|
enable => $enabled,
|
||||||
hasstatus => true,
|
hasstatus => true,
|
||||||
hasrestart => true,
|
hasrestart => true,
|
||||||
subscribe => Concat['/etc/glance/glance-api.conf'],
|
subscribe => Concat['/etc/glance/glance-api.conf'],
|
||||||
|
@ -13,7 +13,8 @@ class glance::registry(
|
|||||||
$auth_uri = 'http://127.0.0.1:5000/',
|
$auth_uri = 'http://127.0.0.1:5000/',
|
||||||
$keystone_tenant = 'admin',
|
$keystone_tenant = 'admin',
|
||||||
$keystone_user = 'admin',
|
$keystone_user = 'admin',
|
||||||
$keystone_password = 'ChangeMe'
|
$keystone_password = 'ChangeMe',
|
||||||
|
$enabled = true
|
||||||
) inherits glance {
|
) inherits glance {
|
||||||
|
|
||||||
require 'keystone::python'
|
require 'keystone::python'
|
||||||
@ -35,21 +36,26 @@ class glance::registry(
|
|||||||
content => template('glance/glance-registry-paste.ini.erb'),
|
content => template('glance/glance-registry-paste.ini.erb'),
|
||||||
}
|
}
|
||||||
|
|
||||||
exec { 'glance-manage db_sync':
|
if $enabled {
|
||||||
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'],
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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':
|
service { 'glance-registry':
|
||||||
name => $::glance::params::registry_service_name,
|
name => $::glance::params::registry_service_name,
|
||||||
ensure => running,
|
ensure => $service_ensure,
|
||||||
enable => true,
|
enable => $enabled,
|
||||||
hasstatus => true,
|
hasstatus => true,
|
||||||
hasrestart => true,
|
hasrestart => true,
|
||||||
subscribe => File['/etc/glance/glance-registry.conf'],
|
subscribe => File['/etc/glance/glance-registry.conf'],
|
||||||
|
@ -18,7 +18,8 @@ describe 'glance::api' do
|
|||||||
:registry_host => '0.0.0.0',
|
:registry_host => '0.0.0.0',
|
||||||
:registry_port => '9191',
|
:registry_port => '9191',
|
||||||
:log_file => '/var/log/glance/api.log',
|
:log_file => '/var/log/glance/api.log',
|
||||||
:auth_type => 'keystone'
|
:auth_type => 'keystone',
|
||||||
|
:enabled => true
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -31,7 +32,8 @@ describe 'glance::api' do
|
|||||||
:registry_host => '127.0.0.1',
|
:registry_host => '127.0.0.1',
|
||||||
:registry_port => '9111',
|
:registry_port => '9111',
|
||||||
:log_file => '/var/log/glance-api.log',
|
:log_file => '/var/log/glance-api.log',
|
||||||
:auth_type => 'not_keystone'
|
:auth_type => 'not_keystone',
|
||||||
|
:enabled => false
|
||||||
}
|
}
|
||||||
].each do |param_set|
|
].each do |param_set|
|
||||||
|
|
||||||
@ -48,7 +50,8 @@ describe 'glance::api' do
|
|||||||
it { should contain_class 'glance' }
|
it { should contain_class 'glance' }
|
||||||
|
|
||||||
it { should contain_service('glance-api').with(
|
it { should contain_service('glance-api').with(
|
||||||
'ensure' => 'running',
|
'ensure' => param_hash[:enabled] ? 'running': 'stopped',
|
||||||
|
'enable' => param_hash[:enabled],
|
||||||
'hasstatus' => 'true',
|
'hasstatus' => 'true',
|
||||||
'hasrestart' => 'true',
|
'hasrestart' => 'true',
|
||||||
'subscribe' => 'Concat[/etc/glance/glance-api.conf]'
|
'subscribe' => 'Concat[/etc/glance/glance-api.conf]'
|
||||||
|
@ -16,7 +16,8 @@ describe 'glance::registry' do
|
|||||||
:bind_port => '9191',
|
:bind_port => '9191',
|
||||||
:log_file => '/var/log/glance/registry.log',
|
:log_file => '/var/log/glance/registry.log',
|
||||||
:sql_connection => 'sqlite:///var/lib/glance/glance.sqlite',
|
:sql_connection => 'sqlite:///var/lib/glance/glance.sqlite',
|
||||||
:sql_idle_timeout => '3600'
|
:sql_idle_timeout => '3600',
|
||||||
|
:enabled => true
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,7 +30,8 @@ describe 'glance::registry' do
|
|||||||
:bind_port => '9111',
|
:bind_port => '9111',
|
||||||
:log_file => '/var/log/glance-registry.log',
|
:log_file => '/var/log/glance-registry.log',
|
||||||
:sql_connection => 'sqlite:///var/lib/glance.sqlite',
|
:sql_connection => 'sqlite:///var/lib/glance.sqlite',
|
||||||
:sql_idle_timeout => '360'
|
:sql_idle_timeout => '360',
|
||||||
|
:enabled => false
|
||||||
}
|
}
|
||||||
].each do |param_set|
|
].each do |param_set|
|
||||||
|
|
||||||
@ -45,21 +47,26 @@ describe 'glance::registry' do
|
|||||||
it { should contain_class 'glance::registry' }
|
it { should contain_class 'glance::registry' }
|
||||||
|
|
||||||
it { should contain_service('glance-registry').with(
|
it { should contain_service('glance-registry').with(
|
||||||
'ensure' => 'running',
|
'ensure' => param_hash[:enabled] ? 'running' : 'stopped',
|
||||||
'enable' => 'true',
|
'enable' => param_hash[:enabled],
|
||||||
'hasstatus' => 'true',
|
'hasstatus' => 'true',
|
||||||
'hasrestart' => 'true',
|
'hasrestart' => 'true',
|
||||||
'subscribe' => 'File[/etc/glance/glance-registry.conf]',
|
'subscribe' => 'File[/etc/glance/glance-registry.conf]',
|
||||||
'require' => 'Class[Glance]'
|
'require' => 'Class[Glance]'
|
||||||
)}
|
)}
|
||||||
|
|
||||||
it { should contain_exec('glance-manage db_sync').with(
|
it 'should only sync the db if the service is enabled' do
|
||||||
'path' => '/usr/bin',
|
|
||||||
'refreshonly' => true,
|
if param_hash[:enabled]
|
||||||
'logoutput' => 'on_failure',
|
should contain_exec('glance-manage db_sync').with(
|
||||||
'subscribe' => ['Package[glance]', 'File[/etc/glance/glance-registry.conf]'],
|
'path' => '/usr/bin',
|
||||||
'notify' => 'Service[glance-registry]'
|
'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
|
it 'should compile the template based on the class parameters' do
|
||||||
content = param_value(subject, 'file', '/etc/glance/glance-registry.conf', 'content')
|
content = param_value(subject, 'file', '/etc/glance/glance-registry.conf', 'content')
|
||||||
|
Loading…
Reference in New Issue
Block a user