summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryufei <zhangyf@rc.inesa.com>2018-01-25 17:32:55 +0800
committeryufei <zhangyf@rc.inesa.com>2018-01-25 17:36:23 +0800
commitdd7567d50aac1b6b070cc13d6f77036eb22d0c24 (patch)
tree5aa3d623ca3cb44ffbdf1548ce7dd74822fa508a
parent1a0ee0e7d0a56cd22b82a52b4ae207f493c5344d (diff)
remove re-auth logic for ironic client
We are using keystone session to build ironic client now, keystone session support to re-auth for expired token, so we don't need to re-auth again in client wrapper. This logic is removed from nova in Ifbb6e19d4e2811ebaafc4e5899e46b13b4520f62. Change-Id: Id319a01c8745b466aaf77b9087ffb2f3fd1e5533
Notes
Notes (review): Code-Review+2: Zhenguo Niu <Niu.ZGlinux@gmail.com> Code-Review+2: ShaoHe Feng <shaohe.feng@intel.com> Workflow+1: ShaoHe Feng <shaohe.feng@intel.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 05 Feb 2018 10:15:52 +0000 Reviewed-on: https://review.openstack.org/537812 Project: openstack/mogan Branch: refs/heads/master
-rw-r--r--mogan/common/ironic.py27
1 files changed, 5 insertions, 22 deletions
diff --git a/mogan/common/ironic.py b/mogan/common/ironic.py
index 6c4705f..20cb5b7 100644
--- a/mogan/common/ironic.py
+++ b/mogan/common/ironic.py
@@ -37,10 +37,6 @@ class IronicClientWrapper(object):
37 """Initialise the IronicClientWrapper for use.""" 37 """Initialise the IronicClientWrapper for use."""
38 self._cached_client = None 38 self._cached_client = None
39 39
40 def _invalidate_cached_client(self):
41 """Tell the wrapper to invalidate the cached ironic-client."""
42 self._cached_client = None
43
44 def _get_auth_plugin(self): 40 def _get_auth_plugin(self):
45 """Load an auth plugin from CONF options.""" 41 """Load an auth plugin from CONF options."""
46 # If an auth plugin name is defined in `auth_type` option of [ironic] 42 # If an auth plugin name is defined in `auth_type` option of [ironic]
@@ -115,21 +111,8 @@ class IronicClientWrapper(object):
115 """ 111 """
116 retry_on_conflict = kwargs.pop('retry_on_conflict', True) 112 retry_on_conflict = kwargs.pop('retry_on_conflict', True)
117 113
118 # NOTE(dtantsur): allow for authentication retry, other retries are 114 # authentication retry for token expiration is handled in keystone
119 # handled by ironicclient starting with 0.8.0 115 # session, other retries are handled by ironicclient starting with
120 for attempt in range(2): 116 # 0.8.0
121 client = self._get_client(retry_on_conflict=retry_on_conflict) 117 client = self._get_client(retry_on_conflict=retry_on_conflict)
122 118 return self._multi_getattr(client, method)(*args, **kwargs)
123 try:
124 return self._multi_getattr(client, method)(*args, **kwargs)
125 except ironic_exc.Unauthorized:
126 # In this case, the authorization token of the cached
127 # ironic-client probably expired. So invalidate the cached
128 # client and the next try will start with a fresh one.
129 if not attempt:
130 self._invalidate_cached_client()
131 LOG.debug("The Ironic client became unauthorized. "
132 "Will attempt to reauthorize and try again.")
133 else:
134 # This code should be unreachable actually
135 raise