From 571e5d8c4d089b8082782c13ec83861b7e59364c Mon Sep 17 00:00:00 2001 From: Eric Fried Date: Thu, 28 Sep 2017 15:00:57 -0500 Subject: [PATCH] Let keystoneauth set the microversion header Constructing the Adapter with the default_microversion kwarg causes the Adapter to handle setting the appropriate Openstack-API-Version header. With this change set, SessionClient now uses the api_version kwarg to set default_microversion instead of setting the header explicitly. Change-Id: I5de721fa373f5d3adb42ddb4b5598f19aabfff3b --- cinderclient/client.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cinderclient/client.py b/cinderclient/client.py index 10761f63d..9f6febec7 100644 --- a/cinderclient/client.py +++ b/cinderclient/client.py @@ -154,15 +154,16 @@ def _log_request_id(logger, resp, service_name): class SessionClient(adapter.LegacyJsonAdapter): def __init__(self, *args, **kwargs): - self.api_version = kwargs.pop('api_version', None) - self.api_version = self.api_version or api_versions.APIVersion() + apiver = kwargs.pop('api_version', None) or api_versions.APIVersion() + if not isinstance(apiver, api_versions.APIVersion): + apiver = api_versions.APIVersion(str(apiver)) + if apiver.ver_minor != 0: + kwargs['default_microversion'] = apiver.get_string() self.retries = kwargs.pop('retries', 0) self._logger = logging.getLogger(__name__) super(SessionClient, self).__init__(*args, **kwargs) def request(self, *args, **kwargs): - kwargs.setdefault('headers', kwargs.get('headers', {})) - api_versions.update_headers(kwargs["headers"], self.api_version) kwargs.setdefault('authenticated', False) # Note(tpatil): The standard call raises errors from