2013-08-05 13:20:54 -04:00
|
|
|
# == Class: neutron::server
|
2013-05-06 14:15:29 -06:00
|
|
|
#
|
2013-08-05 13:20:54 -04:00
|
|
|
# Setup and configure the neutron API endpoint
|
2013-05-06 14:15:29 -06:00
|
|
|
#
|
|
|
|
# === Parameters
|
|
|
|
#
|
|
|
|
# [*package_ensure*]
|
|
|
|
# (optional) The state of the package
|
|
|
|
# Defaults to present
|
|
|
|
#
|
|
|
|
# [*enabled*]
|
|
|
|
# (optional) The state of the service
|
|
|
|
# Defaults to true
|
|
|
|
#
|
2014-01-15 22:52:03 -06:00
|
|
|
# [*manage_service*]
|
|
|
|
# (optional) Whether to start/stop the service
|
|
|
|
# Defaults to true
|
|
|
|
#
|
2013-05-06 14:15:29 -06:00
|
|
|
# [*log_file*]
|
2014-02-25 18:43:55 +01:00
|
|
|
# REMOVED: Use log_file of neutron class instead.
|
2013-05-21 15:36:16 -05:00
|
|
|
#
|
|
|
|
# [*log_dir*]
|
2014-02-25 18:43:55 +01:00
|
|
|
# REMOVED: Use log_dir of neutron class instead.
|
2013-05-06 14:15:29 -06:00
|
|
|
#
|
|
|
|
# [*auth_password*]
|
|
|
|
# (optional) The password to use for authentication (keystone)
|
|
|
|
# Defaults to false. Set a value unless you are using noauth
|
|
|
|
#
|
|
|
|
# [*auth_type*]
|
|
|
|
# (optional) What auth system to use
|
|
|
|
# Defaults to 'keystone'. Can other be 'noauth'
|
|
|
|
#
|
|
|
|
# [*auth_host*]
|
|
|
|
# (optional) The keystone host
|
|
|
|
# Defaults to localhost
|
|
|
|
#
|
|
|
|
# [*auth_protocol*]
|
|
|
|
# (optional) The protocol used to access the auth host
|
|
|
|
# Defaults to http.
|
|
|
|
#
|
|
|
|
# [*auth_port*]
|
|
|
|
# (optional) The keystone auth port
|
|
|
|
# Defaults to 35357
|
|
|
|
#
|
2013-05-15 09:14:19 +02:00
|
|
|
# [*auth_admin_prefix*]
|
|
|
|
# (optional) The admin_prefix used to admin endpoint of the auth host
|
|
|
|
# This allow admin auth URIs like http://auth_host:35357/keystone.
|
|
|
|
# (where '/keystone' is the admin prefix)
|
|
|
|
# Defaults to false for empty. If defined, should be a string with a leading '/' and no trailing '/'.
|
|
|
|
#
|
2013-05-06 14:15:29 -06:00
|
|
|
# [*auth_tenant*]
|
|
|
|
# (optional) The tenant of the auth user
|
|
|
|
# Defaults to services
|
|
|
|
#
|
|
|
|
# [*auth_user*]
|
|
|
|
# (optional) The name of the auth user
|
2013-08-05 13:20:54 -04:00
|
|
|
# Defaults to neutron
|
2013-05-06 14:15:29 -06:00
|
|
|
#
|
|
|
|
# [*auth_protocol*]
|
|
|
|
# (optional) The protocol to connect to keystone
|
|
|
|
# Defaults to http
|
|
|
|
#
|
2013-08-29 09:52:51 -04:00
|
|
|
# [*auth_uri*]
|
|
|
|
# (optional) Complete public Identity API endpoint.
|
|
|
|
# Defaults to: $auth_protocol://$auth_host:5000/
|
|
|
|
#
|
2014-01-28 13:23:13 -05:00
|
|
|
# [*database_connection*]
|
2013-10-31 17:33:36 +00:00
|
|
|
# (optional) Connection url for the neutron database.
|
2014-01-28 13:23:13 -05:00
|
|
|
# (Defaults to 'sqlite:////var/lib/neutron/ovs.sqlite')
|
|
|
|
#
|
|
|
|
# [*sql_connection*]
|
|
|
|
# DEPRECATED: Use database_connection instead.
|
|
|
|
#
|
|
|
|
# [*connection*]
|
|
|
|
# DEPRECATED: Use database_connection instead.
|
|
|
|
#
|
|
|
|
# [*database_max_retries*]
|
|
|
|
# (optional) Maximum database connection retries during startup.
|
|
|
|
# (Defaults to 10)
|
|
|
|
#
|
|
|
|
# [*sql_max_retries*]
|
|
|
|
# DEPRECATED: Use database_max_retries instead.
|
2013-10-31 17:33:36 +00:00
|
|
|
#
|
|
|
|
# [*max_retries*]
|
2014-01-28 13:23:13 -05:00
|
|
|
# DEPRECATED: Use database_max_retries instead.
|
2013-10-31 17:33:36 +00:00
|
|
|
#
|
2014-01-28 13:23:13 -05:00
|
|
|
# [*database_idle_timeout*]
|
|
|
|
# (optional) Timeout before idle database connections are reaped.
|
2013-10-31 17:33:36 +00:00
|
|
|
# Deprecates sql_idle_timeout
|
2014-01-28 13:23:13 -05:00
|
|
|
# (Defaults to 3600)
|
|
|
|
#
|
|
|
|
# [*sql_idle_timeout*]
|
|
|
|
# DEPRECATED: Use database_idle_timeout instead.
|
|
|
|
#
|
|
|
|
# [*idle_timeout*]
|
|
|
|
# DEPRECATED: Use database_idle_timeout instead.
|
|
|
|
#
|
|
|
|
# [*database_retry_interval*]
|
|
|
|
# (optional) Interval between retries of opening a database connection.
|
|
|
|
# (Defaults to 10)
|
|
|
|
#
|
|
|
|
# [*sql_reconnect_interval*]
|
|
|
|
# DEPRECATED: Use database_retry_interval instead.
|
2013-10-31 17:33:36 +00:00
|
|
|
#
|
|
|
|
# [*retry_interval*]
|
2014-01-28 13:23:13 -05:00
|
|
|
# DEPRECATED: Use database_retry_interval instead.
|
2013-10-31 17:33:36 +00:00
|
|
|
#
|
2014-02-03 13:28:03 +01:00
|
|
|
# [*sync_db*]
|
|
|
|
# (optional) Run neutron-db-manage on api nodes after installing the package.
|
2014-03-06 15:39:50 -05:00
|
|
|
# Defaults to false
|
2014-02-03 13:28:03 +01:00
|
|
|
#
|
2013-11-30 16:16:17 +01:00
|
|
|
# [*api_workers*]
|
|
|
|
# (optional) Number of separate worker processes to spawn.
|
|
|
|
# The default, 0, runs the worker thread in the current process.
|
|
|
|
# Greater than 0 launches that number of child processes as workers.
|
|
|
|
# The parent process manages them.
|
|
|
|
# Defaults to: 0
|
|
|
|
#
|
2013-12-24 20:13:55 +01:00
|
|
|
# [*agent_down_time*]
|
|
|
|
# (optional) Seconds to regard the agent as down; should be at least twice
|
|
|
|
# report_interval, to be sure the agent is down for good.
|
2014-04-09 16:37:20 +02:00
|
|
|
# agent_down_time is a config for neutron-server, set by class neutron::server
|
|
|
|
# report_interval is a config for neutron agents, set by class neutron
|
2014-03-23 14:56:56 +01:00
|
|
|
# Defaults to: 75
|
2013-12-24 20:13:55 +01:00
|
|
|
#
|
2013-12-25 00:46:23 +01:00
|
|
|
# [*router_scheduler_driver*]
|
|
|
|
# (optional) Driver to use for scheduling router to a default L3 agent. Could be:
|
|
|
|
# neutron.scheduler.l3_agent_scheduler.ChanceScheduler to schedule a router in a random way
|
|
|
|
# neutron.scheduler.l3_agent_scheduler.LeastRoutersScheduler to allocate on an L3 agent with the least number of routers bound.
|
|
|
|
# Defaults to: neutron.scheduler.l3_agent_scheduler.ChanceScheduler
|
|
|
|
#
|
2014-02-18 13:28:47 +11:00
|
|
|
# [*mysql_module*]
|
|
|
|
# (optional) Mysql puppet module version to use. Tested versions
|
|
|
|
# include 0.9 and 2.2
|
2014-07-16 18:43:48 +05:30
|
|
|
# Defaults to: '2.2'
|
2014-02-18 13:28:47 +11:00
|
|
|
#
|
2013-08-05 13:20:54 -04:00
|
|
|
class neutron::server (
|
2013-12-25 00:46:23 +01:00
|
|
|
$package_ensure = 'present',
|
|
|
|
$enabled = true,
|
2014-01-15 22:52:03 -06:00
|
|
|
$manage_service = true,
|
2013-12-25 00:46:23 +01:00
|
|
|
$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,
|
2014-01-28 13:23:13 -05:00
|
|
|
$database_connection = 'sqlite:////var/lib/neutron/ovs.sqlite',
|
|
|
|
$database_max_retries = 10,
|
|
|
|
$database_idle_timeout = 3600,
|
|
|
|
$database_retry_interval = 10,
|
2014-03-06 15:39:50 -05:00
|
|
|
$sync_db = false,
|
2013-12-25 00:46:23 +01:00
|
|
|
$api_workers = '0',
|
2014-03-23 14:56:56 +01:00
|
|
|
$agent_down_time = '75',
|
2014-01-28 13:23:13 -05:00
|
|
|
$router_scheduler_driver = 'neutron.scheduler.l3_agent_scheduler.ChanceScheduler',
|
2014-07-16 18:43:48 +05:30
|
|
|
$mysql_module = '2.2',
|
2014-01-28 13:23:13 -05:00
|
|
|
# DEPRECATED PARAMETERS
|
|
|
|
$sql_connection = undef,
|
|
|
|
$connection = undef,
|
|
|
|
$sql_max_retries = undef,
|
|
|
|
$max_retries = undef,
|
|
|
|
$sql_idle_timeout = undef,
|
|
|
|
$idle_timeout = undef,
|
|
|
|
$sql_reconnect_interval = undef,
|
|
|
|
$retry_interval = undef,
|
2014-02-25 18:43:55 +01:00
|
|
|
$log_dir = undef,
|
|
|
|
$log_file = undef,
|
2014-04-09 16:37:20 +02:00
|
|
|
$report_interval = undef,
|
2012-10-21 00:34:24 +02:00
|
|
|
) {
|
|
|
|
|
2013-08-05 13:20:54 -04:00
|
|
|
include neutron::params
|
2013-05-06 14:15:29 -06:00
|
|
|
require keystone::python
|
2012-10-09 10:21:36 +02:00
|
|
|
|
2014-07-16 16:34:06 -07:00
|
|
|
Nova_admin_tenant_id_setter<||> ~> Service['neutron-server']
|
2013-08-05 13:20:54 -04:00
|
|
|
Neutron_config<||> ~> Service['neutron-server']
|
|
|
|
Neutron_api_config<||> ~> Service['neutron-server']
|
2012-10-09 10:21:36 +02:00
|
|
|
|
2013-10-31 17:33:36 +00:00
|
|
|
if $sql_connection {
|
2014-01-28 13:23:13 -05:00
|
|
|
warning('The sql_connection parameter is deprecated, use database_connection instead.')
|
|
|
|
$database_connection_real = $sql_connection
|
|
|
|
} elsif $connection {
|
|
|
|
warning('The connection parameter is deprecated, use database_connection instead.')
|
|
|
|
$database_connection_real = $connection
|
2013-10-31 17:33:36 +00:00
|
|
|
} else {
|
2014-01-28 13:23:13 -05:00
|
|
|
$database_connection_real = $database_connection
|
2013-10-31 17:33:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if $sql_max_retries {
|
2014-01-28 13:23:13 -05:00
|
|
|
warning('The sql_max_retries parameter is deprecated, use database_max_retries instead.')
|
|
|
|
$database_max_retries_real = $sql_max_retries
|
2014-04-02 17:04:45 -05:00
|
|
|
} elsif $max_retries {
|
2014-01-28 13:23:13 -05:00
|
|
|
warning('The max_retries parameter is deprecated, use database_max_retries instead.')
|
|
|
|
$database_max_retries_real = $max_retries
|
2013-10-31 17:33:36 +00:00
|
|
|
} else {
|
2014-01-28 13:23:13 -05:00
|
|
|
$database_max_retries_real = $database_max_retries
|
2013-10-31 17:33:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if $sql_idle_timeout {
|
2014-01-28 13:23:13 -05:00
|
|
|
warning('The sql_idle_timeout parameter is deprecated, use database_idle_timeout instead.')
|
|
|
|
$database_idle_timeout_real = $sql_idle_timeout
|
|
|
|
} elsif $idle_timeout {
|
|
|
|
warning('The dle_timeout parameter is deprecated, use database_idle_timeout instead.')
|
|
|
|
$database_idle_timeout_real = $idle_timeout
|
2013-10-31 17:33:36 +00:00
|
|
|
} else {
|
2014-01-28 13:23:13 -05:00
|
|
|
$database_idle_timeout_real = $database_idle_timeout
|
2013-10-31 17:33:36 +00:00
|
|
|
}
|
|
|
|
|
2014-01-28 13:23:13 -05:00
|
|
|
if $sql_reconnect_interval {
|
|
|
|
warning('The sql_reconnect_interval parameter is deprecated, use database_retry_interval instead.')
|
|
|
|
$database_retry_interval_real = $sql_reconnect_interval
|
|
|
|
} elsif $retry_interval {
|
|
|
|
warning('The retry_interval parameter is deprecated, use database_retry_interval instead.')
|
|
|
|
$database_retry_interval_real = $retry_interval
|
2013-10-31 17:33:36 +00:00
|
|
|
} else {
|
2014-01-28 13:23:13 -05:00
|
|
|
$database_retry_interval_real = $database_retry_interval
|
2013-10-31 17:33:36 +00:00
|
|
|
}
|
|
|
|
|
2014-02-25 18:43:55 +01:00
|
|
|
if $log_dir {
|
|
|
|
fail('The log_dir parameter is removed, use log_dir of neutron class instead.')
|
|
|
|
}
|
|
|
|
|
|
|
|
if $log_file {
|
|
|
|
fail('The log_file parameter is removed, use log_file of neutron class instead.')
|
|
|
|
}
|
|
|
|
|
2014-04-09 16:37:20 +02:00
|
|
|
if $report_interval {
|
|
|
|
fail('The report_interval is removed, use report_interval of neutron class instead.')
|
|
|
|
}
|
|
|
|
|
2014-01-28 13:23:13 -05:00
|
|
|
validate_re($database_connection_real, '(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
|
2013-10-31 17:33:36 +00:00
|
|
|
|
2014-01-28 13:23:13 -05:00
|
|
|
case $database_connection_real {
|
2013-10-31 17:33:36 +00:00
|
|
|
/mysql:\/\/\S+:\S+@\S+\/\S+/: {
|
2014-02-18 13:28:47 +11:00
|
|
|
if ($mysql_module >= 2.2) {
|
|
|
|
require 'mysql::bindings'
|
|
|
|
require 'mysql::bindings::python'
|
|
|
|
} else {
|
|
|
|
require 'mysql::python'
|
|
|
|
}
|
2013-10-31 17:33:36 +00:00
|
|
|
}
|
|
|
|
/postgresql:\/\/\S+:\S+@\S+\/\S+/: {
|
|
|
|
$backend_package = 'python-psycopg2'
|
|
|
|
}
|
|
|
|
/sqlite:\/\//: {
|
|
|
|
$backend_package = 'python-pysqlite2'
|
|
|
|
}
|
|
|
|
default: {
|
2014-01-28 13:23:13 -05:00
|
|
|
fail("Invalid database_connection parameter: ${database_connection_real}")
|
2013-10-31 17:33:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-03 13:28:03 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-31 17:33:36 +00:00
|
|
|
neutron_config {
|
2013-12-25 00:46:23 +01:00
|
|
|
'DEFAULT/api_workers': value => $api_workers;
|
|
|
|
'DEFAULT/agent_down_time': value => $agent_down_time;
|
|
|
|
'DEFAULT/router_scheduler_driver': value => $router_scheduler_driver;
|
2014-07-12 02:28:55 +02:00
|
|
|
'database/connection': value => $database_connection_real, secret => true;
|
2014-01-28 13:23:13 -05:00
|
|
|
'database/idle_timeout': value => $database_idle_timeout_real;
|
|
|
|
'database/retry_interval': value => $database_retry_interval_real;
|
|
|
|
'database/max_retries': value => $database_max_retries_real;
|
2013-10-31 17:33:36 +00:00
|
|
|
}
|
|
|
|
|
2013-08-05 13:20:54 -04:00
|
|
|
if ($::neutron::params::server_package) {
|
|
|
|
Package['neutron-server'] -> Neutron_api_config<||>
|
|
|
|
Package['neutron-server'] -> Neutron_config<||>
|
|
|
|
Package['neutron-server'] -> Service['neutron-server']
|
|
|
|
package { 'neutron-server':
|
2013-08-09 16:35:19 +00:00
|
|
|
ensure => $package_ensure,
|
2013-08-05 13:20:54 -04:00
|
|
|
name => $::neutron::params::server_package,
|
2013-04-19 11:08:22 -07:00
|
|
|
}
|
2013-05-19 00:42:56 -04:00
|
|
|
} else {
|
2013-08-05 13:20:54 -04:00
|
|
|
# Some platforms (RedHat) does not provide a neutron-server package.
|
|
|
|
# The neutron api config file is provided by the neutron package.
|
|
|
|
Package['neutron'] -> Neutron_api_config<||>
|
2012-10-09 10:21:36 +02:00
|
|
|
}
|
|
|
|
|
2013-05-06 14:15:29 -06:00
|
|
|
if ($auth_type == 'keystone') {
|
|
|
|
|
|
|
|
if ($auth_password == false) {
|
|
|
|
fail('$auth_password must be set when using keystone authentication.')
|
|
|
|
} else {
|
2013-08-05 13:20:54 -04:00
|
|
|
neutron_config {
|
2013-05-06 14:15:29 -06:00
|
|
|
'keystone_authtoken/auth_host': value => $auth_host;
|
|
|
|
'keystone_authtoken/auth_port': value => $auth_port;
|
|
|
|
'keystone_authtoken/auth_protocol': value => $auth_protocol;
|
2013-05-10 00:07:46 -04:00
|
|
|
'keystone_authtoken/admin_tenant_name': value => $auth_tenant;
|
2013-05-06 14:15:29 -06:00
|
|
|
'keystone_authtoken/admin_user': value => $auth_user;
|
2014-07-12 02:28:55 +02:00
|
|
|
'keystone_authtoken/admin_password': value => $auth_password, secret => true;
|
2013-05-06 14:15:29 -06:00
|
|
|
}
|
|
|
|
|
2013-08-05 13:20:54 -04:00
|
|
|
neutron_api_config {
|
2013-05-06 14:15:29 -06:00
|
|
|
'filter:authtoken/auth_host': value => $auth_host;
|
|
|
|
'filter:authtoken/auth_port': value => $auth_port;
|
|
|
|
'filter:authtoken/auth_protocol': value => $auth_protocol;
|
|
|
|
'filter:authtoken/admin_tenant_name': value => $auth_tenant;
|
|
|
|
'filter:authtoken/admin_user': value => $auth_user;
|
2014-07-12 02:28:55 +02:00
|
|
|
'filter:authtoken/admin_password': value => $auth_password, secret => true;
|
2013-05-06 14:15:29 -06:00
|
|
|
}
|
2013-05-15 09:14:19 +02:00
|
|
|
|
|
|
|
if $auth_admin_prefix {
|
|
|
|
validate_re($auth_admin_prefix, '^(/.+[^/])?$')
|
2013-08-05 13:20:54 -04:00
|
|
|
neutron_config {
|
2013-05-15 09:14:19 +02:00
|
|
|
'keystone_authtoken/auth_admin_prefix': value => $auth_admin_prefix;
|
|
|
|
}
|
2013-08-05 13:20:54 -04:00
|
|
|
neutron_api_config {
|
2013-05-15 09:14:19 +02:00
|
|
|
'filter:authtoken/auth_admin_prefix': value => $auth_admin_prefix;
|
|
|
|
}
|
|
|
|
} else {
|
2013-08-05 13:20:54 -04:00
|
|
|
neutron_config {
|
2013-05-15 09:14:19 +02:00
|
|
|
'keystone_authtoken/auth_admin_prefix': ensure => absent;
|
|
|
|
}
|
2013-08-05 13:20:54 -04:00
|
|
|
neutron_api_config {
|
2013-05-15 09:14:19 +02:00
|
|
|
'filter:authtoken/auth_admin_prefix': ensure => absent;
|
|
|
|
}
|
|
|
|
}
|
2013-08-29 09:52:51 -04:00
|
|
|
|
|
|
|
if $auth_uri {
|
|
|
|
neutron_config {
|
|
|
|
'keystone_authtoken/auth_uri': value => $auth_uri;
|
|
|
|
}
|
|
|
|
neutron_api_config {
|
|
|
|
'filter:authtoken/auth_uri': value => $auth_uri;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
neutron_config {
|
|
|
|
'keystone_authtoken/auth_uri': value => "${auth_protocol}://${auth_host}:5000/";
|
|
|
|
}
|
|
|
|
neutron_api_config {
|
|
|
|
'filter:authtoken/auth_uri': value => "${auth_protocol}://${auth_host}:5000/";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-06 14:15:29 -06:00
|
|
|
}
|
2013-05-15 09:14:19 +02:00
|
|
|
|
2013-05-06 14:15:29 -06:00
|
|
|
}
|
|
|
|
|
2014-01-15 22:52:03 -06:00
|
|
|
if $manage_service {
|
|
|
|
if $enabled {
|
|
|
|
$service_ensure = 'running'
|
|
|
|
} else {
|
|
|
|
$service_ensure = 'stopped'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-05 13:20:54 -04:00
|
|
|
service { 'neutron-server':
|
2012-10-09 10:21:36 +02:00
|
|
|
ensure => $service_ensure,
|
2013-08-09 16:35:19 +00:00
|
|
|
name => $::neutron::params::server_service,
|
2012-10-09 10:21:36 +02:00
|
|
|
enable => $enabled,
|
|
|
|
hasstatus => true,
|
2013-05-19 00:42:56 -04:00
|
|
|
hasrestart => true,
|
2013-08-05 13:20:54 -04:00
|
|
|
require => Class['neutron'],
|
2012-10-09 10:21:36 +02:00
|
|
|
}
|
|
|
|
}
|