Logging neutron request-id in NSX

To simplify debugging neutron transaction in NSX, add neutron's
request id to NSX manager log files.

Change-Id: I894575160b3b86bd063220e46b8e298582268a25
This commit is contained in:
Kobi Samoray 2017-10-19 11:36:09 +03:00 committed by garyk
parent a56e11d3ac
commit bf0b8ef7e8
2 changed files with 10 additions and 0 deletions

View File

@ -15,6 +15,7 @@ neutron-lib>=1.10.0 # Apache-2.0
osc-lib>=1.7.0 # Apache-2.0
python-openstackclient>=3.12.0 # Apache-2.0
oslo.concurrency>=3.20.0 # Apache-2.0
oslo.context!=2.19.1,>=2.14.0 # Apache-2.0
oslo.config>=4.6.0 # Apache-2.0
oslo.db>=4.27.0 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0

View File

@ -15,6 +15,7 @@
import base64
import xml.etree.ElementTree as et
from oslo_context import context as context_utils
from oslo_serialization import jsonutils
import requests
import six
@ -118,6 +119,11 @@ class VcnsApiHelper(object):
# We won't assume that integer error-code value is guaranteed.
return None
def _get_request_id(self):
ctx = context_utils.get_current()
if ctx:
return ctx.__dict__.get('request_id')
def request(self, method, uri, params=None, headers=None,
encodeparams=True):
uri = self.address + uri
@ -127,6 +133,9 @@ class VcnsApiHelper(object):
headers['Accept'] = 'application/' + self.format
headers['Authorization'] = 'Basic ' + self.authToken.strip()
headers['Content-Type'] = 'application/' + self.format
request_id = self._get_request_id()
if request_id:
headers['TicketNumber'] = request_id
if params:
if encodeparams is True: