Skip to content

Commit

Permalink
Merge "Add support for running neutron api by httpd+mod_wsgi"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Nov 17, 2021
2 parents aef6cd2 + ef06ac4 commit feba1ff
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 42 deletions.
4 changes: 2 additions & 2 deletions manifests/keystone/auth.pp
Expand Up @@ -90,11 +90,11 @@
include neutron::deps

if $configure_endpoint {
Keystone_endpoint["${region}/${service_name}::${service_type}"] ~> Service <| tag == 'neutron-server-eventlet' |>
Keystone_endpoint["${region}/${service_name}::${service_type}"] -> Anchor['neutron::service::end']
}

if $configure_user_role {
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| tag == 'neutron-server-eventlet' |>
Keystone_user_role["${auth_name}@${tenant}"] -> Anchor['neutron::service::end']
}

keystone::resource::service_identity { 'neutron':
Expand Down
2 changes: 1 addition & 1 deletion manifests/params.pp
Expand Up @@ -75,7 +75,7 @@
$mlnx_agent_service = 'neutron-mlnx-agent'
} elsif($::osfamily == 'Debian') {
$package_name = 'neutron-common'
if $::os_package_type =='debian' {
if $::operatingsystem == 'Debian' {
$ml2_server_package = false
$server_service = false
$server_package = false
Expand Down
70 changes: 52 additions & 18 deletions manifests/server.pp
Expand Up @@ -403,19 +403,9 @@
tag => ['neutron-service', 'neutron-db-sync-service', 'neutron-server-eventlet'],
}
} elsif $service_name == 'httpd' {
include apache::params
service { 'neutron-server':
ensure => 'stopped',
name => $::neutron::params::server_service,
enable => false,
hasstatus => true,
hasrestart => true,
tag => ['neutron-service', 'neutron-db-sync-service'],
}
Service <| title == 'httpd' |> { tag +> 'neutron-service' }
# we need to make sure neutron-server is stopped before trying to start apache
Service[$::neutron::params::server_service] -> Service[$service_name]
fail('Use api_service_name and rpc_service_name to run api service by httpd')
} else {
warning('Support for arbitaly service name is deprecated')
# backward compatibility so operators can customize the service name.
service { 'neutron-server':
ensure => $service_ensure,
Expand All @@ -427,14 +417,54 @@
}
}
} else {
if $api_service_name {
if $::neutron::params::server_service {
# we need to make sure neutron-server is stopped before trying to
# start separate services.
service { 'neutron-server':
ensure => $service_ensure,
name => $api_service_name,
enable => $enabled,
ensure => 'stopped',
name => $::neutron::params::server_service,
enable => false,
hasstatus => true,
hasrestart => true,
tag => ['neutron-service', 'neutron-db-sync-service', 'neutron-server-eventlet'],
tag => ['neutron-service'],
}
}

if $api_service_name {
if $api_service_name == 'httpd' {
include apache::params
Service <| title == 'httpd' |> { tag +> 'neutron-service' }

if $::neutron::params::server_service {
Service['neutron-server'] -> Service['httpd']
}

if $::neutron::params::api_service_name {
# we need to make sure api service is stopped before trying to
# start apache
service { 'neutron-api':
ensure => 'stopped',
name => $::neutron::params::api_service_name,
enable => false,
hasstatus => true,
hasrestart => true,
tag => ['neutron-service'],
}
Service['neutron-api'] -> Service['httpd']
}
} else {
service { 'neutron-api':
ensure => $service_ensure,
name => $api_service_name,
enable => $enabled,
hasstatus => true,
hasrestart => true,
tag => ['neutron-service', 'neutron-db-sync-service', 'neutron-server-eventlet'],
}

if $::neutron::params::server_service {
Service['neutron-server'] -> Service['neutron-api']
}
}
}

Expand All @@ -447,6 +477,10 @@
hasrestart => true,
tag => ['neutron-service', 'neutron-db-sync-service'],
}

if $::neutron::params::server_service {
Service['neutron-server'] -> Service['neutron-rpc-server']
}
}
}

Expand All @@ -470,6 +504,6 @@
'try_sleep' => '2',
}
}
create_resources('openstacklib::service_validation', $validation_cmd, {'subscribe' => 'Service[neutron-server]'})
create_resources('openstacklib::service_validation', $validation_cmd, {'subscribe' => 'Anchor[neutron::service::end]'})
}
}
17 changes: 17 additions & 0 deletions releasenotes/notes/neutron-api-wsgi-97ea733fb608da78.yaml
@@ -0,0 +1,17 @@
---
features:
- |
Now ``neutron::server::api_service_name`` can accept and handle ``httpd``
as a valid service name, to run api service by httpd+mod_wsgi.
upgrade:
- |
The ``neutron::server::service_name`` parameter no longer accepts
``httpd`` as a valid service name. To run api service by httpd,
the ``neutron::server::api_service_name`` parameter should be used instead
along with the ``neutron::server::rpc_service_name``.
deprecations:
- |
Usage of arbitaly service name for the ``neutron::server::service_name``
has been deprecated and will be removed in a future release.
96 changes: 75 additions & 21 deletions spec/classes/neutron_server_spec.rb
Expand Up @@ -49,16 +49,36 @@ class { 'neutron::keystone::authtoken':
end

it 'configures neutron server service' do
should contain_service('neutron-server').with(
:name => platform_params[:server_service],
:enable => true,
:ensure => 'running',
:tag => ['neutron-service', 'neutron-db-sync-service', 'neutron-server-eventlet'],
)
should contain_service('neutron-server').that_subscribes_to('Anchor[neutron::service::begin]')
should contain_service('neutron-server').that_notifies('Anchor[neutron::service::end]')
if platform_params.has_key?(:server_service)
should contain_service('neutron-server').with(
:name => platform_params[:server_service],
:enable => true,
:ensure => 'running',
:tag => ['neutron-service', 'neutron-db-sync-service', 'neutron-server-eventlet'],
)
should contain_service('neutron-server').that_subscribes_to('Anchor[neutron::service::begin]')
should contain_service('neutron-server').that_notifies('Anchor[neutron::service::end]')
else
should contain_service('neutron-api').with(
:name => platform_params[:api_service_name],
:enable => true,
:ensure => 'running',
:tag => ['neutron-service', 'neutron-db-sync-service', 'neutron-server-eventlet'],
)
should contain_service('neutron-api').that_subscribes_to('Anchor[neutron::service::begin]')
should contain_service('neutron-api').that_notifies('Anchor[neutron::service::end]')

should contain_service('neutron-rpc-server').with(
:name => platform_params[:rpc_service_name],
:enable => true,
:ensure => 'running',
:tag => ['neutron-service', 'neutron-db-sync-service'],
)
should contain_service('neutron-rpc-server').that_subscribes_to('Anchor[neutron::service::begin]')
should contain_service('neutron-rpc-server').that_notifies('Anchor[neutron::service::end]')
end

should_not contain_class('neutron::db::sync')
should contain_service('neutron-server').with_name('neutron-server')
should contain_neutron_config('DEFAULT/api_workers').with_value(facts[:os_workers])
should contain_neutron_config('DEFAULT/rpc_workers').with_value(facts[:os_workers])
should contain_neutron_config('DEFAULT/rpc_state_report_workers').with_value('<SERVICE DEFAULT>')
Expand All @@ -80,7 +100,12 @@ class { 'neutron::keystone::authtoken':
end

it 'should not start/stop service' do
should contain_service('neutron-server').without_ensure
if platform_params.has_key?(:server_service)
should contain_service('neutron-server').without_ensure
else
should contain_service('neutron-api').without_ensure
should contain_service('neutron-rpc-server').without_ensure
end
end
end

Expand Down Expand Up @@ -219,7 +244,11 @@ class { 'neutron::keystone::authtoken':

context 'when running neutron-api in wsgi' do
before :each do
params.merge!( :service_name => 'httpd' )
params.merge!(
:service_name => false,
:api_service_name => 'httpd',
:rpc_service_name => 'neutron-rpc-server',
)
end

let :pre_condition do
Expand All @@ -231,11 +260,27 @@ class { 'neutron::keystone::authtoken':
end

it 'configures neutron-api service with Apache' do
should contain_service('neutron-server').with(
:ensure => 'stopped',
:name => platform_params[:server_service],
:enable => false,
:tag => ['neutron-service', 'neutron-db-sync-service'],
if platform_params.has_key?(:server_service)
should contain_service('neutron-server').with(
:ensure => 'stopped',
:name => platform_params[:server_service],
:enable => false,
:tag => ['neutron-service'],
)
else
should contain_service('neutron-api').with(
:ensure => 'stopped',
:name => platform_params[:api_service_name],
:enable => false,
:tag => ['neutron-service'],
)
end

should contain_service('neutron-rpc-server').with(
:ensure => 'running',
:name => 'neutron-rpc-server',
:enable => true,
:tag => ['neutron-service', 'neutron-db-sync-service'],
)
end
end
Expand Down Expand Up @@ -332,13 +377,22 @@ class { 'neutron::keystone::authtoken':
let (:platform_params) do
case facts[:osfamily]
when 'Debian'
{
:server_package => 'neutron-server',
:server_service => 'neutron-server'
}
if facts[:operatingsystem] == 'Ubuntu'
{
:server_package => 'neutron-server',
:server_service => 'neutron-server',
:rpc_service_name => 'neutron-rpc-server',
}
else
{
:api_service_name => 'neutron-api',
:rpc_service_name => 'neutron-rpc-server',
}
end
when 'RedHat'
{
:server_service => 'neutron-server'
:server_service => 'neutron-server',
:rpc_service_name => 'neutron-rpc-server',
}
end
end
Expand Down

0 comments on commit feba1ff

Please sign in to comment.