def connect(host, username, password, port=<NUM_LIT>, verify=False, debug=False):
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)<EOL>if not verify:<EOL><INDENT>context.verify_mode = ssl.CERT_NONE<EOL>requests.packages.urllib3.disable_warnings()<EOL><DEDENT>try:<EOL><INDENT>si = SmartConnect(<EOL>host=host,<EOL>user=username,<EOL>pwd=password,<EOL>port=port,<EOL>sslContext=context<EOL>)<EOL>atexit.register(Disconnect, si)<EOL>return si.RetrieveContent()<EOL><DEDENT>except IOError as e:<EOL><INDENT>print('<STR_LIT>'.format(e.errno, e.strerror))<EOL><DEDENT>except vmodl.MethodFault as e:<EOL><INDENT>print('<STR_LIT>', file=sys.stderr)<EOL>raise ConnectionError('<STR_LIT>')<EOL>print('<STR_LIT>', e.msg, file=sys.stderr)<EOL>if debug:<EOL><INDENT>traceback.print_exc()<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>print('<STR_LIT>', str(e), file=sys.stderr)<EOL>if debug:<EOL><INDENT>traceback.print_exc()<EOL><DEDENT><DEDENT>
Connect to a vCenter via the API
:param host: Hostname or IP of the vCenter
:type host: str or unicode
:param username: Username
:type user: str or unicode
:param password: Password
:type user: str or unicode
:param port: Port on which the vCenter API is running (default: 443)
:type port: int
:param verify: Whether to verify SSL certs upon connection (default: False)
:type verify: bool
:param debug: Debug option (default: False)
:type debug: bool
:return: Content
:rtype: vim.ServiceInstanceContent