Ensure Neutron DB is populated

- Create symbolic link to have /etc/neutron/plugin.ini
- This file is used to synchronize the database

In that way, the command to populate database is generic to all plugins.

Fixes-Bug #1275688

Change-Id: If320b4fa5682245ac2cc9b4a9f05cf02dadc84c0
Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
Emilien Macchi 2014-02-03 13:28:03 +01:00
parent c5ce246584
commit fea38195c6
12 changed files with 123 additions and 41 deletions

@ -169,12 +169,12 @@ class neutron::plugins::cisco(
'keystone/tenant' : value => $keystone_tenant;
}
if $::osfamily == 'Redhat' {
file {'/etc/neutron/plugin.ini':
ensure => link,
target => '/etc/neutron/plugins/cisco/cisco_plugins.ini',
require => Package['neutron-plugin-cisco'],
}
# In RH, this link is used to start Neutron process but in Debian, it's used only
# to manage database synchronization.
file {'/etc/neutron/plugin.ini':
ensure => link,
target => '/etc/neutron/plugins/cisco/cisco_plugins.ini',
require => Package['neutron-plugin-cisco']
}

@ -62,12 +62,12 @@ class neutron::plugins::linuxbridge (
'VLANS/network_vlan_ranges': value => $network_vlan_ranges;
}
if $::osfamily == 'Redhat' {
file {'/etc/neutron/plugin.ini':
ensure => link,
target => '/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini',
require => Package['neutron-plugin-linuxbridge']
}
# In RH, this link is used to start Neutron process but in Debian, it's used only
# to manage database synchronization.
file {'/etc/neutron/plugin.ini':
ensure => link,
target => '/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini',
require => Package['neutron-plugin-linuxbridge']
}
}

@ -111,12 +111,25 @@ class neutron::plugins::ml2 (
}
# Some platforms do not have a dedicated ml2 plugin package
# In RH, the link is used to start Neutron process but in Debian, it's used only
# to manage database synchronization.
if $::neutron::params::ml2_server_package {
package { 'neutron-plugin-ml2':
ensure => present,
name => $::neutron::params::ml2_server_package,
}
Package['neutron-plugin-ml2'] -> Neutron_plugin_ml2<||>
file {'/etc/neutron/plugin.ini':
ensure => link,
target => '/etc/neutron/plugins/ml2/ml2_conf.ini',
require => Package['neutron-plugin-ml2']
}
} else {
file {'/etc/neutron/plugin.ini':
ensure => link,
target => '/etc/neutron/plugins/ml2/ml2_conf.ini',
require => Package['openstack-neutron']
}
}
neutron::plugins::ml2::driver { $type_drivers:
@ -173,14 +186,6 @@ class neutron::plugins::ml2 (
}
}
if $::osfamily == 'Redhat' {
file {'/etc/neutron/plugin.ini':
ensure => link,
target => '/etc/neutron/plugins/ml2/ml2_conf.ini',
require => Package['openstack-neutron']
}
}
if $enable_security_group {
neutron_plugin_ml2 {
'securitygroup/firewall_driver': value => $enable_security_group;

@ -61,4 +61,13 @@ class neutron::plugins::nvp (
if $::neutron::core_plugin != 'neutron.plugins.nicira.NeutronPlugin.NvpPluginV2' {
fail('nvp plugin should be the core_plugin in neutron.conf')
}
# In RH, this link is used to start Neutron process but in Debian, it's used only
# to manage database synchronization.
file {'/etc/neutron/plugin.ini':
ensure => link,
target => '/etc/neutron/plugins/nicira/nvp.ini',
require => Package['neutron-plugin-nvp']
}
}

@ -89,11 +89,11 @@ class neutron::plugins::ovs (
}
}
if $::osfamily == 'Redhat' {
file {'/etc/neutron/plugin.ini':
ensure => link,
target => '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini',
require => Package['neutron-plugin-ovs']
}
# In RH, this link is used to start Neutron process but in Debian, it's used only
# to manage database synchronization.
file {'/etc/neutron/plugin.ini':
ensure => link,
target => '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini',
require => Package['neutron-plugin-ovs']
}
}

@ -104,6 +104,10 @@
# [*retry_interval*]
# DEPRECATED: Use database_retry_interval instead.
#
# [*sync_db*]
# (optional) Run neutron-db-manage on api nodes after installing the package.
# Defaults to true
#
# [*api_workers*]
# (optional) Number of separate worker processes to spawn.
# The default, 0, runs the worker thread in the current process.
@ -144,6 +148,7 @@ class neutron::server (
$database_max_retries = 10,
$database_idle_timeout = 3600,
$database_retry_interval = 10,
$sync_db = true,
$log_file = false,
$log_dir = '/var/log/neutron',
$api_workers = '0',
@ -224,6 +229,23 @@ class neutron::server (
}
}
if $sync_db {
if ($::neutron::params::server_package) {
# Debian platforms
Package<| title == 'neutron-server' |> ~> Exec['neutron-db-sync']
} else {
# RH platforms
Package<| title == 'neutron' |> ~> Exec['neutron-db-sync']
}
exec { 'neutron-db-sync':
command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head',
path => '/usr/bin',
before => Service['neutron-server'],
require => Neutron_config['database/connection'],
refreshonly => true
}
}
neutron_config {
'DEFAULT/api_workers': value => $api_workers;
'DEFAULT/agent_down_time': value => $agent_down_time;

@ -39,6 +39,14 @@ describe 'neutron::plugins::cisco' do
params.merge!(params_default)
end
it 'should create plugin symbolic link' do
should contain_file('/etc/neutron/plugin.ini').with(
:ensure => 'link',
:target => '/etc/neutron/plugins/cisco/cisco_plugins.ini',
:require => 'Package[neutron-plugin-cisco]'
)
end
it 'should have a plugin config folder' do
should contain_file('/etc/neutron/plugins').with(
:ensure => 'directory',
@ -140,13 +148,6 @@ describe 'neutron::plugins::cisco' do
end
it_configures 'default cisco plugin'
it 'should perform redhat specific configuration' do
should contain_file('/etc/neutron/plugin.ini').with(
:ensure => 'link',
:target => '/etc/neutron/plugins/cisco/cisco_plugins.ini',
:require => 'Package[neutron-plugin-cisco]'
)
end
end

@ -33,6 +33,15 @@ describe 'neutron::plugins::linuxbridge' do
:value => params[:network_vlan_ranges]
)
end
it 'should create plugin symbolic link' do
should contain_file('/etc/neutron/plugin.ini').with(
:ensure => 'link',
:target => '/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini',
:require => 'Package[neutron-plugin-linuxbridge]'
)
end
end

@ -62,6 +62,13 @@ describe 'neutron::plugins::ml2' do
should contain_neutron_plugin_ml2('securitygroup/firewall_driver').with_value('neutron.agent.firewall.NoopFirewallDriver')
end
it 'should create plugin symbolic link' do
should contain_file('/etc/neutron/plugin.ini').with(
:ensure => 'link',
:target => '/etc/neutron/plugins/ml2/ml2_conf.ini'
)
end
it 'installs ml2 package (if any)' do
if platform_params.has_key?(:ml2_server_package)
should contain_package('neutron-plugin-ml2').with(

@ -44,6 +44,14 @@ describe 'neutron::plugins::nvp' do
should contain_neutron_config('DEFAULT/core_plugin').with_value('neutron.plugins.nicira.NeutronPlugin.NvpPluginV2')
end
it 'should create plugin symbolic link' do
should contain_file('/etc/neutron/plugin.ini').with(
:ensure => 'link',
:target => '/etc/neutron/plugins/nicira/nvp.ini',
:require => 'Package[neutron-plugin-nvp]'
)
end
it 'should configure nvp.ini' do
should contain_neutron_plugin_nvp('DEFAULT/default_tz_uuid').with_value(p[:default_tz_uuid])
should contain_neutron_plugin_nvp('nvp/metadata_mode').with_value(p[:metadata_mode])

@ -31,6 +31,14 @@ describe 'neutron::plugins::ovs' do
{ :tenant_network_type => 'vlan' }
end
it 'should create plugin symbolic link' do
should contain_file('/etc/neutron/plugin.ini').with(
:ensure => 'link',
:target => '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini',
:require => 'Package[neutron-plugin-ovs]'
)
end
it 'should perform default configuration of' do
should contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type])
should contain_package('neutron-plugin-ovs').with(
@ -187,14 +195,6 @@ describe 'neutron::plugins::ovs' do
{ :ovs_server_package => 'openstack-neutron-openvswitch' }
end
it 'should perform redhat specific configuration' do
should contain_file('/etc/neutron/plugin.ini').with(
:ensure => 'link',
:target => '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini',
:require => 'Package[neutron-plugin-ovs]'
)
end
it_configures 'neutron ovs plugin'
end
end

@ -24,6 +24,7 @@ describe 'neutron::server' do
:database_max_retries => '10',
:database_idle_timeout => '3600',
:database_retry_interval => '10',
:sync_db => true,
:api_workers => '0',
:agent_down_time => '9',
:report_interval => '4',
@ -80,6 +81,13 @@ describe 'neutron::server' do
:ensure => 'running',
:require => 'Class[Neutron]'
)
should contain_exec('neutron-db-sync').with(
:command => 'neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugin.ini upgrade head',
:path => '/usr/bin',
:before => 'Service[neutron-server]',
:require => 'Neutron_config[database/connection]',
:refreshonly => true
)
should contain_neutron_api_config('filter:authtoken/auth_admin_prefix').with(
:ensure => 'absent'
)
@ -131,6 +139,17 @@ describe 'neutron::server' do
it_raises 'a Puppet::Error', /auth_password must be set/
end
shared_examples_for 'a neutron server without database synchronization' do
before do
params.merge!(
:sync_db => false
)
end
it 'should not exec neutron-db-sync' do
should_not contain_exec('neutron-db-sync')
end
end
shared_examples_for 'a neutron server with log_file specified' do
before do
params.merge!(
@ -244,6 +263,7 @@ describe 'neutron::server' do
it_configures 'a neutron server with some incorrect auth_admin_prefix set'
it_configures 'a neutron server with deprecated parameters'
it_configures 'a neutron server with database_connection specified'
it_configures 'a neutron server without database synchronization'
end
context 'on RedHat platforms' do
@ -263,5 +283,6 @@ describe 'neutron::server' do
it_configures 'a neutron server with some incorrect auth_admin_prefix set'
it_configures 'a neutron server with deprecated parameters'
it_configures 'a neutron server with database_connection specified'
it_configures 'a neutron server without database synchronization'
end
end