From 6c71469783e0953bf186fef54a9595e46abbd249 Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Tue, 18 Oct 2016 11:20:51 +1100 Subject: [PATCH] Show deprecation warning and limit features for KSC session There are still a lot of places where keystoneclient sessions are being used and we've made a fair effort to maintain compatibility with these sessions. Unfortunately passing client_name and client_version for user_agent generation is something only present in keystoneauth and passing it to a keystoneclient session results in failure. Whilst it would be good to just tell people to fix their code in reality we'll probably be dealing with this for a while so just check to ensure it really is a keystoneauth session we are passing parameters to and warn otherwise. Change-Id: I4d51ee08cfa9094443aca7128fe5323a95974a4d --- keystoneauth1/adapter.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/keystoneauth1/adapter.py b/keystoneauth1/adapter.py index 21497920..0275abf1 100644 --- a/keystoneauth1/adapter.py +++ b/keystoneauth1/adapter.py @@ -11,9 +11,12 @@ # under the License. import os +import warnings from positional import positional +from keystoneauth1 import session + class Adapter(object): """An instance of a session with local variables. @@ -113,10 +116,18 @@ class Adapter(object): kwargs.setdefault('logger', self.logger) if self.allow: kwargs.setdefault('allow', self.allow) - if self.client_name: - kwargs.setdefault('client_name', self.client_name) - if self.client_version: - kwargs.setdefault('client_version', self.client_version) + + if isinstance(self.session, session.Session): + # these things are unsupported by keystoneclient's session so be + # careful with them until everyone has transitioned to ksa. + if self.client_name: + kwargs.setdefault('client_name', self.client_name) + if self.client_version: + kwargs.setdefault('client_version', self.client_version) + + else: + warnings.warn('Using keystoneclient sessions has been deprecated. ' + 'Please update your software to use keystoneauth1.') for k, v in self.additional_headers.items(): kwargs.setdefault('headers', {}).setdefault(k, v)