diff options
| author | Zhongyue Luo <zhongyue.nah@intel.com> | 2012-10-29 09:43:43 +0800 |
|---|---|---|
| committer | Zhongyue Luo <zhongyue.nah@intel.com> | 2012-10-29 09:52:48 +0800 |
| commit | cfb6df121774b6e39dc93391369b72e5c88dca25 (patch) | |
| tree | 8ad6e5e47c62aeb22fcad2ed6ed47a3d0392d55f | |
| parent | 580747edd6a7d5fb205bbfddba9eb6a338de1e25 (diff) | |
Clean up quantumv2.get_client
Makes the get_client function more readable
Change-Id: I90a1e529308d0f52d1315e57cc412b40426d50a6
| -rw-r--r-- | nova/network/quantumv2/__init__.py | 23 |
1 files 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) |
