2 # Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
19 # Configures the nova database.
23 # [*database_connection*]
24 # (optional) Connection url to connect to nova database.
27 # [*slave_connection*]
28 # (optional) Connection url to connect to nova slave database (read-only).
31 # [*database_idle_timeout*]
32 # (optional) Timeout before idle db connections are reaped.
36 $database_connection = undef,
37 $slave_connection = undef,
38 $database_idle_timeout = undef,
41 $database_connection_real = pick($database_connection, $::nova::database_connection, false)
42 $slave_connection_real = pick($slave_connection, $::nova::slave_connection, false)
43 $database_idle_timeout_real = pick($database_idle_timeout, $::nova::database_idle_timeout, false)
45 if $database_connection_real {
46 if($database_connection_real =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
47 require 'mysql::bindings'
48 require 'mysql::bindings::python'
49 } elsif($database_connection_real =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
51 } elsif($database_connection_real =~ /sqlite:\/\//) {
54 fail("Invalid db connection ${database_connection_real}")
57 'database/connection': value => $database_connection_real, secret => true;
58 'database/idle_timeout': value => $database_idle_timeout_real;
60 if $slave_connection_real {
62 'database/slave_connection': value => $slave_connection_real, secret => true;
66 'database/slave_connection': ensure => absent;