def SmartConnect(protocol='https', host='localhost', port=443, user='******', pwd='', service="hostd", path="/sdk", preferredApiVersions=None): """ Determine the most preferred API version supported by the specified server, then connect to the specified server using that API version, login and return the service instance object. Throws any exception back to caller. The service instance object is also saved in the library for easy access. Clients should modify the service parameter only when connecting to a VMOMI server other than hostd/vpxd. For both of the latter, the default value is fine. @param protocol: What protocol to use for the connection (e.g. https or http). @type protocol: string @param host: Which host to connect to. @type host: string @param port: Port @type port: int @param user: User @type user: string @param pwd: Password @type pwd: string @param service: Service @type service: string @param path: Path @type path: string @param preferredApiVersions: Acceptable API version(s) (e.g. vim.version.version3) If a list of versions is specified the versions should be ordered from most to least preferred. If None is specified, the list of versions support by pyVmomi will be used. @type preferredApiVersions: string or string list """ if preferredApiVersions is None: preferredApiVersions = GetServiceVersions('vim25') supportedVersion = __FindSupportedVersion(protocol, host, port, path, preferredApiVersions) if supportedVersion is None: raise Exception("%s:%s is not a VIM server" % (host, port)) portNumber = protocol == "http" and -int(port) or int(port) return Connect(host=host, port=portNumber, user=user, pwd=pwd, service=service, adapter='SOAP', version=supportedVersion, path=path)
def SmartStubAdapter(host='localhost', port=443, path='/sdk', url=None, sock=None, poolSize=5, certFile=None, certKeyFile=None, httpProxyHost=None, httpProxyPort=80, sslProxyPath=None, thumbprint=None, cacertsFile=None, preferredApiVersions=None, acceptCompressedResponses=True, connectionPoolTimeout=CONNECTION_POOL_IDLE_TIMEOUT_SEC, samlToken=None, sslContext=None): """ Determine the most preferred API version supported by the specified server, then create a soap stub adapter using that version The parameters are the same as for pyVmomi.SoapStubAdapter except for version which is renamed to prefferedApiVersions @param preferredApiVersions: Acceptable API version(s) (e.g. vim.version.version3) If a list of versions is specified the versions should be ordered from most to least preferred. If None is specified, the list of versions support by pyVmomi will be used. @type preferredApiVersions: string or string list """ if preferredApiVersions is None: preferredApiVersions = GetServiceVersions('vim25') supportedVersion = __FindSupportedVersion('https' if port > 0 else 'http', host, port, path, preferredApiVersions, sslContext) if supportedVersion is None: raise Exception("%s:%s is not a VIM server" % (host, port)) return SoapStubAdapter(host=host, port=port, path=path, url=url, sock=sock, poolSize=poolSize, certFile=certFile, certKeyFile=certKeyFile, httpProxyHost=httpProxyHost, httpProxyPort=httpProxyPort, sslProxyPath=sslProxyPath, thumbprint=thumbprint, cacertsFile=cacertsFile, version=supportedVersion, acceptCompressedResponses=acceptCompressedResponses, connectionPoolTimeout=connectionPoolTimeout, samlToken=samlToken, sslContext=sslContext)
def SmartConnect(protocol='https', host='localhost', port=443, user='******', pwd='', service="hostd", path="/sdk", connectionPoolTimeout=CONNECTION_POOL_IDLE_TIMEOUT_SEC, preferredApiVersions=None, keyFile=None, certFile=None, thumbprint=None, sslContext=None, b64token=None, mechanism='userpass'): """ Determine the most preferred API version supported by the specified server, then connect to the specified server using that API version, login and return the service instance object. Throws any exception back to caller. The service instance object is also saved in the library for easy access. Clients should modify the service parameter only when connecting to a VMOMI server other than hostd/vpxd. For both of the latter, the default value is fine. @param protocol: What protocol to use for the connection (e.g. https or http). @type protocol: string @param host: Which host to connect to. @type host: string @param port: Port @type port: int @param user: User @type user: string @param pwd: Password @type pwd: string @param service: Service @type service: string @param path: Path @type path: string @param connectionPoolTimeout: Timeout in secs for idle connections to close, specify negative numbers for never closing the connections @type connectionPoolTimeout: int @param preferredApiVersions: Acceptable API version(s) (e.g. vim.version.version3) If a list of versions is specified the versions should be ordered from most to least preferred. If None is specified, the list of versions support by pyVmomi will be used. @type preferredApiVersions: string or string list @param keyFile: ssl key file path @type keyFile: string @param certFile: ssl cert file path @type certFile: string @param thumbprint: host cert thumbprint @type thumbprint: string @param sslContext: SSL Context describing the various SSL options. It is only supported in Python 2.7.9 or higher. @type sslContext: SSL.Context """ if preferredApiVersions is None: preferredApiVersions = GetServiceVersions('vim25') sslContext = localSslFixup(host, sslContext) supportedVersion = __FindSupportedVersion(protocol, host, port, path, preferredApiVersions, sslContext) if supportedVersion is None: raise Exception("%s:%s is not a VIM server" % (host, port)) portNumber = protocol == "http" and -int(port) or int(port) return Connect(host=host, port=portNumber, user=user, pwd=pwd, service=service, adapter='SOAP', version=supportedVersion, path=path, connectionPoolTimeout=connectionPoolTimeout, keyFile=keyFile, certFile=certFile, thumbprint=thumbprint, sslContext=sslContext, b64token=b64token, mechanism=mechanism)