added support for cinder-backup service

Change-Id: I0817ca69777490c9ee9a1bb14c3b2f6fcffb90a2
diff --git a/README.rst b/README.rst
index a8b174e..7e02a05 100644
--- a/README.rst
+++ b/README.rst
@@ -96,6 +96,7 @@
             pool: SAS7K2
         audit:
           enabled: false
+    
 
 Client-side RabbitMQ HA setup for controller
 
@@ -408,8 +409,36 @@
             clustername: cluster1
             sf_emulate_512: false
 
+Enable cinder-backup service for ceph
 
+.. code-block:: yaml
 
+    cinder:
+      controller:
+        enabled: true
+        version: mitaka
+        backup:
+          engine: ceph
+          ceph_conf: "/etc/ceph/ceph.conf"
+          ceph_pool: backup
+          ceph_stripe_count: 0
+          ceph_stripe_unit: 0
+          ceph_user: cinder
+          ceph_chunk_size: 134217728
+          restore_discard_excess_bytes: false
+      volume:
+        enabled: true
+        version: mitaka
+        backup:
+          engine: ceph
+          ceph_conf: "/etc/ceph/ceph.conf"
+          ceph_pool: backup
+          ceph_stripe_count: 0
+          ceph_stripe_unit: 0
+          ceph_user: cinder
+          ceph_chunk_size: 134217728
+          restore_discard_excess_bytes: false
+          
 Enable auditing filter, ie: CADF
 
 .. code-block:: yaml
diff --git a/cinder/controller.sls b/cinder/controller.sls
index 805d0a5..a50a3ca 100644
--- a/cinder/controller.sls
+++ b/cinder/controller.sls
@@ -142,4 +142,20 @@
 
 {% endfor %}
 
+{%- if controller.backup.engine != None %}
+
+cinder_backup_packages:
+  pkg.installed:
+  - names: {{ controller.backup.pkgs }}
+
+cinder_backup_services:
+  service.running:
+  - names: {{ controller.backup.services }}
+  - enable: true
+  - watch:
+    - file: /etc/cinder/cinder.conf
+    - file: /etc/cinder/api-paste.ini
+
+{%- endif %}
+
 {%- endif %}
\ No newline at end of file
diff --git a/cinder/files/backup_backend/_ceph.conf b/cinder/files/backup_backend/_ceph.conf
new file mode 100644
index 0000000..34a7465
--- /dev/null
+++ b/cinder/files/backup_backend/_ceph.conf
@@ -0,0 +1,8 @@
+#backup conf
+backup_driver=cinder.backup.drivers.{{ controller.backup.engine }}
+backup_ceph_conf={{ controller.backup.get('ceph_conf', '/etc/ceph/ceph.conf') }}
+backup_ceph_user = {{ controller.backup.get('ceph_user', cinder) }}
+backup_ceph_chunk_size = {{ controller.backup.get('ceph_chunk_size', 134217728 )}}
+backup_ceph_pool = {{ controller.backup.get('ceph_pool', backup) }}
+backup_ceph_stripe_unit = {{ controller.backup.get('ceph_stripe_unit', 0) }}
+backup_ceph_stripe_count = {{ controller.backup.get('ceph_stripe_count', 0) }}
\ No newline at end of file
diff --git a/cinder/files/mitaka/cinder.conf.controller.Debian b/cinder/files/mitaka/cinder.conf.controller.Debian
index 5aea59b..d58a006 100644
--- a/cinder/files/mitaka/cinder.conf.controller.Debian
+++ b/cinder/files/mitaka/cinder.conf.controller.Debian
@@ -82,6 +82,11 @@
 query_volume_filters = {{ controller.query_volume_filters|join(",") }}
 {%- endif %}
 
+{%- if controller.backup.engine != None %}
+{%- set backup_backend_fragment = "cinder/files/backup_backend/_" + controller.backup.engine + ".conf" %}
+{%- include backup_backend_fragment %}
+{%- endif %}
+
 [oslo_messaging_notifications]
 {%- if controller.notification is mapping %}
 driver = {{ controller.notification.get('driver', 'messagingv2') }}
diff --git a/cinder/files/mitaka/cinder.conf.volume.Debian b/cinder/files/mitaka/cinder.conf.volume.Debian
index beb8008..f3633e6 100644
--- a/cinder/files/mitaka/cinder.conf.volume.Debian
+++ b/cinder/files/mitaka/cinder.conf.volume.Debian
@@ -75,6 +75,11 @@
 use_syslog=false
 verbose=True
 
+{%- if volume.backup.engine != None %}
+{%- set backup_backend_fragment = "cinder/files/backup_backend/_" + volume.backup.engine + ".conf" %}
+{%- include backup_backend_fragment %}
+{%- endif %}
+
 [oslo_messaging_notifications]
 {%- if volume.notification is mapping %}
 driver = {{ volume.notification.get('driver', 'messagingv2') }}
diff --git a/cinder/files/newton/cinder.conf.controller.Debian b/cinder/files/newton/cinder.conf.controller.Debian
index c94d662..550f3c3 100644
--- a/cinder/files/newton/cinder.conf.controller.Debian
+++ b/cinder/files/newton/cinder.conf.controller.Debian
@@ -105,6 +105,11 @@
 transport_url = rabbit://{{ controller.message_queue.user }}:{{ controller.message_queue.password }}@{{ controller.message_queue.host }}:{{ controller.message_queue.port }}/{{ controller.message_queue.virtual_host }}
 {%- endif %}
 
+{%- if controller.backup.engine != None %}
+{%- set backup_backend_fragment = "cinder/files/backup_backend/_" + controller.backup.engine + ".conf" %}
+{%- include backup_backend_fragment %}
+{%- endif %}
+
 [oslo_messaging_notifications]
 {%- if controller.notification is mapping %}
 driver = {{ controller.notification.get('driver', 'messagingv2') }}
diff --git a/cinder/files/newton/cinder.conf.volume.Debian b/cinder/files/newton/cinder.conf.volume.Debian
index 36423ed..1124056 100644
--- a/cinder/files/newton/cinder.conf.volume.Debian
+++ b/cinder/files/newton/cinder.conf.volume.Debian
@@ -95,6 +95,11 @@
 transport_url = rabbit://{{ volume.message_queue.user }}:{{ volume.message_queue.password }}@{{ volume.message_queue.host }}:{{ volume.message_queue.port }}/{{ volume.message_queue.virtual_host }}
 {%- endif %}
 
+{%- if volume.backup.engine != None %}
+{%- set backup_backend_fragment = "cinder/files/backup_backend/_" + volume.backup.engine + ".conf" %}
+{%- include backup_backend_fragment %}
+{%- endif %}
+
 [oslo_messaging_notifications]
 {%- if volume.notification is mapping %}
 driver = {{ volume.notification.get('driver', 'messagingv2') }}
diff --git a/cinder/files/ocata/cinder.conf.controller.Debian b/cinder/files/ocata/cinder.conf.controller.Debian
index c94d662..550f3c3 100644
--- a/cinder/files/ocata/cinder.conf.controller.Debian
+++ b/cinder/files/ocata/cinder.conf.controller.Debian
@@ -105,6 +105,11 @@
 transport_url = rabbit://{{ controller.message_queue.user }}:{{ controller.message_queue.password }}@{{ controller.message_queue.host }}:{{ controller.message_queue.port }}/{{ controller.message_queue.virtual_host }}
 {%- endif %}
 
+{%- if controller.backup.engine != None %}
+{%- set backup_backend_fragment = "cinder/files/backup_backend/_" + controller.backup.engine + ".conf" %}
+{%- include backup_backend_fragment %}
+{%- endif %}
+
 [oslo_messaging_notifications]
 {%- if controller.notification is mapping %}
 driver = {{ controller.notification.get('driver', 'messagingv2') }}
diff --git a/cinder/files/ocata/cinder.conf.volume.Debian b/cinder/files/ocata/cinder.conf.volume.Debian
index 36423ed..1124056 100644
--- a/cinder/files/ocata/cinder.conf.volume.Debian
+++ b/cinder/files/ocata/cinder.conf.volume.Debian
@@ -95,6 +95,11 @@
 transport_url = rabbit://{{ volume.message_queue.user }}:{{ volume.message_queue.password }}@{{ volume.message_queue.host }}:{{ volume.message_queue.port }}/{{ volume.message_queue.virtual_host }}
 {%- endif %}
 
+{%- if volume.backup.engine != None %}
+{%- set backup_backend_fragment = "cinder/files/backup_backend/_" + volume.backup.engine + ".conf" %}
+{%- include backup_backend_fragment %}
+{%- endif %}
+
 [oslo_messaging_notifications]
 {%- if volume.notification is mapping %}
 driver = {{ volume.notification.get('driver', 'messagingv2') }}
diff --git a/cinder/map.jinja b/cinder/map.jinja
index b11a90d..bc2b4c5 100644
--- a/cinder/map.jinja
+++ b/cinder/map.jinja
@@ -7,6 +7,11 @@
         'notification': False,
         'audit': {
           'enabled': false
+        },
+        'backup': {
+          'pkgs': ['cinder-backup'],
+          'services': ['cinder-backup'],
+          'engine': None
         }
     },
     'RedHat': {
@@ -16,7 +21,13 @@
         'notification': False,
         'audit': {
           'enabled': false
+        },
+        'backup': {
+          'pkgs': ['cinder-backup'],
+          'services': ['cinder-backup'],
+          'engine': None
         }
+
     },
 }, merge=pillar.cinder.get('controller', {})) %}
 
@@ -28,7 +39,13 @@
         'notification': False,
         'audit': {
           'enabled': false
+        },
+        'backup': {
+          'pkgs': ['cinder-backup'],
+          'services': ['cinder-backup'],
+          'engine': None
         }
+
     },
     'RedHat': {
         'pkgs': ['openstack-cinder', 'python-cinder', 'lvm2', 'sysfsutils', 'sg3_utils', 'device-mapper-multipath', 'device-mapper-multipath-libs', 'python-pycadf'],
@@ -37,6 +54,11 @@
         'notification': False,
         'audit': {
           'enabled': false
+        },
+        'backup': {
+          'pkgs': ['cinder-backup'],
+          'services': ['cinder-backup'],
+          'engine': None
         }
     },
 }, merge=pillar.cinder.get('volume', {})) %}
diff --git a/cinder/volume.sls b/cinder/volume.sls
index 762b665..b4bc0f8 100644
--- a/cinder/volume.sls
+++ b/cinder/volume.sls
@@ -36,6 +36,22 @@
   - require:
     - pkg: cinder_volume_packages
 
+{%- if volume.backup.engine != None %}
+
+cinder_backup_packages:
+  pkg.installed:
+  - names: {{ volume.backup.pkgs }}
+
+cinder_backup_services:
+  service.running:
+  - names: {{ volume.backup.services }}
+  - enable: true
+  - watch:
+    - file: /etc/cinder/cinder.conf
+    - file: /etc/cinder/api-paste.ini
+
+{%- endif %}
+
 {%- endif %}
 
 {%- if not grains.get('noservices', False) %}