a8c575a095cf80249c3178504873455e7c668802
[mirror/dsa-puppet.git] / 3rdparty / modules / cinder / manifests / backup.pp
1 #
2 # Copyright (C) 2013 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: cinder::backup
19 #
20 # Setup Cinder backup service
21 #
22 # === Parameters
23 #
24 # [*backup_topic*]
25 #   (optional) The topic volume backup nodes listen on.
26 #   Defaults to 'cinder-backup'
27 #
28 # [*backup_manager*]
29 #   (optional) Full class name for the Manager for volume backup.
30 #   Defaults to 'cinder.backup.manager.BackupManager'
31 #
32 # [*backup_api_class*]
33 #   (optional) The full class name of the volume backup API class.
34 #   Defaults to 'cinder.backup.api.API'
35 #
36 # [*backup_name_template*]
37 #   (optional) Template string to be used to generate backup names.
38 #   Defaults to 'backup-%s'
39 #
40
41 class cinder::backup (
42   $enabled              = true,
43   $package_ensure       = 'present',
44   $backup_topic         = 'cinder-backup',
45   $backup_manager       = 'cinder.backup.manager.BackupManager',
46   $backup_api_class     = 'cinder.backup.api.API',
47   $backup_name_template = 'backup-%s'
48 ) {
49
50   include cinder::params
51
52   Cinder_config<||> ~> Service['cinder-backup']
53
54   if $::cinder::params::backup_package {
55     Package['cinder-backup'] -> Cinder_config<||>
56     Package['cinder-backup'] -> Service['cinder-backup']
57     package { 'cinder-backup':
58       ensure => $package_ensure,
59       name   => $::cinder::params::backup_package,
60     }
61   }
62
63   if $enabled {
64     $ensure = 'running'
65   } else {
66     $ensure = 'stopped'
67   }
68
69   service { 'cinder-backup':
70     ensure    => $ensure,
71     name      => $::cinder::params::backup_service,
72     enable    => $enabled,
73     hasstatus => true,
74     require   => Package['cinder'],
75   }
76
77   cinder_config {
78     'DEFAULT/backup_topic':         value => $backup_topic;
79     'DEFAULT/backup_manager':       value => $backup_manager;
80     'DEFAULT/backup_api_class':     value => $backup_api_class;
81     'DEFAULT/backup_name_template': value => $backup_name_template;
82   }
83
84 }