

def apikey(sessionKey, hostname, debug=False):
    'Login to a Palo Alto Networks device (firewall or Panorama)\n\n    Returns:\n        The API key for the firewall or Panorama\n    '
    try:
        apikey = get_firewall_apikey(sessionKey)
        log(debug, 'API Key found in Splunk credential store')
        return apikey
    except NoCredentialsFound:
        try:
            log(debug, 'API Key was not in Splunk credential store')
            log(debug, 'Getting credentials from Splunk credential store')
            (fw_username, fw_password) = get_firewall_credentials(sessionKey)
            log(debug, 'Getting API Key from firewall/Panorama')
            device = pandevice.base.PanDevice(hostname, fw_username, fw_password)
            apikey = device.api_key
            log(debug, 'Adding API Key to Splunk credential store')
            set_firewall_apikey(sessionKey, apikey)
            return apikey
        except NoCredentialsFound as e:
            exit_with_error('No Firewall/Panorama credentials for searchbar command. Please set the username and password in the App set up page.')
        except Exception as e:
            exit_with_error(('Unable to get apikey from firewall: %s' % str(e)))

dataset/ETHPy150Open PaloAltoNetworks/SplunkforPaloAltoNetworks/bin/lib/common.py apikey/original