This function gets called when the proxy starts up. For
    panos devices, a determination is made on the connection type
    and the appropriate connection details that must be cached.

def init(opts):
    '''
    This function gets called when the proxy starts up. For
    panos devices, a determination is made on the connection type
    and the appropriate connection details that must be cached.
    '''
    if 'host' not in opts['proxy']:
        log.critical('No \'host\' key found in pillar for this proxy.')
        return False
    if 'apikey' not in opts['proxy']:
        # If we do not have an apikey, we must have both a username and password
        if 'username' not in opts['proxy']:
            log.critical('No \'username\' key found in pillar for this proxy.')
            return False
        if 'password' not in opts['proxy']:
            log.critical('No \'passwords\' key found in pillar for this proxy.')
            return False

    DETAILS['url'] = 'https://{0}/api/'.format(opts['proxy']['host'])

    # Set configuration details
    DETAILS['host'] = opts['proxy']['host']
    if 'serial' in opts['proxy']:
        DETAILS['serial'] = opts['proxy'].get('serial')
        if 'apikey' in opts['proxy']:
            log.debug("Selected pan_key method for panos proxy module.")
            DETAILS['method'] = 'pan_key'
            DETAILS['apikey'] = opts['proxy'].get('apikey')
        else:
            log.debug("Selected pan_pass method for panos proxy module.")
            DETAILS['method'] = 'pan_pass'
            DETAILS['username'] = opts['proxy'].get('username')
            DETAILS['password'] = opts['proxy'].get('password')
    else:
        if 'apikey' in opts['proxy']:
            log.debug("Selected dev_key method for panos proxy module.")
            DETAILS['method'] = 'dev_key'
            DETAILS['apikey'] = opts['proxy'].get('apikey')
        else:
            log.debug("Selected dev_pass method for panos proxy module.")
            DETAILS['method'] = 'dev_pass'
            DETAILS['username'] = opts['proxy'].get('username')
            DETAILS['password'] = opts['proxy'].get('password')

    # Ensure connectivity to the device
    log.debug("Attempting to connect to panos proxy host.")
    query = {'type': 'op', 'cmd': '<show><system><info></info></system></show>'}
    call(query)
    log.debug("Successfully connected to panos proxy host.")

    DETAILS['initialized'] = True