Пример #1
0
    def dispatchJob(self, wait=True, **kwargs):
        '''
        Dispatches a new job
        '''
        if not set(kwargs.keys()) >= set(REQUIRED_DISPATCH_ARGUMENTS):
            raise cherrypy.HTTPError(
                status=400,
                message=
                "Missing one or more of the required arguments: 'search', 'statusBucketCount', 'earliestTime', 'latestTime'."
            )

        # setup the dispatch args
        options = kwargs.copy()
        q = options['search']
        del options['search']

        if 'maxEvents' not in options:
            options['maxEvents'] = EXPORT_HARDLIMIT

        # ensure that owner and namespace contexts are passed
        if 'owner' not in options:
            options['owner'] = cherrypy.session['user'].get('name')
        if 'namespace' not in options:
            options['namespace'] = splunk.getDefault('namespace')
            logger.warn(
                'search was dispatched without a namespace specified; defaulting to "%s"'
                % options['namespace'])

        # Add the default time format
        options['time_format'] = cherrypy.config.get('DISPATCH_TIME_FORMAT')

        # bypass the legacy sdk blocking for RUNNING state
        wait = splunk.util.normalizeBoolean(wait)
        options["waitForRunning"] = wait

        resp = JsonResponse()

        try:
            logger.debug('q=%s' % q)
            logger.debug('options=%s' % options)

            # We're not going to read/write further from the user's session at this point...if we do, acquire the lock`
            # This can take significant time when there is a subsearch
            cherrypy.session.release_lock()

            job = splunk.search.dispatch(
                q, sessionKey=cherrypy.session['sessionKey'], **options)
            resp.data = job.id
        except splunk.SplunkdConnectionException, e:
            logger.exception(e)
            resp.success = False
            resp.addFatal(str(e))
Пример #2
0
    def uiindex(self, **kwargs):
        '''
        JSONResponse envelope of message data.
        '''
        resp = JsonResponse()

        try:
            msg = MsgPoolMgr.get_poolmgr_instance()[UI_MSG_POOL].pop(kwargs['id'])

            if msg:
                resp.addMessage(msg.severity.upper(), msg.text)

        except splunk.SplunkdConnectionException, e:
            logger.exception(e)
            resp.success = False
            resp.addFatal(_('The appserver was unable to connect to splunkd. Check if splunkd is still running. (%s)') % e.message)
Пример #3
0
    def dispatchJob(self, **kwargs):
        """
        Dispatches a new job
        """
        if not set(kwargs.keys()) >= set(REQUIRED_DISPATCH_ARGUMENTS):
            raise cherrypy.HTTPError(
                status=400,
                message="Missing one or more of the required arguments: 'search', 'statusBucketCount', 'earliestTime', 'latestTime'.",
            )

        # setup the dispatch args
        options = kwargs.copy()
        q = options["search"]
        del options["search"]

        if "maxEvents" not in options:
            options["maxEvents"] = EXPORT_HARDLIMIT

        # ensure that owner and namespace contexts are passed
        if "owner" not in options:
            options["owner"] = cherrypy.session["user"].get("name")
        if "namespace" not in options:
            options["namespace"] = splunk.getDefault("namespace")
            logger.warn(
                'search was dispatched without a namespace specified; defaulting to "%s"' % options["namespace"]
            )

        # Add the default time format
        options["time_format"] = cherrypy.config.get("DISPATCH_TIME_FORMAT")

        resp = JsonResponse()

        try:
            try:
                userid = cherrypy.session["user"]["name"]
                querylogger.warn("%s\t%s" % (userid, q))
            except:
                pass

            logger.debug("q=%s" % q)
            logger.debug("options=%s" % options)
            job = splunk.search.dispatch(q, sessionKey=cherrypy.session["sessionKey"], **options)
            resp.data = job.id
        except splunk.SplunkdConnectionException, e:
            logger.exception(e)
            resp.success = False
            resp.addFatal(str(e))
    def dispatchJob(self, wait=True, **kwargs):
        '''
        Dispatches a new job
        '''
        if not set(kwargs.keys()) >= set(REQUIRED_DISPATCH_ARGUMENTS):
            raise cherrypy.HTTPError(status=400, message="Missing one or more of the required arguments: 'search', 'statusBucketCount', 'earliestTime', 'latestTime'.")

        # setup the dispatch args
        options = kwargs.copy()
        q = options['search']
        del options['search']

        if 'maxEvents' not in options:
            options['maxEvents'] = EXPORT_HARDLIMIT
        
        # ensure that owner and namespace contexts are passed
        if 'owner' not in options:
            options['owner'] = cherrypy.session['user'].get('name')
        if 'namespace' not in options:
            options['namespace'] = splunk.getDefault('namespace')
            logger.warn('search was dispatched without a namespace specified; defaulting to "%s"' % options['namespace'])

        # Add the default time format
        options['time_format'] = cherrypy.config.get('DISPATCH_TIME_FORMAT')
        
        # bypass the legacy sdk blocking for RUNNING state
        wait = splunk.util.normalizeBoolean(wait)
        options["waitForRunning"] = wait
     
        resp = JsonResponse()

        try:
            logger.debug('q=%s' % q)
            logger.debug('options=%s' % options)

            # We're not going to read/write further from the user's session at this point...if we do, acquire the lock`
            # This can take significant time when there is a subsearch
            cherrypy.session.release_lock()

            job = splunk.search.dispatch(q, sessionKey=cherrypy.session['sessionKey'], **options)
            resp.data = job.id
        except splunk.SplunkdConnectionException, e:
            logger.exception(e)
            resp.success = False
            resp.addFatal(str(e))
    def uiindex(self, **kwargs):
        '''
        JSONResponse envelope of message data.
        '''
        resp = JsonResponse()

        try:
            msg = MsgPoolMgr.get_poolmgr_instance()[UI_MSG_POOL].pop(
                kwargs['id'])

            if msg:
                resp.addMessage(msg.severity.upper(), msg.text)

        except splunk.SplunkdConnectionException, e:
            logger.exception(e)
            resp.success = False
            resp.addFatal(
                _('The appserver was unable to connect to splunkd. Check if splunkd is still running. (%s)'
                  ) % e.message)