From a17e07a511f6bd8a674c12e1c7f6cff2f318c326 Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Tue, 1 Dec 2015 18:39:56 +1100 Subject: [PATCH] Cleanups to K2K plugin Refactor parts of the K2K plugin. Use the plugins model a bit more effectively and make it easier to read. Change-Id: I0f315cb2845a8cf1489a34f3490f6983dac3155d --- keystoneauth1/identity/v3/k2k.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/keystoneauth1/identity/v3/k2k.py b/keystoneauth1/identity/v3/k2k.py index d04c15c7..64e4da07 100644 --- a/keystoneauth1/identity/v3/k2k.py +++ b/keystoneauth1/identity/v3/k2k.py @@ -74,14 +74,13 @@ class Keystone2Keystone(federation._Rescoped): idx = auth_url.index(PATTERN) if PATTERN in auth_url else len(auth_url) return auth_url[:idx] - def _ecp_assertion_request(self, session): - token_id = self._local_cloud_plugin.get_access(session).auth_token + def _get_ecp_assertion(self, session): body = { 'auth': { 'identity': { 'methods': ['token'], 'token': { - 'id': token_id + 'id': self._local_cloud_plugin.get_token(session) } }, 'scope': { @@ -92,14 +91,17 @@ class Keystone2Keystone(federation._Rescoped): } } - return body + endpoint_filter = {'version': (3, 0), + 'interface': plugin.AUTH_INTERFACE} - def _get_ecp_assertion(self, session): - url = self._local_cloud_plugin.get_endpoint( - session, interface=plugin.AUTH_INTERFACE, version=(3, 0)) - body = self._ecp_assertion_request(session) + headers = {'Accept': 'application/json'} - resp = session.post(url=url + self.REQUEST_ECP_URL, json=body, + resp = session.post(self.REQUEST_ECP_URL, + json=body, + auth=self._local_cloud_plugin, + endpoint_filter=endpoint_filter, + headers=headers, + authenticated=False, raise_exc=False) # NOTE(marek-denis): I am not sure whether disabling exceptions in the