From 977414d0583f8e191a5e2bc5065d89f57ea95724 Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Wed, 8 Mar 2017 10:50:42 +0800 Subject: [PATCH] Drop "os" prefix for project id Keystone session now returns project id without "os" prefix. We should drop it as well. Closes-bug: #1668830 Change-Id: I4ad9d0696c362723c4de7f7283105ba6f396fa96 Co-Authored-By: XueFeng Liu --- releasenotes/notes/remove_os_prefix-14fc4a97527dee81.yaml | 5 +++++ zaqarclient/transport/request.py | 5 ++++- zaqarclient/transport/ws.py | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/remove_os_prefix-14fc4a97527dee81.yaml diff --git a/releasenotes/notes/remove_os_prefix-14fc4a97527dee81.yaml b/releasenotes/notes/remove_os_prefix-14fc4a97527dee81.yaml new file mode 100644 index 00000000..09907477 --- /dev/null +++ b/releasenotes/notes/remove_os_prefix-14fc4a97527dee81.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - The "os" prefix for project id has been dropped to keep the same with + OpenStack and Keystone Client. To keep the backwards compatibility, the "os" + prefix still can be used. And it'll be removed in the next release. diff --git a/zaqarclient/transport/request.py b/zaqarclient/transport/request.py index 8a9821a2..7bf07f79 100644 --- a/zaqarclient/transport/request.py +++ b/zaqarclient/transport/request.py @@ -45,7 +45,10 @@ def prepare_request(auth_opts=None, data=None, **kwargs): auth_backend = auth.get_backend(**(auth_opts or {})) req = auth_backend.authenticate(kwargs.get('api'), req) - project_id = auth_opts.get('options', {}).get('os_project_id', {}) + option = auth_opts.get('options', {}) + # TODO(wangxiyuan): To keep backwards compatibility, we leave + # "os_project_id" here. Remove it in the next release. + project_id = option.get('os_project_id', option.get('project_id')) # Let's add project id header, only if it will have non-empty value. if project_id: diff --git a/zaqarclient/transport/ws.py b/zaqarclient/transport/ws.py index ab22d1ef..8af6e07b 100644 --- a/zaqarclient/transport/ws.py +++ b/zaqarclient/transport/ws.py @@ -57,7 +57,11 @@ class WebsocketTransport(base.Transport): """ def __init__(self, options): super(WebsocketTransport, self).__init__(options) - self._project_id = options['auth_opts']['options']['os_project_id'] + option = options['auth_opts']['options'] + # TODO(wangxiyuan): To keep backwards compatibility, we leave + # "os_project_id" here. Remove it in the next release. + self._project_id = option.get('os_project_id', + option.get('project_id')) self._token = options['auth_opts']['options']['os_auth_token'] self._websocket_client_id = None self._ws = None