From cfb6df121774b6e39dc93391369b72e5c88dca25 Mon Sep 17 00:00:00 2001 From: Zhongyue Luo Date: Mon, 29 Oct 2012 09:43:43 +0800 Subject: Clean up quantumv2.get_client Makes the get_client function more readable Change-Id: I90a1e529308d0f52d1315e57cc412b40426d50a6 --- nova/network/quantumv2/__init__.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/nova/network/quantumv2/__init__.py b/nova/network/quantumv2/__init__.py index af114a80c..9070a1f3e 100644 --- a/nova/network/quantumv2/__init__.py +++ b/nova/network/quantumv2/__init__.py @@ -1,3 +1,5 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 +# # Copyright 2012 OpenStack LLC. # All Rights Reserved # @@ -12,8 +14,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -# -# vim: tabstop=4 shiftwidth=4 softtabstop=4 from nova import exception from nova import flags @@ -44,15 +44,14 @@ def _get_auth_token(): def get_client(context): token = context.auth_token - if not token: - if FLAGS.quantum_auth_strategy: - token = _get_auth_token() + if not token and FLAGS.quantum_auth_strategy: + token = _get_auth_token() + params = { + 'endpoint_url': FLAGS.quantum_url, + 'timeout': FLAGS.quantum_url_timeout, + } if token: - my_client = clientv20.Client( - endpoint_url=FLAGS.quantum_url, - token=token, timeout=FLAGS.quantum_url_timeout) + params['token'] = token else: - my_client = clientv20.Client( - endpoint_url=FLAGS.quantum_url, - auth_strategy=None, timeout=FLAGS.quantum_url_timeout) - return my_client + params['auth_strategy'] = None + return clientv20.Client(**params) -- cgit