Adds Database Configuration Support for Havana

Previously, database configuration information was stored in the
plugin .ini file.  As of Havana, a [database] section has been
created in neutron.conf to manage the database configuation for
all Neutron plugins:

https://github.com/openstack/neutron/blob/stable/havana/etc/neutron.conf#L315

Additionaly, several database flags have changed from Grizzly to
Havana.  For backwards compatibility, the previously supported
database flags are contained in neutron::server with a default
of false.

Change-Id: I300fc12092bca1abdd105e0c0c272f7fd49258ac
This commit is contained in:
danehans 2013-10-31 17:33:36 +00:00
parent 6a91ac0d82
commit 82552e7931
8 changed files with 151 additions and 69 deletions

View File

@ -55,11 +55,11 @@ class { '::neutron':
class { 'neutron::server':
auth_host => '127.0.0.1', # the keystone host address
auth_password => 'keystone_neutron_secret',
sql_connection => 'mysql://neutron:neutron_sql_secret@127.0.0.1/neutron?charset=utf8',
}
# enable the Open VSwitch plugin server
class { 'neutron::plugins::ovs':
sql_connection => 'mysql://neutron:neutron_sql_secret@127.0.0.1/neutron?charset=utf8',
tenant_network_type => 'gre',
network_vlan_ranges => 'physnet:1000:2000',
}

View File

@ -13,6 +13,7 @@ class { 'neutron':
# The API server talks to keystone for authorisation
class { 'neutron::server':
keystone_password => 'password',
connection => 'mysql://neutron:password@192.168.1.1/neutron',
}
# Various agents
@ -29,7 +30,6 @@ class { 'neutron::agents::ovs':
# Plugin
class { 'neutron::plugins::ovs':
sql_connection => 'mysql://neutron:password@localhost/neutron',
tenant_network_type => 'gre',
}
@ -53,6 +53,5 @@ class { 'neutron::agents::ovs':
# Plugin
class { 'neutron::plugins::ovs':
sql_connection => 'mysql://neutron:password@192.168.1.1/neutron',
tenant_network_type => 'gre',
}

View File

@ -5,8 +5,9 @@
# === Parameters
#
# [*sql_connection*]
# (required) SQL connection string with the format:
# [driver]://[user]:[password]@[host]/[database]
# sql_connection is no longer configured in the plugin.ini.
# Use $connection in the nuetron::server class to configure the SQL
# connection string.
#
# [*network_vlan_ranges*]
# (required) Comma-separated list of <physical_network>[:<vlan_min>:<vlan_max>]
@ -21,7 +22,7 @@
# (optional) Ensure state for package. Defaults to 'present'.
#
class neutron::plugins::linuxbridge (
$sql_connection = 'sqlite:////var/lib/neutron/linuxbridge.sqlite',
$sql_connection = false,
$network_vlan_ranges = 'physnet1:1000:2000',
$tenant_network_type = 'vlan',
$package_ensure = 'present'
@ -52,8 +53,11 @@ class neutron::plugins::linuxbridge (
name => $::neutron::params::linuxbridge_server_package,
}
if $sql_connection {
warning('sql_connection is deprecated for connection in the neutron::server class')
}
neutron_plugin_linuxbridge {
'DATABASE/sql_connection': value => $sql_connection;
'VLANS/tenant_network_type': value => $tenant_network_type;
'VLANS/network_vlan_ranges': value => $network_vlan_ranges;
}

View File

@ -5,16 +5,12 @@
#
# === Parameters
#
# [*sql_idle_timeout*]
# (optional) Timeout for SQL to reap connetions.
# Defaults to '3600'.
#
class neutron::plugins::ovs (
$package_ensure = 'present',
$sql_connection = 'sqlite:////var/lib/neutron/ovs.sqlite',
$sql_max_retries = 10,
$sql_idle_timeout = '3600',
$reconnect_interval = 2,
$sql_connection = false,
$sql_max_retries = false,
$sql_idle_timeout = false,
$reconnect_interval = false,
$tenant_network_type = 'vlan',
# NB: don't need tunnel ID range when using VLANs,
# *but* you do need the network vlan range regardless of type,
@ -33,23 +29,6 @@ class neutron::plugins::ovs (
Neutron_plugin_ovs<||> ~> Service<| title == 'neutron-server' |>
Package['neutron-plugin-ovs'] -> Service<| title == 'neutron-server' |>
validate_re($sql_connection, '(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
case $sql_connection {
/mysql:\/\/\S+:\S+@\S+\/\S+/: {
require 'mysql::python'
}
/postgresql:\/\/\S+:\S+@\S+\/\S+/: {
$backend_package = 'python-psycopg2'
}
/sqlite:\/\//: {
$backend_package = 'python-pysqlite2'
}
default: {
fail("Invalid sql connection: ${sql_connection}")
}
}
if ! defined(Package['neutron-plugin-ovs']) {
package { 'neutron-plugin-ovs':
ensure => $package_ensure,
@ -57,11 +36,23 @@ class neutron::plugins::ovs (
}
}
if $sql_connection {
warning('sql_connection is deprecated for connection in the neutron::server class')
}
if $sql_max_retries {
warning('sql_max_retries is deprecated for max_retries in the neutron::server class')
}
if $sql_idle_timeout {
warning('sql_idle_timeout is deprecated for idle_timeout in the neutron::server class')
}
if $reconnect_interval {
warning('reconnect_interval is deprecated for retry_interval in the neutron::server class')
}
neutron_plugin_ovs {
'DATABASE/sql_connection': value => $sql_connection;
'DATABASE/sql_max_retries': value => $sql_max_retries;
'DATABASE/sql_idle_timeout': value => $sql_idle_timeout;
'DATABASE/reconnect_interval': value => $reconnect_interval;
'OVS/tenant_network_type': value => $tenant_network_type;
}

View File

@ -61,20 +61,48 @@
# (optional) Complete public Identity API endpoint.
# Defaults to: $auth_protocol://$auth_host:5000/
#
# [*connection*]
# (optional) Connection url for the neutron database.
# Deprecates sql_connection
# Defaults to: sqlite:////var/lib/neutron/ovs.sqlite
#
# [*max_retries*]
# (optional) Database reconnection retry times.
# Deprecates sql_max_retries
# Defaults to: 10
#
# [*idle_timeout*]
# (optional) Timeout before idle db connections are reaped.
# Deprecates sql_idle_timeout
# Defaults to: 3600
#
# [*retry_interval*]
# (optional) Database reconnection interval in seconds.
# Deprecates reconnect_interval
# Defaults to: 10
#
class neutron::server (
$package_ensure = 'present',
$enabled = true,
$auth_password = false,
$auth_type = 'keystone',
$auth_host = 'localhost',
$auth_port = '35357',
$auth_admin_prefix = false,
$auth_tenant = 'services',
$auth_user = 'neutron',
$auth_protocol = 'http',
$auth_uri = false,
$log_file = false,
$log_dir = '/var/log/neutron'
$package_ensure = 'present',
$enabled = true,
$auth_password = false,
$auth_type = 'keystone',
$auth_host = 'localhost',
$auth_port = '35357',
$auth_admin_prefix = false,
$auth_tenant = 'services',
$auth_user = 'neutron',
$auth_protocol = 'http',
$auth_uri = false,
$sql_connection = 'sqlite:////var/lib/neutron/ovs.sqlite',
$connection = 'sqlite:////var/lib/neutron/ovs.sqlite',
$max_retries = '10',
$sql_max_retries = '10',
$sql_idle_timeout = '3600',
$idle_timeout = '3600',
$reconnect_interval = '10',
$retry_interval = '10',
$log_file = false,
$log_dir = '/var/log/neutron'
) {
include neutron::params
@ -83,6 +111,58 @@ class neutron::server (
Neutron_config<||> ~> Service['neutron-server']
Neutron_api_config<||> ~> Service['neutron-server']
if $sql_connection {
warning('sql_connection deprecated for connection')
$connection_real = $sql_connection
} else {
$connection_real = $connection
}
if $sql_max_retries {
warning('sql_max_retries deprecated for max_retries')
$max_retries_real = $sql_max_retries
} else {
$max_retries_real = $max_retries
}
if $sql_idle_timeout {
warning('sql_idle_timeout deprecated for idle_timeout')
$idle_timeout_real = $sql_idle_timeout
} else {
$idle_timeout_real = $idle_timeout
}
if $reconnect_interval {
warning('reconnect_interval deprecated for retry_interval')
$retry_interval_real = $reconnect_interval
} else {
$retry_interval_real = $retry_interval
}
validate_re($connection_real, '(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
case $connection_real {
/mysql:\/\/\S+:\S+@\S+\/\S+/: {
require 'mysql::python'
}
/postgresql:\/\/\S+:\S+@\S+\/\S+/: {
$backend_package = 'python-psycopg2'
}
/sqlite:\/\//: {
$backend_package = 'python-pysqlite2'
}
default: {
fail("Invalid sql connection: ${connection_real}")
}
}
neutron_config {
'database/connection': value => $connection_real;
'database/idle_timeout': value => $idle_timeout_real;
'database/retry_interval': value => $retry_interval_real;
'database/max_retries': value => $max_retries_real;
}
if $log_file {
neutron_config {
'DEFAULT/log_file': value => $log_file;

View File

@ -7,7 +7,7 @@ describe 'neutron::plugins::linuxbridge' do
end
let :params do
{ :sql_connection => 'mysql://user:pass@db/db',
{ :sql_connection => false,
:network_vlan_ranges => 'physnet0:100:109',
:tenant_network_type => 'vlan',
:package_ensure => 'installed'
@ -26,9 +26,6 @@ describe 'neutron::plugins::linuxbridge' do
end
it 'configures linuxbridge_conf.ini' do
should contain_neutron_plugin_linuxbridge('DATABASE/sql_connection').with(
:value => params[:sql_connection]
)
should contain_neutron_plugin_linuxbridge('VLANS/tenant_network_type').with(
:value => params[:tenant_network_type]
)

View File

@ -9,10 +9,10 @@ describe 'neutron::plugins::ovs' do
let :default_params do
{
:package_ensure => 'present',
:sql_connection => 'sqlite:////var/lib/neutron/ovs.sqlite',
:sql_max_retries => 10,
:sql_idle_timeout => '3600',
:reconnect_interval => 2,
:sql_connection => false,
:sql_max_retries => false,
:sql_idle_timeout => false,
:reconnect_interval => false,
:tunnel_id_ranges => '1:1000',
:network_vlan_ranges => 'physnet1:1000:2000'
}
@ -32,10 +32,6 @@ describe 'neutron::plugins::ovs' do
end
it 'should perform default configuration of' do
should contain_neutron_plugin_ovs('DATABASE/sql_connection').with_value(params[:sql_connection])
should contain_neutron_plugin_ovs('DATABASE/sql_max_retries').with_value(params[:sql_max_retries])
should contain_neutron_plugin_ovs('DATABASE/sql_idle_timeout').with_value(params[:sql_idle_timeout])
should contain_neutron_plugin_ovs('DATABASE/reconnect_interval').with_value(params[:reconnect_interval])
should contain_neutron_plugin_ovs('OVS/tenant_network_type').with_value(params[:tenant_network_type])
should contain_package('neutron-plugin-ovs').with(
:name => platform_params[:ovs_server_package],

View File

@ -12,14 +12,22 @@ describe 'neutron::server' do
end
let :default_params do
{ :package_ensure => 'present',
:enabled => true,
:log_dir => '/var/log/neutron',
:auth_type => 'keystone',
:auth_host => 'localhost',
:auth_port => '35357',
:auth_tenant => 'services',
:auth_user => 'neutron' }
{ :package_ensure => 'present',
:enabled => true,
:log_dir => '/var/log/neutron',
:auth_type => 'keystone',
:auth_host => 'localhost',
:auth_port => '35357',
:auth_tenant => 'services',
:auth_user => 'neutron',
:sql_connection => 'sqlite:////var/lib/neutron/ovs.sqlite',
:connection => 'sqlite:////var/lib/neutron/ovs.sqlite',
:sql_max_retries => '10',
:max_retries => '10',
:sql_idle_timeout => '3600',
:idle_timeout => '3600',
:reconnect_interval => '10',
:retry_interval => '10' }
end
shared_examples_for 'a neutron server' do
@ -27,6 +35,13 @@ describe 'neutron::server' do
default_params.merge(params)
end
it 'should perform default database configuration of' do
should contain_neutron_config('database/connection').with_value(p[:connection])
should contain_neutron_config('database/max_retries').with_value(p[:max_retries])
should contain_neutron_config('database/idle_timeout').with_value(p[:idle_timeout])
should contain_neutron_config('database/retry_interval').with_value(p[:retry_interval])
end
it { should include_class('neutron::params') }
it 'configures logging' do
should contain_neutron_config('DEFAULT/log_file').with_ensure('absent')