def decomposeIntentions(q, hostPath, namespace, owner) : ''' Given a set of params, returns a dictionary capable of being passed to the client and turned into a SearchContext. ''' decompositionFailed = False try: parsedObj = splunk.search.Parser.parseSearch( q, hostPath=hostPath, sessionKey=cherrypy.session['sessionKey'], namespace=namespace, owner=owner ) decomposedSearch, intentions = xformer.decomposeSearch(namespace, owner, parsedObj, q) baseSearch = str(parsedObj) sequence = str(time.time()) #parserLogger.debug('DECOMPOSE %s IN %s' % (sequence, json.dumps({'q': q}))) #parserLogger.debug('DECOMPOSE %s OUT %s' % (sequence, json.dumps({'q': decomposedSearch.jsonable(), 'intentions': intentions}))) except Exception, e: #never break on resurrecting. except xformer.SearchTransformerException, e: logger.warn("Exception in resurrectSearch when trying to parse the following search - " + q) # import traceback; logger.error(traceback.format_exc()) baseSearch = q intentions = [] decompositionFailed = True
def decompose(self, q=None, namespace=None, owner=None): logger.debug("Decomposing intentions: %s" % q) try: parsedObj = splunk.search.Parser.parseSearch( q, hostPath=self.splunkd_urlhost, sessionKey=cherrypy.session['sessionKey'], namespace=namespace, owner=owner ) decomposedSearch, intentions = xformer.decomposeSearch(namespace, owner, parsedObj, q) logger.debug("Decomposing intentions result search: %s intentions: %s" % (decomposedSearch, intentions)) except Exception, e: return self._failJSON( _("PARSER: Unsupported search (%s): %s" % (q, e)))
def decompose(self, q=None, namespace=None, owner=None): logger.debug("Decomposing intentions: %s" % q) try: parsedObj = splunk.search.Parser.parseSearch( q, hostPath=self.splunkd_urlhost, sessionKey=cherrypy.session['sessionKey'], namespace=namespace, owner=owner) decomposedSearch, intentions = xformer.decomposeSearch( namespace, owner, parsedObj, q) logger.debug( "Decomposing intentions result search: %s intentions: %s" % (decomposedSearch, intentions)) except Exception, e: return self._failJSON( _("PARSER: Unsupported search (%s): %s" % (q, e)))
def _parseAndApplyIntentions(self, q=None, intentions=None, namespace=None, owner=None): # first, try to parse the given search string parsedObj = splunk.search.Parser.parseSearch( q, hostPath=self.splunkd_urlhost, sessionKey=cherrypy.session['sessionKey'], namespace=namespace, owner=owner ) # walk through the transform stack for intention in intentions: if intention[INAME] not in ["", None]: intentName = intention[INAME] intentArg = intention.get(IARG, {} ) intentFlags = intention.get(IFLAGS, None ) parsedObj = xformer.applyIntention(namespace, owner, parsedObj, intentName, intentArg, intentFlags) return parsedObj
def _parseAndApplyIntentions(self, q=None, intentions=None, namespace=None, owner=None): # first, try to parse the given search string parsedObj = splunk.search.Parser.parseSearch( q, hostPath=self.splunkd_urlhost, sessionKey=cherrypy.session['sessionKey'], namespace=namespace, owner=owner) # walk through the transform stack for intention in intentions: if intention[INAME] not in ["", None]: intentName = intention[INAME] intentArg = intention.get(IARG, {}) intentFlags = intention.get(IFLAGS, None) parsedObj = xformer.applyIntention(namespace, owner, parsedObj, intentName, intentArg, intentFlags) return parsedObj