mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 21:30:22 -07:00
VMware: correct logic to pass ESXi SSL thumbprint (#47600)
Due to refactoring of task_error and wait_for_task method, SSL thumbprint was lost in error message. This fixes the retry mechanism of AddHost task. Fixes: #47563 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
524c5190b8
commit
e7c83d6aa9
2 changed files with 12 additions and 4 deletions
|
@ -32,7 +32,8 @@ from ansible.module_utils.basic import env_fallback
|
|||
|
||||
|
||||
class TaskError(Exception):
|
||||
pass
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(TaskError, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
def wait_for_task(task, max_backoff=64, timeout=3600):
|
||||
|
@ -56,12 +57,15 @@ def wait_for_task(task, max_backoff=64, timeout=3600):
|
|||
return True, task.info.result
|
||||
if task.info.state == vim.TaskInfo.State.error:
|
||||
error_msg = task.info.error
|
||||
host_thumbprint = None
|
||||
try:
|
||||
error_msg = error_msg.msg
|
||||
if hasattr(task.info.error, 'thumbprint'):
|
||||
host_thumbprint = task.info.error.thumbprint
|
||||
except AttributeError:
|
||||
pass
|
||||
finally:
|
||||
raise_from(TaskError(error_msg), task.info.error)
|
||||
raise_from(TaskError(error_msg, host_thumbprint), task.info.error)
|
||||
if task.info.state in [vim.TaskInfo.State.running, vim.TaskInfo.State.queued]:
|
||||
sleep_time = min(2 ** failure_counter + randint(1, 1000) / 1000, max_backoff)
|
||||
time.sleep(sleep_time)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue