diff --git a/manifests/plugins/cisco.pp b/manifests/plugins/cisco.pp index 7ef371738..b620d3f63 100644 --- a/manifests/plugins/cisco.pp +++ b/manifests/plugins/cisco.pp @@ -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'] } diff --git a/manifests/plugins/linuxbridge.pp b/manifests/plugins/linuxbridge.pp index 229a8797b..f784f6804 100644 --- a/manifests/plugins/linuxbridge.pp +++ b/manifests/plugins/linuxbridge.pp @@ -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'] } } diff --git a/manifests/plugins/ml2.pp b/manifests/plugins/ml2.pp index e1f9ec249..0b16b5f4d 100644 --- a/manifests/plugins/ml2.pp +++ b/manifests/plugins/ml2.pp @@ -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; diff --git a/manifests/plugins/nvp.pp b/manifests/plugins/nvp.pp index 23df1a915..96269f8d0 100644 --- a/manifests/plugins/nvp.pp +++ b/manifests/plugins/nvp.pp @@ -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'] + } + } diff --git a/manifests/plugins/ovs.pp b/manifests/plugins/ovs.pp index 6129f2b07..474a9dc3e 100644 --- a/manifests/plugins/ovs.pp +++ b/manifests/plugins/ovs.pp @@ -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'] } } diff --git a/manifests/server.pp b/manifests/server.pp index 2a861c9c9..fb3c7f88a 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -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; diff --git a/spec/classes/neutron_plugins_cisco_spec.rb b/spec/classes/neutron_plugins_cisco_spec.rb index ac87ef881..1e09c512a 100644 --- a/spec/classes/neutron_plugins_cisco_spec.rb +++ b/spec/classes/neutron_plugins_cisco_spec.rb @@ -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 diff --git a/spec/classes/neutron_plugins_linuxbridge_spec.rb b/spec/classes/neutron_plugins_linuxbridge_spec.rb index e28a5310d..bbe0480e4 100644 --- a/spec/classes/neutron_plugins_linuxbridge_spec.rb +++ b/spec/classes/neutron_plugins_linuxbridge_spec.rb @@ -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 diff --git a/spec/classes/neutron_plugins_ml2_spec.rb b/spec/classes/neutron_plugins_ml2_spec.rb index 6522a3d67..b6318ee44 100644 --- a/spec/classes/neutron_plugins_ml2_spec.rb +++ b/spec/classes/neutron_plugins_ml2_spec.rb @@ -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( diff --git a/spec/classes/neutron_plugins_nvp_spec.rb b/spec/classes/neutron_plugins_nvp_spec.rb index 090b7bb09..c6c19c203 100644 --- a/spec/classes/neutron_plugins_nvp_spec.rb +++ b/spec/classes/neutron_plugins_nvp_spec.rb @@ -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]) diff --git a/spec/classes/neutron_plugins_ovs_spec.rb b/spec/classes/neutron_plugins_ovs_spec.rb index 887b27959..fd24ab2ea 100644 --- a/spec/classes/neutron_plugins_ovs_spec.rb +++ b/spec/classes/neutron_plugins_ovs_spec.rb @@ -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 diff --git a/spec/classes/neutron_server_spec.rb b/spec/classes/neutron_server_spec.rb index 718fe7150..7c6c900b1 100644 --- a/spec/classes/neutron_server_spec.rb +++ b/spec/classes/neutron_server_spec.rb @@ -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