summaryrefslogtreecommitdiff
path: root/novaclient/client.py
diff options
context:
space:
mode:
authorSean Dague <sean@dague.net>2017-05-25 14:30:59 -0400
committerSean Dague <sean@dague.net>2017-05-26 08:32:05 -0400
commitd25502cbe2749ed7042e427fe8d4a3678acf4550 (patch)
tree997c30a4d4b8a4643677cbe2e616fed08d905243 /novaclient/client.py
parent8f6c2169310f83753f15cc693e5900ea76a872df (diff)
downloadpython-novaclient-d25502cbe2749ed7042e427fe8d4a3678acf4550.tar.gz
Have python-novaclient support global_request_id
As part of the Boston Summit, support the global_request_id effort by making python-novaclient support passing global_request_id during construction. part of bp:oslo-middleware-request-id oslo spec I65de8261746b25d45e105394f4eeb95b9cb3bd42 Change-Id: Ife29b1856c0c278eab1708c3971fef14b9d77e2e
Diffstat (limited to 'novaclient/client.py')
-rw-r--r--novaclient/client.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/novaclient/client.py b/novaclient/client.py
index be2fad87..f65f194f 100644
--- a/novaclient/client.py
+++ b/novaclient/client.py
@@ -40,7 +40,7 @@ from novaclient import extension as ext
from novaclient.i18n import _
from novaclient import utils
-
+REQ_ID_HEADER = 'X-OpenStack-Request-ID'
# TODO(jichenjc): when an extension in contrib is moved to core extension,
# Add the name into the following list, then after last patch merged,
# remove the whole function
@@ -57,12 +57,16 @@ class SessionClient(adapter.LegacyJsonAdapter):
self.timings = kwargs.pop('timings', False)
self.api_version = kwargs.pop('api_version', None)
self.api_version = self.api_version or api_versions.APIVersion()
+ self.global_request_id = kwargs.pop('global_request_id', None)
super(SessionClient, self).__init__(*args, **kwargs)
def request(self, url, method, **kwargs):
kwargs.setdefault('headers', kwargs.get('headers', {}))
api_versions.update_headers(kwargs["headers"], self.api_version)
+ if self.global_request_id is not None:
+ kwargs['headers'].setdefault(REQ_ID_HEADER, self.global_request_id)
+
# NOTE(dbelova): osprofiler_web.get_trace_id_headers does not add any
# headers in case if osprofiler is not initialized.
if osprofiler_web: