Adding connection retries for keystone adapter

Due to fact that the same state cinder are run on the
all control nodes and this state means restarting of
apache therefore raise condition occurs and as a consequence
BadStatus lines errors is raised whiting keystone connection. So
in order to avoid this connect_retries is set to make keystone client
reconnect to the server.

Related-PROD: PROD-19729

https://github.com/openstack/keystoneauth/blob/master/keystoneauth1/adapter.py#L45

Change-Id: I8ba2de1197d07b9c11994f3c7e89223430fcbc8f
diff --git a/_modules/cinderng.py b/_modules/cinderng.py
index 08aaad9..4d75116 100644
--- a/_modules/cinderng.py
+++ b/_modules/cinderng.py
@@ -1,5 +1,6 @@
 # -*- coding: utf-8 -*-
 import logging
+import time
 
 LOG = logging.getLogger(__name__)
 
@@ -45,6 +46,22 @@
     }
     return credentials
 
+def retries(func):
+    def func_wrapper(*args, **kwargs):
+        retries = kwargs.get('retries', 3)
+        timeout = kwargs.get('timeout', 5)
+        res = None
+        for i in range(retries):
+            try:
+                res = func(*args, **kwargs)
+            except Exception as e:
+                if i == retries - 1:
+                    raise e
+                    time.sleep(timeout)
+                else:
+                    break
+        return res
+    return func_wrapper
 
 def create_conn(cred=None):
     """
@@ -63,7 +80,7 @@
     )
     return nt
 
-
+@retries
 def list_volumes(profile=None, **kwargs):
     """
     Return list of cinder volumes.
@@ -72,7 +89,7 @@
     nt = create_conn(cred)
     return nt.volumes.list()
 
-
+@retries
 def list_volume_type(profile=None, **kwargs):
     """
     Return list of volume types
@@ -81,7 +98,7 @@
     nt = create_conn(cred)
     return nt.volume_types.list()
 
-
+@retries
 def get_volume_type(type_name, profile=None, **kwargs):
     """
     Returns id of the specified volume type name
@@ -103,7 +120,7 @@
     else:
         return
 
-
+@retries
 def create_volume_type(type_name, profile=None, **kwargs):
     """
     Create cinder volume type
@@ -120,7 +137,7 @@
     else:
         return 'exists'
 
-
+@retries
 def get_keys_volume_type(type_name, profile=None, **kwargs):
     """
     Return extra specs of the specified volume type.
@@ -135,7 +152,7 @@
     else:
         return
 
-
+@retries
 def set_keys_volume_type(type_name, keys={}, profile=None, **kwargs):
     """
     Set extra specs of the specified volume type.