This function gets called when the proxy starts up. For
    login
    the protocol and port are cached.

def init(opts):
    '''
    This function gets called when the proxy starts up. For
    login
    the protocol and port are cached.
    '''
    log.debug('Initting esxcluster proxy module in process %s', os.getpid())
    log.debug('Validating esxcluster proxy input')
    schema = EsxclusterProxySchema.serialize()
    log.trace('schema = %s', schema)
    proxy_conf = merge(opts.get('proxy', {}), __pillar__.get('proxy', {}))
    log.trace('proxy_conf = %s', proxy_conf)
    try:
        jsonschema.validate(proxy_conf, schema)
    except jsonschema.exceptions.ValidationError as exc:
        raise salt.exceptions.InvalidConfigError(exc)

    # Save mandatory fields in cache
    for key in ('vcenter', 'datacenter', 'cluster', 'mechanism'):
        DETAILS[key] = proxy_conf[key]

    # Additional validation
    if DETAILS['mechanism'] == 'userpass':
        if 'username' not in proxy_conf:
            raise salt.exceptions.InvalidConfigError(
                'Mechanism is set to \'userpass\', but no '
                '\'username\' key found in proxy config.')
        if 'passwords' not in proxy_conf:
            raise salt.exceptions.InvalidConfigError(
                'Mechanism is set to \'userpass\', but no '
                '\'passwords\' key found in proxy config.')
        for key in ('username', 'passwords'):
            DETAILS[key] = proxy_conf[key]
    else:
        if 'domain' not in proxy_conf:
            raise salt.exceptions.InvalidConfigError(
                'Mechanism is set to \'sspi\', but no '
                '\'domain\' key found in proxy config.')
        if 'principal' not in proxy_conf:
            raise salt.exceptions.InvalidConfigError(
                'Mechanism is set to \'sspi\', but no '
                '\'principal\' key found in proxy config.')
        for key in ('domain', 'principal'):
            DETAILS[key] = proxy_conf[key]

    # Save optional
    DETAILS['protocol'] = proxy_conf.get('protocol')
    DETAILS['port'] = proxy_conf.get('port')

    # Test connection
    if DETAILS['mechanism'] == 'userpass':
        # Get the correct login details
        log.debug('Retrieving credentials and testing vCenter connection for '
                  'mehchanism \'userpass\'')
        try:
            username, password = find_credentials()
            DETAILS['password'] = password
        except salt.exceptions.SaltSystemExit as err:
            log.critical('Error: %s', err)
            return False
    return True