Merge "Drop support for standalone api service in CentOS/Ubuntu"
This commit is contained in:
commit
b4494d575f
|
@ -10,23 +10,6 @@
|
||||||
# (optional) Whether the service should be managed by Puppet.
|
# (optional) Whether the service should be managed by Puppet.
|
||||||
# Defaults to true.
|
# Defaults to true.
|
||||||
#
|
#
|
||||||
# [*host*]
|
|
||||||
# (optional) The panko api bind address.
|
|
||||||
# Defaults to 0.0.0.0
|
|
||||||
#
|
|
||||||
# [*port*]
|
|
||||||
# (optional) The panko api port.
|
|
||||||
# Defaults to 8977
|
|
||||||
#
|
|
||||||
# [*workers*]
|
|
||||||
# (optional) Number of workers for Panko API server.
|
|
||||||
# Defaults to $::os_workers
|
|
||||||
#
|
|
||||||
# [*max_limit*]
|
|
||||||
# (optional) The maximum number of items returned in a
|
|
||||||
# single response from a collection resource.
|
|
||||||
# Defaults to 1000
|
|
||||||
#
|
|
||||||
# [*package_ensure*]
|
# [*package_ensure*]
|
||||||
# (optional) ensure state for package.
|
# (optional) ensure state for package.
|
||||||
# Defaults to 'present'
|
# Defaults to 'present'
|
||||||
|
@ -80,14 +63,29 @@
|
||||||
# (<= 0 means forever)
|
# (<= 0 means forever)
|
||||||
# Defaults to $::os_service_default.
|
# Defaults to $::os_service_default.
|
||||||
#
|
#
|
||||||
|
# DEPRECATED PARAMETERS
|
||||||
|
#
|
||||||
|
# [*host*]
|
||||||
|
# (optional) The panko api bind address.
|
||||||
|
# Defaults to undef
|
||||||
|
#
|
||||||
|
# [*port*]
|
||||||
|
# (optional) The panko api port.
|
||||||
|
# Defaults to undef
|
||||||
|
#
|
||||||
|
# [*workers*]
|
||||||
|
# (optional) Number of workers for Panko API server.
|
||||||
|
# Defaults to undef
|
||||||
|
#
|
||||||
|
# [*max_limit*]
|
||||||
|
# (optional) The maximum number of items returned in a
|
||||||
|
# single response from a collection resource.
|
||||||
|
# Defaults to undef
|
||||||
|
#
|
||||||
class panko::api (
|
class panko::api (
|
||||||
$manage_service = true,
|
$manage_service = true,
|
||||||
$enabled = true,
|
$enabled = true,
|
||||||
$package_ensure = 'present',
|
$package_ensure = 'present',
|
||||||
$host = '0.0.0.0',
|
|
||||||
$port = '8977',
|
|
||||||
$workers = $::os_workers,
|
|
||||||
$max_limit = 1000,
|
|
||||||
$service_name = $::panko::params::api_service_name,
|
$service_name = $::panko::params::api_service_name,
|
||||||
$sync_db = false,
|
$sync_db = false,
|
||||||
$auth_strategy = 'keystone',
|
$auth_strategy = 'keystone',
|
||||||
|
@ -98,8 +96,26 @@ class panko::api (
|
||||||
$es_ssl_enabled = $::os_service_default,
|
$es_ssl_enabled = $::os_service_default,
|
||||||
$es_index_name = $::os_service_default,
|
$es_index_name = $::os_service_default,
|
||||||
$event_time_to_live = $::os_service_default,
|
$event_time_to_live = $::os_service_default,
|
||||||
|
# DEPRECATED PARAMETERS
|
||||||
|
$host = undef,
|
||||||
|
$port = undef,
|
||||||
|
$workers = undef,
|
||||||
|
$max_limit = undef,
|
||||||
) inherits panko::params {
|
) inherits panko::params {
|
||||||
|
|
||||||
|
if $host != undef {
|
||||||
|
warning('The panko::api::host parameter is deprecated and has no effect')
|
||||||
|
}
|
||||||
|
if $port != undef {
|
||||||
|
warning('The panko::api::port parameter is deprecated and has no effect')
|
||||||
|
}
|
||||||
|
if $workers != undef {
|
||||||
|
warning('The panko::api::workers parameter is deprecated and has no effect')
|
||||||
|
}
|
||||||
|
if $max_limit != undef {
|
||||||
|
warning('The panko::api::max_limit parameter is deprecated and has no effect')
|
||||||
|
}
|
||||||
|
|
||||||
include panko::deps
|
include panko::deps
|
||||||
include panko::policy
|
include panko::policy
|
||||||
|
|
||||||
|
@ -121,10 +137,11 @@ class panko::api (
|
||||||
include panko::db::sync
|
include panko::db::sync
|
||||||
}
|
}
|
||||||
|
|
||||||
if $service_name == $::panko::params::api_service_name {
|
$api_service_name = $::panko::params::api_service_name
|
||||||
|
if $api_service_name != 'httpd' and $service_name == $api_service_name {
|
||||||
service { 'panko-api':
|
service { 'panko-api':
|
||||||
ensure => $service_ensure,
|
ensure => $service_ensure,
|
||||||
name => $::panko::params::api_service_name,
|
name => $api_service_name,
|
||||||
enable => $enabled,
|
enable => $enabled,
|
||||||
hasstatus => true,
|
hasstatus => true,
|
||||||
hasrestart => true,
|
hasrestart => true,
|
||||||
|
@ -132,29 +149,26 @@ class panko::api (
|
||||||
}
|
}
|
||||||
} elsif $service_name == 'httpd' {
|
} elsif $service_name == 'httpd' {
|
||||||
include apache::params
|
include apache::params
|
||||||
service { 'panko-api':
|
|
||||||
ensure => 'stopped',
|
|
||||||
name => $::panko::params::api_service_name,
|
|
||||||
enable => false,
|
|
||||||
tag => ['panko-service', 'panko-db-sync-service'],
|
|
||||||
}
|
|
||||||
Class['panko::db'] -> Service[$service_name]
|
|
||||||
Service <| title == 'httpd' |> {
|
Service <| title == 'httpd' |> {
|
||||||
tag +> ['panko-service', 'panko-db-sync-service']
|
tag +> ['panko-service', 'panko-db-sync-service']
|
||||||
}
|
}
|
||||||
|
Class['panko::db'] -> Service[$service_name]
|
||||||
|
|
||||||
# we need to make sure panko-api/eventlet is stopped before trying to start apache
|
if $api_service_name != 'httpd' {
|
||||||
Service['panko-api'] -> Service[$service_name]
|
service { 'panko-api':
|
||||||
|
ensure => 'stopped',
|
||||||
|
name => $api_service_name,
|
||||||
|
enable => false,
|
||||||
|
tag => ['panko-service', 'panko-db-sync-service'],
|
||||||
|
}
|
||||||
|
# we need to make sure panko-api/eventlet is stopped before trying to start apache
|
||||||
|
Service['panko-api'] -> Service[$service_name]
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fail("Invalid service_name. Either panko/openstack-panko-api for \
|
fail('Invalid service_name.')
|
||||||
running as a standalone service, or httpd for being run by a httpd server")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
panko_config {
|
panko_config {
|
||||||
'api/host': value => $host;
|
|
||||||
'api/port': value => $port;
|
|
||||||
'api/workers': value => $workers;
|
|
||||||
'api/max_limit': value => $max_limit;
|
|
||||||
'storage/max_retries': value => $max_retries;
|
'storage/max_retries': value => $max_retries;
|
||||||
'storage/retry_interval': value => $retry_interval;
|
'storage/retry_interval': value => $retry_interval;
|
||||||
'storage/es_ssl_enabled': value => $es_ssl_enabled;
|
'storage/es_ssl_enabled': value => $es_ssl_enabled;
|
||||||
|
|
|
@ -12,14 +12,21 @@ class panko::params {
|
||||||
'RedHat': {
|
'RedHat': {
|
||||||
$common_package_name = 'openstack-panko-common'
|
$common_package_name = 'openstack-panko-common'
|
||||||
$api_package_name = 'openstack-panko-api'
|
$api_package_name = 'openstack-panko-api'
|
||||||
$api_service_name = 'openstack-panko-api'
|
$api_service_name = 'httpd'
|
||||||
$panko_wsgi_script_path = '/var/www/cgi-bin/panko'
|
$panko_wsgi_script_path = '/var/www/cgi-bin/panko'
|
||||||
$panko_wsgi_script_source = '/usr/bin/panko-api'
|
$panko_wsgi_script_source = '/usr/bin/panko-api'
|
||||||
}
|
}
|
||||||
'Debian': {
|
'Debian': {
|
||||||
$common_package_name = 'panko-common'
|
$common_package_name = 'panko-common'
|
||||||
$api_package_name = 'panko-api'
|
$api_package_name = 'panko-api'
|
||||||
$api_service_name = 'panko-api'
|
case $::operatingsystem {
|
||||||
|
'Ubuntu': {
|
||||||
|
$api_service_name = 'httpd'
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
$api_service_name = 'panko-api'
|
||||||
|
}
|
||||||
|
}
|
||||||
$panko_wsgi_script_path = '/usr/lib/cgi-bin/panko'
|
$panko_wsgi_script_path = '/usr/lib/cgi-bin/panko'
|
||||||
$panko_wsgi_script_source = '/usr/bin/panko-api'
|
$panko_wsgi_script_source = '/usr/bin/panko-api'
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
---
|
||||||
|
deprecations:
|
||||||
|
- |
|
||||||
|
The following parameters in ``panko::api`` class have been deprecated and
|
||||||
|
now have no effect. These parameters will be removed in a future release.
|
||||||
|
|
||||||
|
- ``host``
|
||||||
|
- ``port``
|
||||||
|
- ``workers``
|
||||||
|
- ``max_limit``
|
||||||
|
|
||||||
|
upgrade:
|
||||||
|
- |
|
||||||
|
The ``panko::api`` class no longer supports standalone api service in
|
||||||
|
CentOS and Ubuntu, because these 2 distros don't provide standalone api
|
||||||
|
service and require that wsgi is used to run the api service.
|
|
@ -3,7 +3,8 @@ require 'spec_helper'
|
||||||
describe 'panko::api' do
|
describe 'panko::api' do
|
||||||
|
|
||||||
let :pre_condition do
|
let :pre_condition do
|
||||||
"class { 'panko': }
|
"include apache
|
||||||
|
class { 'panko': }
|
||||||
include panko::db
|
include panko::db
|
||||||
class {'panko::keystone::authtoken':
|
class {'panko::keystone::authtoken':
|
||||||
password => 'password',
|
password => 'password',
|
||||||
|
@ -14,9 +15,6 @@ describe 'panko::api' do
|
||||||
{ :enabled => true,
|
{ :enabled => true,
|
||||||
:manage_service => true,
|
:manage_service => true,
|
||||||
:package_ensure => 'latest',
|
:package_ensure => 'latest',
|
||||||
:port => '8977',
|
|
||||||
:max_limit => '1000',
|
|
||||||
:host => '0.0.0.0',
|
|
||||||
:max_retries => '10',
|
:max_retries => '10',
|
||||||
:retry_interval => '20',
|
:retry_interval => '20',
|
||||||
:es_ssl_enabled => true,
|
:es_ssl_enabled => true,
|
||||||
|
@ -40,10 +38,6 @@ describe 'panko::api' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'configures keystone authentication middleware' do
|
it 'configures keystone authentication middleware' do
|
||||||
is_expected.to contain_panko_config('api/host').with_value( params[:host] )
|
|
||||||
is_expected.to contain_panko_config('api/port').with_value( params[:port] )
|
|
||||||
is_expected.to contain_panko_config('api/max_limit').with_value( params[:max_limit] )
|
|
||||||
is_expected.to contain_panko_config('api/workers').with_value('2')
|
|
||||||
is_expected.to contain_panko_config('storage/max_retries').with_value(params[:max_retries])
|
is_expected.to contain_panko_config('storage/max_retries').with_value(params[:max_retries])
|
||||||
is_expected.to contain_panko_config('storage/retry_interval').with_value(params[:retry_interval])
|
is_expected.to contain_panko_config('storage/retry_interval').with_value(params[:retry_interval])
|
||||||
is_expected.to contain_panko_config('storage/es_ssl_enabled').with_value(params[:es_ssl_enabled])
|
is_expected.to contain_panko_config('storage/es_ssl_enabled').with_value(params[:es_ssl_enabled])
|
||||||
|
@ -55,27 +49,6 @@ describe 'panko::api' do
|
||||||
is_expected.to contain_panko_config('database/event_time_to_live').with_value( params[:event_time_to_live] )
|
is_expected.to contain_panko_config('database/event_time_to_live').with_value( params[:event_time_to_live] )
|
||||||
end
|
end
|
||||||
|
|
||||||
[{:enabled => true}, {:enabled => false}].each do |param_hash|
|
|
||||||
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
|
|
||||||
before do
|
|
||||||
params.merge!(param_hash)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'configures panko-api service' do
|
|
||||||
is_expected.to contain_service('panko-api').with(
|
|
||||||
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
|
||||||
:name => platform_params[:api_service_name],
|
|
||||||
:enable => params[:enabled],
|
|
||||||
:hasstatus => true,
|
|
||||||
:hasrestart => true,
|
|
||||||
:tag => ['panko-service', 'panko-db-sync-service'],
|
|
||||||
)
|
|
||||||
end
|
|
||||||
it { is_expected.to contain_service('panko-api').that_subscribes_to('Anchor[panko::service::begin]')}
|
|
||||||
it { is_expected.to contain_service('panko-api').that_notifies('Anchor[panko::service::end]')}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'with sync_db set to true' do
|
context 'with sync_db set to true' do
|
||||||
before do
|
before do
|
||||||
params.merge!({
|
params.merge!({
|
||||||
|
@ -104,6 +77,82 @@ describe 'panko::api' do
|
||||||
)}
|
)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when service_name is not valid' do
|
||||||
|
before do
|
||||||
|
params.merge!({ :service_name => 'foobar' })
|
||||||
|
end
|
||||||
|
|
||||||
|
let :pre_condition do
|
||||||
|
"include apache
|
||||||
|
include panko::db
|
||||||
|
class { 'panko': }"
|
||||||
|
end
|
||||||
|
|
||||||
|
it_raises 'a Puppet::Error', /Invalid service_name/
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with noauth" do
|
||||||
|
before do
|
||||||
|
params.merge!({
|
||||||
|
:auth_strategy => 'noauth',
|
||||||
|
})
|
||||||
|
end
|
||||||
|
it 'configures pipeline' do
|
||||||
|
is_expected.to contain_panko_api_paste_ini('pipeline:main/pipeline').with_value('panko+noauth');
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with keystone" do
|
||||||
|
before do
|
||||||
|
params.merge!({
|
||||||
|
:auth_strategy => 'keystone',
|
||||||
|
})
|
||||||
|
end
|
||||||
|
it 'configures pipeline' do
|
||||||
|
is_expected.to contain_panko_api_paste_ini('pipeline:main/pipeline').with_value('panko+auth');
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
shared_examples_for 'panko-api without standalone service' do
|
||||||
|
|
||||||
|
let :pre_condition do
|
||||||
|
"include apache
|
||||||
|
include panko::db
|
||||||
|
class { 'panko': }
|
||||||
|
class {'panko::keystone::authtoken':
|
||||||
|
password => 'password',
|
||||||
|
}"
|
||||||
|
end
|
||||||
|
|
||||||
|
it { is_expected.to_not contain_service('panko-api') }
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
shared_examples_for 'panko-api with standalone service' do
|
||||||
|
|
||||||
|
[{:enabled => true}, {:enabled => false}].each do |param_hash|
|
||||||
|
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
|
||||||
|
before do
|
||||||
|
params.merge!(param_hash)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures panko-api service' do
|
||||||
|
is_expected.to contain_service('panko-api').with(
|
||||||
|
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
|
||||||
|
:name => platform_params[:api_service_name],
|
||||||
|
:enable => params[:enabled],
|
||||||
|
:hasstatus => true,
|
||||||
|
:hasrestart => true,
|
||||||
|
:tag => ['panko-service', 'panko-db-sync-service'],
|
||||||
|
)
|
||||||
|
end
|
||||||
|
it { is_expected.to contain_service('panko-api').that_subscribes_to('Anchor[panko::service::begin]')}
|
||||||
|
it { is_expected.to contain_service('panko-api').that_notifies('Anchor[panko::service::end]')}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'with disabled service managing' do
|
context 'with disabled service managing' do
|
||||||
before do
|
before do
|
||||||
params.merge!({
|
params.merge!({
|
||||||
|
@ -146,42 +195,6 @@ describe 'panko::api' do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when service_name is not valid' do
|
|
||||||
before do
|
|
||||||
params.merge!({ :service_name => 'foobar' })
|
|
||||||
end
|
|
||||||
|
|
||||||
let :pre_condition do
|
|
||||||
"include apache
|
|
||||||
include panko::db
|
|
||||||
class { 'panko': }"
|
|
||||||
end
|
|
||||||
|
|
||||||
it_raises 'a Puppet::Error', /Invalid service_name/
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with noauth" do
|
|
||||||
before do
|
|
||||||
params.merge!({
|
|
||||||
:auth_strategy => 'noauth',
|
|
||||||
})
|
|
||||||
end
|
|
||||||
it 'configures pipeline' do
|
|
||||||
is_expected.to contain_panko_api_paste_ini('pipeline:main/pipeline').with_value('panko+noauth');
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with keystone" do
|
|
||||||
before do
|
|
||||||
params.merge!({
|
|
||||||
:auth_strategy => 'keystone',
|
|
||||||
})
|
|
||||||
end
|
|
||||||
it 'configures pipeline' do
|
|
||||||
is_expected.to contain_panko_api_paste_ini('pipeline:main/pipeline').with_value('panko+auth');
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
on_supported_os({
|
on_supported_os({
|
||||||
|
@ -197,13 +210,22 @@ describe 'panko::api' do
|
||||||
let(:platform_params) do
|
let(:platform_params) do
|
||||||
case facts[:osfamily]
|
case facts[:osfamily]
|
||||||
when 'Debian'
|
when 'Debian'
|
||||||
{ :api_package_name => 'panko-api',
|
if facts[:operatingsystem] == 'Ubuntu'
|
||||||
:api_service_name => 'panko-api' }
|
{ :api_package_name => 'panko-api' }
|
||||||
|
else
|
||||||
|
{ :api_package_name => 'panko-api',
|
||||||
|
:api_service_name => 'panko-api' }
|
||||||
|
end
|
||||||
when 'RedHat'
|
when 'RedHat'
|
||||||
{ :api_package_name => 'openstack-panko-api',
|
{ :api_package_name => 'openstack-panko-api' }
|
||||||
:api_service_name => 'openstack-panko-api' }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if facts[:osfamily] == 'Debian' and facts[:operatingsystem] != 'Ubuntu'
|
||||||
|
it_behaves_like 'panko-api with standalone service'
|
||||||
|
else
|
||||||
|
it_behaves_like 'panko-api without standalone service'
|
||||||
|
end
|
||||||
it_behaves_like 'panko-api'
|
it_behaves_like 'panko-api'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue