From 844a5f5376cf3f58a8bebf15e133a7047d7ba7ec Mon Sep 17 00:00:00 2001 From: Md Nadeem Date: Wed, 11 Nov 2015 15:10:38 +0900 Subject: [PATCH] Attaching a default project_id Zaqar client threw below exception for noauth backend. MalformedRequest: The header X-PROJECT-ID was missing This patch will add a default project_id in request header for noauth authentication backend. Closes-Bug: #1494154 Change-Id: I2e56654846a41ea136e4c06cd1daf697683aed46 --- zaqarclient/transport/request.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/zaqarclient/transport/request.py b/zaqarclient/transport/request.py index c19ec800..32d7a799 100644 --- a/zaqarclient/transport/request.py +++ b/zaqarclient/transport/request.py @@ -46,8 +46,13 @@ def prepare_request(auth_opts=None, data=None, **kwargs): # TODO(flaper87): Do something smarter # to get the api_version. req = auth_backend.authenticate(1, req) - req.headers['X-Project-Id'] = auth_opts.get('options', - {}).get('os_project_id') + req.headers['X-Project-Id'] = auth_opts.get( + 'options', {}).get('os_project_id', {}) + + # In case of noauth backend, a default project id will be added to header. + if (not req.headers['X-Project-Id'] and + auth_opts.get("backend") == "noauth"): + req.headers['X-Project-Id'] = "fake_project_id_for_noauth" if data is not None: req.content = json.dumps(data)