Changed insecure to validate_certs, with a default to true from false (reversing behavior)

This commit is contained in:
Stewart Rutledge 2015-11-30 10:26:14 +01:00 committed by Matt Clay
parent 2f79e2c01c
commit 79b8a42354

View file

@ -50,11 +50,12 @@ options:
required: true required: true
default: null default: null
aliases: [] aliases: []
insecure: validate_certs:
description: description:
- Ignore SSL verification errors when connection to vcenter - Validate SSL certs.
required: false required: false
default: false default: yes
choices: ['yes', 'no']
guest: guest:
description: description:
- The virtual server name you wish to manage. - The virtual server name you wish to manage.
@ -1581,7 +1582,7 @@ def main():
cluster=dict(required=False, default=None, type='str'), cluster=dict(required=False, default=None, type='str'),
force=dict(required=False, type='bool', default=False), force=dict(required=False, type='bool', default=False),
esxi=dict(required=False, type='dict', default={}), esxi=dict(required=False, type='dict', default={}),
insecure=dict(required=False, type='bool', default=False), validate_certs=dict(required=False, type='bool', default=True),
power_on_after_clone=dict(required=False, type='bool', default=True) power_on_after_clone=dict(required=False, type='bool', default=True)
@ -1623,7 +1624,7 @@ def main():
from_template = module.params['from_template'] from_template = module.params['from_template']
snapshot_to_clone = module.params['snapshot_to_clone'] snapshot_to_clone = module.params['snapshot_to_clone']
power_on_after_clone = module.params['power_on_after_clone'] power_on_after_clone = module.params['power_on_after_clone']
insecure = module.params['insecure'] validate_certs = module.params['validate_certs']
# CONNECT TO THE SERVER # CONNECT TO THE SERVER
@ -1631,7 +1632,7 @@ def main():
try: try:
viserver.connect(vcenter_hostname, username, password) viserver.connect(vcenter_hostname, username, password)
except ssl.SSLError as sslerr: except ssl.SSLError as sslerr:
if '[SSL: CERTIFICATE_VERIFY_FAILED]' in sslerr.strerror and insecure: if '[SSL: CERTIFICATE_VERIFY_FAILED]' in sslerr.strerror and not validate_certs:
default_context = ssl._create_default_https_context default_context = ssl._create_default_https_context
ssl._create_default_https_context = ssl._create_unverified_context ssl._create_default_https_context = ssl._create_unverified_context
viserver.connect(vcenter_hostname, username, password) viserver.connect(vcenter_hostname, username, password)