Merge "Refactor placement::api"
This commit is contained in:
commit
b84e6bf77d
@ -36,50 +36,49 @@
|
||||
# Defaults to false
|
||||
#
|
||||
class placement::api (
|
||||
$enabled = true,
|
||||
$manage_service = true,
|
||||
$api_service_name = $::placement::params::service_name,
|
||||
$host = '0.0.0.0',
|
||||
$port = '8778',
|
||||
$package_ensure = 'present',
|
||||
$sync_db = false,
|
||||
$enabled = true,
|
||||
$manage_service = true,
|
||||
$api_service_name = $::placement::params::service_name,
|
||||
$host = '0.0.0.0',
|
||||
$port = '8778',
|
||||
$package_ensure = 'present',
|
||||
$sync_db = false,
|
||||
) inherits placement::params {
|
||||
|
||||
include placement::deps
|
||||
|
||||
package { 'placement-api':
|
||||
ensure => $package_ensure,
|
||||
name => $::placement::params::package_name,
|
||||
tag => ['openstack', 'placement-package'],
|
||||
if $manage_service {
|
||||
if $api_service_name == 'httpd' {
|
||||
# The following logic is currently required only in Debian, because
|
||||
# the other distributions don't provide an independent service for
|
||||
# placement
|
||||
if $::placement::params::service_name {
|
||||
service { 'placement-api':
|
||||
ensure => 'stopped',
|
||||
name => $::placement::params::service_name,
|
||||
enable => false,
|
||||
tag => ['placement-service'],
|
||||
}
|
||||
Service['placement-api'] -> Service[$api_service_name]
|
||||
}
|
||||
$api_service_name_real = false
|
||||
} else {
|
||||
$api_service_name_real = $api_service_name
|
||||
}
|
||||
|
||||
Service <| title == 'httpd' |> { tag +> 'placement-service' }
|
||||
} else {
|
||||
$api_service_name_real = $api_service_name
|
||||
}
|
||||
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
if $api_service_name == $::placement::params::service_name {
|
||||
service { 'placement-api':
|
||||
ensure => $service_ensure,
|
||||
name => $::placement::params::service_name,
|
||||
enable => $enabled,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
tag => ['placement-service', 'placement-db-sync-service'],
|
||||
}
|
||||
} elsif $api_service_name == 'httpd' {
|
||||
include apache::params
|
||||
service { 'placement-api':
|
||||
ensure => 'stopped',
|
||||
name => $::placement::params::service_name,
|
||||
enable => false,
|
||||
tag => ['placement-service', 'placement-db-sync-service'],
|
||||
}
|
||||
Service['placement-api'] -> Service[$api_service_name]
|
||||
Service<| title == 'httpd' |> { tag +> ['placement-service', 'placement-db-sync-service'] }
|
||||
}
|
||||
placement::generic_service { 'api':
|
||||
service_name => $api_service_name_real,
|
||||
package_name => $::placement::params::package_name,
|
||||
manage_service => $manage_service,
|
||||
enabled => $enabled,
|
||||
ensure_package => $package_ensure,
|
||||
}
|
||||
|
||||
if $sync_db {
|
||||
include placement::db::sync
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class placement::params {
|
||||
$package_name = 'openstack-placement-api'
|
||||
$common_package_name = 'openstack-placement-common'
|
||||
$python_package_name = "python${pyvers_real}-placement"
|
||||
$service_name = 'httpd'
|
||||
$service_name = false
|
||||
$public_url = 'http://127.0.0.1/placement'
|
||||
$internal_url = 'http://127.0.0.1/placement'
|
||||
$admin_url = 'http://127.0.0.1/placement'
|
||||
@ -36,7 +36,7 @@ class placement::params {
|
||||
$service_name = 'placement-api'
|
||||
}
|
||||
default: {
|
||||
$service_name = 'httpd'
|
||||
$service_name = false
|
||||
}
|
||||
}
|
||||
$public_url = 'http://127.0.0.1'
|
||||
|
@ -120,10 +120,13 @@ class placement::wsgi::apache (
|
||||
include apache::mod::ssl
|
||||
}
|
||||
|
||||
placement::generic_service { 'api':
|
||||
service_name => false,
|
||||
package_name => $::placement::params::package_name,
|
||||
ensure_package => $ensure_package,
|
||||
if ! defined(Class['placement::api']) {
|
||||
warning('placement::api class will be required in a future release')
|
||||
placement::generic_service { 'api':
|
||||
service_name => false,
|
||||
package_name => $::placement::params::package_name,
|
||||
ensure_package => $ensure_package,
|
||||
}
|
||||
}
|
||||
|
||||
file { $::placement::params::httpd_config_file:
|
||||
|
5
releasenotes/notes/placement-api-fdecbcf65b84b5f8.yaml
Normal file
5
releasenotes/notes/placement-api-fdecbcf65b84b5f8.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
deprecations:
|
||||
- |
|
||||
The ``placmenet::api`` class will be required in a future release evne when
|
||||
wsgi is used.
|
81
spec/classes/placement_api_spec.rb
Normal file
81
spec/classes/placement_api_spec.rb
Normal file
@ -0,0 +1,81 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'placement::api' do
|
||||
shared_examples 'placement::api' do
|
||||
|
||||
context 'with only required params' do
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
it { should contain_class('placement::deps') }
|
||||
it { should contain_placement__generic_service('api').with(
|
||||
:service_name => platform_params[:service_name],
|
||||
:package_name => platform_params[:package_name],
|
||||
:manage_service => true,
|
||||
:enabled => true,
|
||||
:ensure_package => 'present',
|
||||
) }
|
||||
end
|
||||
|
||||
context 'with package_ensure parameter provided' do
|
||||
let :params do
|
||||
{ :package_ensure => false }
|
||||
end
|
||||
|
||||
it { should contain_placement__generic_service('api').with(
|
||||
:ensure_package => false,
|
||||
) }
|
||||
end
|
||||
|
||||
context 'with manage_service parameter provided' do
|
||||
let :params do
|
||||
{ :manage_service => false }
|
||||
end
|
||||
|
||||
it { should contain_placement__generic_service('api').with(
|
||||
:manage_service => false,
|
||||
) }
|
||||
end
|
||||
|
||||
context 'with sync_db parameter provided' do
|
||||
let :params do
|
||||
{ :sync_db => true }
|
||||
end
|
||||
|
||||
it { should contain_class('placement::db::sync') }
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge(OSDefaults.get_facts({
|
||||
:os_workers => 8,
|
||||
:fqdn => 'some.host.tld',
|
||||
:concat_basedir => '/var/lib/puppet/concat',
|
||||
}))
|
||||
end
|
||||
|
||||
let(:platform_params) do
|
||||
case facts[:osfamily]
|
||||
when 'Debian'
|
||||
if facts[:os_package_type] == 'debian'
|
||||
{ :service_name => 'placement-api',
|
||||
:package_name => 'placement-api'}
|
||||
else
|
||||
{ :service_name => false,
|
||||
:package_name => 'placement-api'}
|
||||
end
|
||||
when 'RedHat'
|
||||
{ :service_name => false,
|
||||
:package_name => 'openstack-placement-api'}
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like 'placement::api'
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user