Add error handling for user login (#32613)

This fix adds additional error handling for vmware connect
method, where username provided user does not have required
permissions to use/login ESXi.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/32698/merge
Abhijeet Kasurde 7 years ago committed by Jordan Borean
parent 8e081b7e30
commit 80967380d3

@ -414,6 +414,9 @@ def connect_to_api(module, disconnect_atexit=True):
service_instance = connect.SmartConnect(host=hostname, user=username, pwd=password, sslContext=ssl_context)
except vim.fault.InvalidLogin as e:
module.fail_json(msg="Unable to log on to vCenter or ESXi API at %s as %s: %s" % (hostname, username, e.msg))
except vim.fault.NoPermission as e:
module.fail_json(msg="User %s does not have required permission"
" to log on to vCenter or ESXi API at %s: %s" % (username, hostname, e.msg))
except (requests.ConnectionError, ssl.SSLError) as e:
module.fail_json(msg="Unable to connect to vCenter or ESXi API at %s on TCP/443: %s" % (hostname, e))
except Exception as e:

Loading…
Cancel
Save