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
|
|
|
|
#
|
|
|
|
# [*log_file*]
|
|
|
|
# (optional) Where to log
|
2013-05-21 15:36:16 -05:00
|
|
|
#
|
|
|
|
# [*log_dir*]
|
|
|
|
# (optional) Directory to store logs
|
2013-08-05 13:20:54 -04:00
|
|
|
# Defaults to /var/log/neutron
|
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/
|
|
|
|
#
|
2013-10-31 17:33:36 +00:00
|
|
|
# [*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
|
|
|
|
#
|
2013-08-05 13:20:54 -04:00
|
|
|
class neutron::server (
|
2013-10-31 17:33:36 +00:00
|
|
|
$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'
|
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
|
|
|
|
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 {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-05-21 15:36:16 -05:00
|
|
|
if $log_file {
|
2013-08-05 13:20:54 -04:00
|
|
|
neutron_config {
|
2013-05-21 15:36:16 -05:00
|
|
|
'DEFAULT/log_file': value => $log_file;
|
|
|
|
'DEFAULT/log_dir': ensure => absent;
|
|
|
|
}
|
|
|
|
} else {
|
2013-08-05 13:20:54 -04:00
|
|
|
neutron_config {
|
2013-05-21 15:36:16 -05:00
|
|
|
'DEFAULT/log_dir': value => $log_dir;
|
|
|
|
'DEFAULT/log_file': ensure => absent;
|
|
|
|
}
|
2012-10-09 10:21:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if $enabled {
|
2012-10-21 00:34:24 +02:00
|
|
|
$service_ensure = 'running'
|
2012-10-09 10:21:36 +02:00
|
|
|
} else {
|
2012-10-21 00:34:24 +02:00
|
|
|
$service_ensure = 'stopped'
|
2012-10-09 10:21:36 +02: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;
|
2013-05-10 22:40:23 +02:00
|
|
|
'keystone_authtoken/admin_password': value => $auth_password;
|
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;
|
2013-05-10 22:40:23 +02:00
|
|
|
'filter:authtoken/admin_password': value => $auth_password;
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|