support separate registry/api packages
on Debian plattforms there are separate packages for glance registry and glance api. This allows you to install api/registry on different servers. If the packages for registry and api are the same, (as it is the case for RedHat plattform) the package is installed in ::glance class. If the packages differs (as for Debian plattform), installation of packages is done in registry/api classes. Additionaly this patch adds a test for unsupported plattforms. Change-Id: I8d4b74e8c8ad2dd7e6e2ad175326f36ff818c108
This commit is contained in:
parent
e61e47d664
commit
394661ec4a
@ -185,8 +185,13 @@ class glance::api(
|
||||
|
||||
validate_re($sql_connection, '(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
Package['glance'] -> Glance_api_config<||>
|
||||
Package['glance'] -> Glance_cache_config<||>
|
||||
if ( $glance::params::api_package_name != $glance::params::registry_package_name ) {
|
||||
ensure_packages([$glance::params::api_package_name])
|
||||
}
|
||||
|
||||
Package[$glance::params::api_package_name] -> Glance_api_config<||>
|
||||
Package[$glance::params::api_package_name] -> Glance_cache_config<||>
|
||||
|
||||
# adding all of this stuff b/c it devstack says glance-api uses the
|
||||
# db now
|
||||
Glance_api_config<||> ~> Exec<| title == 'glance-manage db_sync' |>
|
||||
|
@ -15,10 +15,12 @@ class glance(
|
||||
owner => 'glance',
|
||||
group => 'root',
|
||||
mode => '0770',
|
||||
require => Package['glance']
|
||||
}
|
||||
package { 'glance':
|
||||
ensure => $package_ensure,
|
||||
name => $::glance::params::package_name,
|
||||
|
||||
if ( $glance::params::api_package_name == $glance::params::registry_package_name ) {
|
||||
package { $glance::params::api_package_name :
|
||||
ensure => $package_ensure,
|
||||
name => $::glance::params::package_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,15 @@ class glance::params {
|
||||
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
$package_name = 'openstack-glance'
|
||||
$api_package_name = 'openstack-glance'
|
||||
$registry_package_name = 'openstack-glance'
|
||||
$api_service_name = 'openstack-glance-api'
|
||||
$registry_service_name = 'openstack-glance-registry'
|
||||
$db_sync_command = 'glance-manage db_sync'
|
||||
}
|
||||
'Debian': {
|
||||
$package_name = 'glance'
|
||||
$api_package_name = 'glance-api'
|
||||
$registry_package_name = 'glance-registry'
|
||||
$api_service_name = 'glance-api'
|
||||
$registry_service_name = 'glance-registry'
|
||||
$db_sync_command = 'glance-manage db_sync'
|
||||
|
@ -133,7 +133,12 @@ class glance::registry(
|
||||
|
||||
validate_re($sql_connection, '(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||
|
||||
Package['glance'] -> Glance_registry_config<||>
|
||||
if ( $glance::params::api_package_name != $glance::params::registry_package_name ) {
|
||||
ensure_packages([$glance::params::registry_package_name])
|
||||
}
|
||||
|
||||
Package[$glance::params::registry_package_name] -> Glance_registry_config<||>
|
||||
|
||||
Glance_registry_config<||> ~> Exec<| title == 'glance-manage db_sync' |>
|
||||
Glance_registry_config<||> ~> Service['glance-registry']
|
||||
|
||||
@ -297,7 +302,7 @@ class glance::registry(
|
||||
user => 'glance',
|
||||
refreshonly => true,
|
||||
logoutput => on_failure,
|
||||
subscribe => [Package['glance'], File['/etc/glance/glance-registry.conf']],
|
||||
subscribe => [Package[$glance::params::registry_package_name], File['/etc/glance/glance-registry.conf']],
|
||||
}
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
|
@ -304,4 +304,34 @@ describe 'glance::api' do
|
||||
|
||||
it { should contain_glance_api_config('DEFAULT/known_stores').with_value("glance.store.filesystem.Store,glance.store.http.Store") }
|
||||
end
|
||||
|
||||
describe 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
let(:params) { default_params }
|
||||
|
||||
it {should contain_package('glance-api')}
|
||||
end
|
||||
|
||||
describe 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
let(:params) { default_params }
|
||||
|
||||
it { should contain_package('openstack-glance')}
|
||||
end
|
||||
|
||||
describe 'on unknown platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'unknown' }
|
||||
end
|
||||
let(:params) { default_params }
|
||||
|
||||
it 'should fails to configure glance-api' do
|
||||
expect { subject }.to raise_error(Puppet::Error, /module glance only support osfamily RedHat and Debian/)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -79,7 +79,7 @@ describe 'glance::registry' do
|
||||
'path' => '/usr/bin',
|
||||
'refreshonly' => true,
|
||||
'logoutput' => 'on_failure',
|
||||
'subscribe' => ['Package[glance]', 'File[/etc/glance/glance-registry.conf]'],
|
||||
'subscribe' => ['Package[glance-registry]', 'File[/etc/glance/glance-registry.conf]'],
|
||||
'notify' => 'Service[glance-registry]'
|
||||
)
|
||||
end
|
||||
@ -268,4 +268,33 @@ describe 'glance::registry' do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
let(:params) { default_params }
|
||||
|
||||
it {should contain_package('glance-registry')}
|
||||
end
|
||||
|
||||
describe 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
let(:params) { default_params }
|
||||
|
||||
it { should contain_package('openstack-glance')}
|
||||
end
|
||||
|
||||
describe 'on unknown platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'unknown' }
|
||||
end
|
||||
let(:params) { default_params }
|
||||
|
||||
it 'should fails to configure glance-registry' do
|
||||
expect { subject }.to raise_error(Puppet::Error, /module glance only support osfamily RedHat and Debian/)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -9,12 +9,12 @@ describe 'glance' do
|
||||
end
|
||||
|
||||
let :default_params do
|
||||
{:package_ensure => 'present'}
|
||||
{}
|
||||
end
|
||||
|
||||
[
|
||||
{},
|
||||
{:package_ensure => 'latest'}
|
||||
{}
|
||||
].each do |param_set|
|
||||
|
||||
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
|
||||
@ -25,13 +25,31 @@ describe 'glance' do
|
||||
|
||||
let :params do param_set end
|
||||
|
||||
it { should contain_package('glance').with_ensure(param_hash[:package_ensure]) }
|
||||
it { should contain_file('/etc/glance/').with(
|
||||
'ensure' => 'directory',
|
||||
'owner' => 'glance',
|
||||
'mode' => '0770',
|
||||
'require' => 'Package[glance]'
|
||||
'mode' => '0770'
|
||||
)}
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
describe 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
let(:params) { default_params }
|
||||
|
||||
it {should_not contain_package('glance')}
|
||||
end
|
||||
|
||||
describe 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
let(:params) { default_params }
|
||||
|
||||
it { should contain_package('openstack-glance')}
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user