Revert "Use auth_token_info to initialize heat_keystoneclient sessions"

It looks like this change has revealed an unrelated race with locking
during delete. While this issue is investigated then this change
needs to be reverted to fix the gate.

Related-Bug: #1306029

This reverts commit 535dd4e77e.

Change-Id: I06be473d7c6961e399c4fd6128f374d24b9b0510
This commit is contained in:
Steve Baker 2014-06-12 00:23:22 +00:00
parent 535dd4e77e
commit 09d023887b
2 changed files with 3 additions and 72 deletions

View File

@ -14,7 +14,6 @@
"""Keystone Client functionality for use by resources."""
from collections import namedtuple
import copy
import json
import uuid
@ -153,21 +152,6 @@ class KeystoneClientV3(object):
kwargs.update(self._service_admin_creds())
kwargs['trust_id'] = self.context.trust_id
kwargs.pop('project_name')
elif self.context.auth_token_info is not None:
# The auth_ref version must be set according to the token version
if 'access' in self.context.auth_token_info:
kwargs['auth_ref'] = copy.deepcopy(
self.context.auth_token_info['access'])
kwargs['auth_ref']['version'] = 'v2.0'
kwargs['auth_ref']['token']['id'] = self.context.auth_token
elif 'token' in self.context.auth_token_info:
kwargs['auth_ref'] = copy.deepcopy(
self.context.auth_token_info['token'])
kwargs['auth_ref']['version'] = 'v3'
kwargs['auth_ref']['auth_token'] = self.context.auth_token
else:
LOG.error("Unknown version in auth_token_info")
raise exception.AuthorizationFailure('Unknown token version')
elif self.context.auth_token is not None:
kwargs['token'] = self.context.auth_token
kwargs['project_id'] = self.context.tenant_id
@ -181,12 +165,7 @@ class KeystoneClientV3(object):
raise exception.AuthorizationFailure()
kwargs.update(self._ssl_options())
client = kc_v3.Client(**kwargs)
# If auth_ref has already be specified via auth_token_info, don't
# authenticate as we want to reuse, rather than request a new token
if 'auth_ref' not in kwargs:
client.authenticate()
client.authenticate()
# If we are authenticating with a trust set the context auth_token
# with the trust scoped token
if 'trust_id' in kwargs:

View File

@ -86,7 +86,7 @@ class KeystoneClientTest(HeatTestCase):
self.mock_admin_client.auth_ref.user_id = '1234'
def _stubs_v3(self, method='token', auth_ok=True, trust_scoped=True,
user_id='trustor_user_id', auth_ref=None):
user_id='trustor_user_id'):
if method == 'token':
kc_v3.Client(
@ -97,15 +97,6 @@ class KeystoneClientTest(HeatTestCase):
cert=None,
insecure=False,
key=None).AndReturn(self.mock_ks_v3_client)
elif method == 'auth_ref':
kc_v3.Client(
auth_ref=auth_ref,
auth_url='http://server.test:5000/v3',
endpoint='http://server.test:5000/v3',
cacert=None,
cert=None,
insecure=False,
key=None).AndReturn(self.mock_ks_v3_client)
elif method == 'password':
kc_v3.Client(
username='test_username',
@ -133,8 +124,7 @@ class KeystoneClientTest(HeatTestCase):
self.mock_ks_v3_client.auth_ref.trust_scoped = trust_scoped
self.mock_ks_v3_client.auth_ref.auth_token = 'atrusttoken'
if method != 'auth_ref':
self.mock_ks_v3_client.authenticate().AndReturn(auth_ok)
self.mock_ks_v3_client.authenticate().AndReturn(auth_ok)
def test_username_length(self):
"""Test that user names >64 characters are properly truncated."""
@ -397,44 +387,6 @@ class KeystoneClientTest(HeatTestCase):
heat_ks_client.client
self.assertIsNotNone(heat_ks_client._client)
def test_init_v3_token_auth_ref_v2(self):
"""Test creating the client, token v2 auth_ref."""
expected_auth_ref = {'token': {'id': 'ctx_token', 'expires': '123'},
'version': 'v2.0'}
self._stubs_v3(method='auth_ref', auth_ref=expected_auth_ref)
self.m.ReplayAll()
ctx = utils.dummy_context()
ctx.username = None
ctx.password = None
ctx.trust_id = None
ctx.auth_token = 'ctx_token'
ctx.auth_token_info = {'access': {'token': {'expires': '123'}}}
heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
heat_ks_client.client
self.assertIsNotNone(heat_ks_client._client)
def test_init_v3_token_auth_ref_v3(self):
"""Test creating the client, token v3 auth_ref."""
expected_auth_ref = {'auth_token': 'ctx_token',
'expires': '456', 'version': 'v3'}
self._stubs_v3(method='auth_ref', auth_ref=expected_auth_ref)
self.m.ReplayAll()
ctx = utils.dummy_context()
ctx.username = None
ctx.password = None
ctx.trust_id = None
ctx.auth_token = 'ctx_token'
ctx.auth_token_info = {'token': {'expires': '456'}}
heat_ks_client = heat_keystoneclient.KeystoneClient(ctx)
heat_ks_client.client
self.assertIsNotNone(heat_ks_client._client)
def test_init_v3_password(self):
"""Test creating the client, password auth."""