Fix retries decorator, fix queens key_manager section
This patch fixes retries decorator in cinderng module.
Also fix rendering issues around barbican in config.
Change-Id: I8890ffd2eff124c5b0f38167e14292393561636b
diff --git a/_modules/cinderng.py b/_modules/cinderng.py
index d97c5cd..aaed6fd 100644
--- a/_modules/cinderng.py
+++ b/_modules/cinderng.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import logging
import time
+import functools
LOG = logging.getLogger(__name__)
@@ -47,20 +48,19 @@
return credentials
def retries(func):
+ @functools.wraps(func)
def func_wrapper(*args, **kwargs):
retries = kwargs.get('retries', 5)
timeout = kwargs.get('timeout', 5)
res = None
for i in range(retries):
try:
- res = func(*args, **kwargs)
+ return func(*args, **kwargs)
except Exception as e:
if i == retries - 1:
raise e
- time.sleep(timeout)
else:
- break
- return res
+ time.sleep(timeout)
return func_wrapper
def create_conn(cred=None):
diff --git a/cinder/files/queens/cinder.conf.controller.Debian b/cinder/files/queens/cinder.conf.controller.Debian
index 5aa41f3..2cad9f7 100644
--- a/cinder/files/queens/cinder.conf.controller.Debian
+++ b/cinder/files/queens/cinder.conf.controller.Debian
@@ -3247,8 +3247,19 @@
{%- set _data = controller.identity %}
[barbican]
{%- include "oslo_templates/files/queens/castellan/_barbican.conf" %}
+{%- endif %}
+
[key_manager]
+{%- if controller.get('key_manager', {}).backend is defined %}
+ {%- set key_backend = controller.key_manager.backend %}
+{%- elif controller.get('barbican', {}).get('enabled', False) %}
+ {%- set key_backend = 'barbican' %}
+{%- endif %}
+
+{%- set _data = {} %}
+{%- do _data.update(controller.identity) %}
+{%- do _data.update(controller.get('barbican', {})) %}
#
# From castellan.config
#
@@ -3257,10 +3268,11 @@
# Default is "barbican". Will support the values earlier set using
# [key_manager]/api_class for some time. (string value)
# Deprecated group/name - [key_manager]/api_class
-backend = {{ _data.backend }}
-
-{%- include "oslo_templates/files/queens/keystoneauth/_type_"+ _data.get('auth_type','password') +".conf" %}
+#backend = barbican
+{%- if key_backend is defined %}
+backend = {{ key_backend }}
{%- endif %}
+{%- include "oslo_templates/files/queens/keystoneauth/_type_"+ _data.get('auth_type','password') +".conf" %}
[keystone_authtoken]
{%- set _data = controller.get('identity', {}) %}
diff --git a/cinder/files/queens/cinder.conf.volume.Debian b/cinder/files/queens/cinder.conf.volume.Debian
index 4602e7e..b6c644b 100644
--- a/cinder/files/queens/cinder.conf.volume.Debian
+++ b/cinder/files/queens/cinder.conf.volume.Debian
@@ -3246,9 +3246,20 @@
{%- if volume.get('barbican', {}).get('enabled', False) %}
{%- set _data = volume.identity %}
[barbican]
-{%- include "oslo_templates/files/castellan/_barbican.conf" %}
+{%- include "oslo_templates/files/queens/castellan/_barbican.conf" %}
+{%- endif %}
+
[key_manager]
+{%- if volume.get('key_manager', {}).backend is defined %}
+ {%- set key_backend = volume.key_manager.backend %}
+{%- elif volume.get('barbican', {}).get('enabled', False) %}
+ {%- set key_backend = 'barbican' %}
+{%- endif %}
+
+{%- set _data = {} %}
+{%- do _data.update(volume.identity) %}
+{%- do _data.update(volume.get('barbican', {})) %}
#
# From castellan.config
#
@@ -3257,10 +3268,12 @@
# Default is "barbican". Will support the values earlier set using
# [key_manager]/api_class for some time. (string value)
# Deprecated group/name - [key_manager]/api_class
-backend = {{ _data.backend }}
-
-{%- include "oslo_templates/files/queens/keystoneauth/_type_"+ _data.get('auth_type','password') +".conf" %}
+#backend = barbican
+{%- if key_backend is defined %}
+backend = {{ key_backend }}
{%- endif %}
+{%- include "oslo_templates/files/queens/keystoneauth/_type_"+ _data.get('auth_type','password') +".conf" %}
+
[keystone_authtoken]
{%- set _data = volume.get('identity', {}) %}