From a7c47a053944ae750cd841400b9fbb2aef4ff326 Mon Sep 17 00:00:00 2001
From: Vladislav Belogrudov <vladislav.belogrudov@oracle.com>
Date: Tue, 18 Apr 2017 13:15:02 +0300
Subject: [PATCH] Allow use of any backup backend for any volume backend

Currently if Ceph is used for Cinder volumes the only choice of
backup driver is Ceph. It should be possible to use any backup
driver for any volume type, e.g. iSCSI volumes can go to Ceph
based backup storage.

Change-Id: Ifc8a767b9030391580de6a24383bb6b87053835d
Closes-Bug: #1683715
---
 ansible/roles/cinder/templates/cinder.conf.j2 | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/ansible/roles/cinder/templates/cinder.conf.j2 b/ansible/roles/cinder/templates/cinder.conf.j2
index 224677fd5c..cccbb0ca41 100644
--- a/ansible/roles/cinder/templates/cinder.conf.j2
+++ b/ansible/roles/cinder/templates/cinder.conf.j2
@@ -21,7 +21,8 @@ os_region_name = {{ openstack_region_name }}
 enabled_backends = {{ cinder_enabled_backends|map(attribute='name')|join(',') }}
 {% endif %}
 
-{% if service_name == "cinder-backup" and enable_ceph | bool and cinder_backend_ceph | bool %}
+{% if service_name == "cinder-backup" %}
+{% if enable_ceph | bool and cinder_backup_driver == "ceph" %}
 backup_driver = cinder.backup.drivers.ceph
 backup_ceph_conf = /etc/ceph/ceph.conf
 backup_ceph_user = cinder-backup
@@ -30,13 +31,13 @@ backup_ceph_pool = {{ ceph_cinder_backup_pool_name }}
 backup_ceph_stripe_unit = 0
 backup_ceph_stripe_count = 0
 restore_discard_excess_bytes = true
-{% elif cinder_backup_driver == "nfs"%}
+{% elif cinder_backup_driver == "nfs" %}
 backup_driver = cinder.backup.drivers.nfs
 backup_mount_options = {{ cinder_backup_mount_options_nfs }}
 backup_mount_point_base = /var/lib/cinder/backup
 backup_share = {{ cinder_backup_share }}
 backup_file_size = 327680000
-{% elif cinder_backup_driver == "swift"%}
+{% elif enable_swift | bool and cinder_backup_driver == "swift" %}
 backup_driver = cinder.backup.drivers.swift
 backup_swift_url = http://{{ kolla_internal_vip_address }}:{{ swift_proxy_server_port }}/v1/AUTH_
 backup_swift_auth = per_user
@@ -44,6 +45,7 @@ backup_swift_auth_version = 1
 backup_swift_user =
 backup_swift_key =
 {% endif %}
+{% endif %}
 
 osapi_volume_listen = {{ api_interface_address }}
 osapi_volume_listen_port = {{ cinder_api_port }}