Fixed exception handling
* It need for handling exception in case when exception catched.
It is wrong return empty dictionary if exception catched.
Change-Id: I76d71cae5ada0384cbc44c8d4e6cc537c04f8f96
Related-PROD: PROD-29484
diff --git a/_modules/keystonev3/common.py b/_modules/keystonev3/common.py
index 9a7744b..6fdbf18 100644
--- a/_modules/keystonev3/common.py
+++ b/_modules/keystonev3/common.py
@@ -111,12 +111,14 @@
kwargs.pop(k)
url, json = func(*args, **kwargs)
response = None
+ last_exception = None
for i in range(connect_retries):
try:
response = getattr(adapter, method)(
url, connect_retries=connect_retries,
json=json)
except Exception as e:
+ last_exception = e
if not hasattr(e, 'http_status') or (e.http_status >= 500
or e.http_status == 0):
msg = ("Got retriable exception when contacting "
@@ -125,7 +127,13 @@
log.error(msg % (connect_retry_delay, i, connect_retries))
time.sleep(connect_retry_delay)
continue
- break
+ else:
+ break
+ else:
+ last_exception = None
+ break
+ if last_exception:
+ raise KeystoneException(last_exception.message)
if not response or not response.content:
return {}
try:
diff --git a/_states/keystonev3.py b/_states/keystonev3.py
index 6962290..bd79857 100644
--- a/_states/keystonev3.py
+++ b/_states/keystonev3.py
@@ -248,7 +248,7 @@
'user_create', name=name, cloud_name=cloud_name, **kwargs
)
except Exception as e:
- log.error('Keystone user create failed with {}'.format(e))
+ log.error('Keystone user create failed with: {}'.format(e))
return _create_failed(name, 'user')
return _created(name, 'user', resp)
diff --git a/keystone/client/resources/v3.sls b/keystone/client/resources/v3.sls
index 8f58f0c..8cac028 100644
--- a/keystone/client/resources/v3.sls
+++ b/keystone/client/resources/v3.sls
@@ -214,6 +214,8 @@
{%- if role.role_domain_id is defined %}
- role_domain_id: {{ role.role_domain_id }}
{%- endif %}
+ - require:
+ - keystone_user_{{ user_name }}
{%- elif role.get('status', 'assigned') == 'unassigned' %}