diff options
author | Radoslav Gerganov <rgerganov@vmware.com> | 2018-08-07 12:26:34 +0300 |
---|---|---|
committer | Radoslav Gerganov <rgerganov@vmware.com> | 2018-08-07 15:43:36 +0300 |
commit | 44396c93b451cd09c64285c470e5f628a91af868 (patch) | |
tree | 5fee5be4d410498c175a0fd46a375a22240b686c /oslo_vmware/api.py | |
parent | a2bcf80fbcfa4f78ea8de9df97649c5b51a166ab (diff) | |
download | oslo-vmware-44396c93b451cd09c64285c470e5f628a91af868.tar.gz |
Set request context when polling vCenter tasks
There are various useful log messages which come when polling vCenter
tasks which are missing request context and thus are hard to correlate
to API requests.
This patch fixes this by passing the request context to the async
jobs which poll the vCenter tasks.
Change-Id: I8efbc343e5073d3deb18b5f87c378c271ea4d816
Diffstat (limited to 'oslo_vmware/api.py')
-rw-r--r-- | oslo_vmware/api.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/oslo_vmware/api.py b/oslo_vmware/api.py index 4224a96..a86ecef 100644 --- a/oslo_vmware/api.py +++ b/oslo_vmware/api.py @@ -24,6 +24,7 @@ in case of connection problems or server API call overload. import logging from oslo_concurrency import lockutils +from oslo_context import context from oslo_utils import excutils from oslo_utils import reflection import six @@ -390,12 +391,13 @@ class VMwareAPISession(object): :raises: VimException, VimFaultException, VimAttributeException, VimSessionOverLoadException, VimConnectionException """ - loop = loopingcall.FixedIntervalLoopingCall(self._poll_task, task) + ctx = context.get_current() + loop = loopingcall.FixedIntervalLoopingCall(self._poll_task, task, ctx) evt = loop.start(self._task_poll_interval) LOG.debug("Waiting for the task: %s to complete.", task) return evt.wait() - def _poll_task(self, task): + def _poll_task(self, task, ctx): """Poll the given task until completion. If the task completes successfully, the method returns the task info @@ -403,7 +405,9 @@ class VMwareAPISession(object): exception is set in the event. :param task: managed object reference of the task + :param ctx: request context for the corresponding task """ + ctx.update_store() try: # we poll tasks too often, so skip logging the opID as it generates # too much noise in the logs |