try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / nova / manifests / db.pp
1 #
2 # Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
3 #
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
5 #
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
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
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
16 # under the License.
17 #
18 # == Class: nova::db
19 # Configures the nova database.
20 #
21 # == Parameters
22 #
23 # [*database_connection*]
24 #   (optional) Connection url to connect to nova database.
25 #   Defaults to undef
26 #
27 # [*slave_connection*]
28 #   (optional) Connection url to connect to nova slave database (read-only).
29 #   Defaults to undef
30 #
31 # [*database_idle_timeout*]
32 #   (optional) Timeout before idle db connections are reaped.
33 #   Defaults to undef
34 #
35 class nova::db (
36   $database_connection   = undef,
37   $slave_connection      = undef,
38   $database_idle_timeout = undef,
39 ) {
40
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)
44
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+/) {
50
51     } elsif($database_connection_real =~ /sqlite:\/\//) {
52
53     } else {
54       fail("Invalid db connection ${database_connection_real}")
55     }
56     nova_config {
57       'database/connection':   value => $database_connection_real, secret => true;
58       'database/idle_timeout': value => $database_idle_timeout_real;
59     }
60     if $slave_connection_real {
61       nova_config {
62         'database/slave_connection': value => $slave_connection_real, secret => true;
63       }
64     } else {
65       nova_config {
66         'database/slave_connection': ensure => absent;
67       }
68     }
69   }
70
71 }