diff options
author | Giridhar Jayavelu <gjayavelu@vmware.com> | 2016-08-01 14:20:49 -0700 |
---|---|---|
committer | Giridhar Jayavelu <gjayavelu@vmware.com> | 2016-08-18 11:54:17 -0700 |
commit | 41267a595eb7648d6eecf85d90d694aaee6c7d29 (patch) | |
tree | 662272ec07d7b16b97d07ed40c15d6ac3e4ab75b /oslo_vmware/api.py | |
parent | 37283c8689238fe0bcd038267893fc7d002d1383 (diff) | |
download | oslo-vmware-41267a595eb7648d6eecf85d90d694aaee6c7d29.tar.gz |
Improve logging for task updates
This patch would print the task name while waiting
for tasks to complete and also update total duration
in seconds on successful completion.
Change-Id: Ia1448cc9baf1cf7abc7d4b14e27e90c86af5583c
Diffstat (limited to 'oslo_vmware/api.py')
-rw-r--r-- | oslo_vmware/api.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/oslo_vmware/api.py b/oslo_vmware/api.py index aaeb77b..323462b 100644 --- a/oslo_vmware/api.py +++ b/oslo_vmware/api.py @@ -408,13 +408,25 @@ class VMwareAPISession(object): "task: %s."), task) else: + task_detail = {'id': task.value} + # some internal tasks do not have 'name' set + if getattr(task_info, 'name', None): + task_detail['name'] = task_info.name + if task_info.state in ['queued', 'running']: if hasattr(task_info, 'progress'): LOG.debug("Task: %(task)s progress is %(progress)s%%.", - {'task': task, + {'task': task_detail, 'progress': task_info.progress}) elif task_info.state == 'success': - LOG.debug("Task: %s status is success.", task) + def get_completed_task(): + complete_time = getattr(task_info, 'completeTime', None) + if complete_time: + duration = complete_time - task_info.queueTime + task_detail['duration_secs'] = duration.total_seconds() + return task_detail + LOG.debug("Task: %s completed successfully.", + get_completed_task()) raise loopingcall.LoopingCallDone(task_info) else: error_msg = six.text_type(task_info.error.localizedMessage) |