def handleList(self, confInfo):
        user, app = self.user_app()

        # reload the conf before reading it
        try:
            entity.refreshEntities(
                self.endpoint,
                namespace=app,
                owner=user,
                sessionKey=self.getSessionKey(),
            )
        except Exception as exc:
            RH_Err.ctl(
                1023,
                msgx=exc,
                logLevel=logging.INFO,
                shouldPrint=False,
                shouldRaise=False,
            )

        if self.callerArgs.id is None:
            ents = self.all()
            for name, ent in list(ents.items()):
                makeConfItem(name, ent, confInfo, user=user, app=app)
        else:
            try:
                ent = self.get(self.callerArgs.id)
                makeConfItem(self.callerArgs.id, ent, confInfo, user=user, app=app)
            except ResourceNotFound as exc:
                RH_Err.ctl(-1, exc, logLevel=logging.INFO)
    def handleReload(self, confInfo=None, refreshProvidersServices=True):
        """
      Handles refresh/reload of the configuration options
      """
        ## Get requested action
        actionStr = str(self.requestedAction)
        if Transitioners.REQUESTED_ACTIONS.has_key(actionStr):
            actionStr = Transitioners.REQUESTED_ACTIONS[actionStr]

        logger.info('Entering %s' % (actionStr))

        logger.info(
            'Refreshing authorize configurations via properties endpoint')

        # Refresh the authorize endpoint: this will make it such that the calls to readConf for authorize.conf will return the correct results
        try:
            refreshInfo = entity.refreshEntities(
                'properties/authorize', sessionKey=self.getSessionKey())
        except Exception as e:
            logger.warn(
                'Could not refresh authorize configurations via properties endpoint: %s'
                % str(e))

        # Refresh the internal cached authentication capabilities data: this will make the /authorization/roles return the correct data
        if refreshProvidersServices:
            try:
                refreshInfo = entity.refreshEntities(
                    '/authentication/providers/services',
                    sessionKey=self.getSessionKey())
            except Exception as e:
                logger.warn(
                    'Could not refresh authorize configurations via properties endpoint: %s'
                    % str(e))

        logger.info('%s completed successfully' % (actionStr))
Beispiel #3
0
    def handleReload(self):
        """
        Reload the list of configuration options.
        """

        # Refresh the configuration (handles disk based updates)
        entity.refreshEntities('properties/' + self.conf_file, sessionKey=self.getSessionKey())
Beispiel #4
0
 def handleReload(self, confInfo):
     """
     Reload the list of configuration options.
     
     Arguments
     confInfo -- The object containing the information about what is being requested.
     """
     
     # Refresh the configuration (handles disk based updates)
     entity.refreshEntities('properties/' + self.CONF_FILE, sessionKey=self.getSessionKey())
    def handleReload(self, confInfo=None, makeKVS=True):
        """
        Handles refresh/reload of the configuration options
        """
        ## Get requested action
        actionStr = str(self.requestedAction)
        if Governance.REQUESTED_ACTIONS.has_key(actionStr):
            actionStr = Governance.REQUESTED_ACTIONS[actionStr]

        logger.info('Entering %s' % (actionStr))
        try:
            refreshInfo = entity.refreshEntities(
                'properties/governance', sessionKey=self.getSessionKey())

        except Exception as e:
            logger.warn(
                'Could not refresh governance configurations via properties endpoint: %s'
                % str(e))

        if makeKVS:
            # Only execute on standalone or on cluster master.
            exec_status, exec_status_msg = should_execute(
                session_key=self.getSessionKey())
            logger.info(exec_status_msg)
            if exec_status:
                self.makeKVS()

        logger.info('%s completed successfully' % (actionStr))
    def handleList(self, confInfo):
        user, app = self.user_app()

        # reload the conf before reading it
        try:
            entity.refreshEntities(self.endpoint,
                                   namespace=app,
                                   owner=user,
                                   sessionKey=self.getSessionKey())
        except Exception, exc:
            RestHandlerError.ctl(
                400,
                msgx=exc,
                logLevel=logging.INFO,
                shouldPrint=False,
                shouldRaise=False,
            )
  def writeInputs(self):
    inputsFile = os.path.join(os.environ['SPLUNK_HOME'], 'etc', 'apps', 'code42', 'default', 'inputs.json')
    entities = []
    with open(inputsFile) as data:
      inputConfs = json.load(data)

      for value in inputConfs:
        protocol = value['protocol']
        path = os.path.join(*value['path'])
        self.writeConf('inputs', "%s://%s" % (protocol, path), value['settings'])

        if not protocol in entities:
          entities.append(protocol)

    for entity in entities:
      entityPath = "/data/inputs/%s" % entity
      en.refreshEntities(entityPath, sessionKey=self.getSessionKey())
    def handleReload(self,
                     confInfo=None,
                     makeKVS=True,
                     reloadReviewStatuses=True):
        """
        Handles refresh/reload of the configuration options
        """
        actionStr = str(self.requestedAction)
        if actionStr in CorrelationSearches.REQUESTED_ACTIONS:
            actionStr = CorrelationSearches.REQUESTED_ACTIONS[actionStr]

        logger.info('Entering %s', actionStr)
        logger.info(
            'Refreshing correlationsearches configurations via properties endpoint'
        )
        try:
            entity.refreshEntities('properties/correlationsearches',
                                   sessionKey=self.getSessionKey())
        except Exception as e:
            logger.warn(
                'Could not refresh correlationsearches configurations via properties endpoint: %s',
                e)

        ## since we checkConf on reviewstatuses this ensures the latest values
        if reloadReviewStatuses:
            logger.info(
                'Refreshing reviewstatuses configurations via properties endpoint'
            )
            try:
                entity.refreshEntities('properties/reviewstatuses',
                                       sessionKey=self.getSessionKey())
            except Exception as e:
                logger.warn(
                    'Could not refresh reviewstatuses configurations via properties endpoint: %s',
                    e)

        if makeKVS:
            # Only execute on standalone or on cluster master.
            exec_status, exec_status_msg = should_execute(
                session_key=self.getSessionKey())
            logger.info(exec_status_msg)
            if exec_status:
                self.makeKVS()

        logger.info('%s completed successfully', actionStr)
Beispiel #9
0
    def write_inputs(self):
        """
        Writes out values to a json file.
        """
        inputs_file = os.path.join(os.environ['SPLUNK_HOME'], 'etc', 'apps',
                                   'code42', 'default', 'inputs.json')
        entities = []
        with open(inputs_file) as data:
            input_confs = json.load(data)

            for value in input_confs:
                protocol = value['protocol']
                path = os.path.join(*value['path'])
                self.writeConf('inputs', "%s://%s" % (protocol, path),
                               value['settings'])

                if protocol not in entities:
                    entities.append(protocol)

        for entity in entities:
            entity_path = "/data/inputs/%s" % entity
            en.refreshEntities(entity_path, sessionKey=self.getSessionKey())
Beispiel #10
0
    def handleReload(self, confInfo=None, makeCSV=True):
        """
        Handles refresh/reload of the configuration options
        """
        # Get requested action
        actionStr = str(self.requestedAction)
        if actionStr in Suppressions.REQUESTED_ACTIONS:
            actionStr = Suppressions.REQUESTED_ACTIONS[actionStr]

        logger.info('Entering %s', actionStr)

        logger.info(
            'Refreshing suppression configurations via properties endpoint')
        try:
            refreshInfo = entity.refreshEntities(
                'properties/eventtypes', sessionKey=self.getSessionKey())
        except Exception as e:
            logger.warn(
                'Could not refresh suppression configurations via properties endpoint: %s',
                str(e))

        logger.info('%s completed successfully', actionStr)
    def handleReload(self, confInfo=None):
        """
      Handles refresh/reload of the configuration options
      """
        ## Get requested action
        actionStr = str(self.requestedAction)
        if Transitions.REQUESTED_ACTIONS.has_key(actionStr):
            actionStr = Transitions.REQUESTED_ACTIONS[actionStr]

        logger.info('Entering %s' % (actionStr))

        logger.info(
            'Refreshing authorize configurations via properties endpoint')
        try:
            refreshInfo = entity.refreshEntities(
                'properties/authorize', sessionKey=self.getSessionKey())

        except Exception as e:
            logger.warn(
                'Could not refresh authorize configurations via properties endpoint: %s'
                % str(e))

        logger.info('%s completed successfully' % (actionStr))
    def refresh(self, entity=None, **kwargs):
        '''
        Forces a refresh on splunkd resources

        This method calls a splunkd refresh on all registered EAI handlers that
        advertise a reload function.  Alternate entities can be specified by appending
        them via URI parameters.  For example,

            http://localhost:8000/debug/refresh?entity=admin/conf-times&entity=data/ui/manager

        will request a refresh on only 'admin/conf-times' and 'data/ui/manager'.

        1) not all splunkd endpoints support refreshing.
        2) auth-services is excluded from the default set, as refreshing that system will
           logout the current user; use the 'entity' param to force it
        '''

        # get auto-list of refreshable EAI endpoints
        allEndpoints = en.getEntities('admin', namespace="search")
        eligibleEndpoints = {}

        for name in allEndpoints:
            for link in allEndpoints[name].links:
                if link[0] == '_reload':
                    logger.debug('FOUND reload for %s' % name)
                    eligibleEndpoints[name] = allEndpoints[name]
                    break

        if isinstance(entity, list):
            entityPaths = entity
        elif isinstance(entity, basestring):
            entityPaths = [entity]
        else:
            # seed manual endpoints
            entityPaths = [
                'admin/conf-times',
                'data/ui/manager',
                'data/ui/nav',
                'data/ui/views'
            ]

            # add capable endpoints
            for name in sorted(eligibleEndpoints.keys()):
                if name in ['auth-services']: # refreshing auth causes logout
                    continue
                if sys.platform == 'win32' and name == 'fifo':
                    # splunkd never loads FIFO on windows, but advertises it anyway
                    continue
                entityPaths.append('%s/%s' % (allEndpoints[name].path, allEndpoints[name].name))


        cherrypy.response.headers['content-type'] = MIME_TEXT

        output = ['Entity refresh control page']
        output.append('=' * len(output[0]))
        output.append("'''")
        output.append(self.refresh.__doc__.strip())
        output.append("'''")
        output.append('')

        # call refresh on each
        for path in entityPaths:
            try:
                en.refreshEntities(path, namespace='search')
                output.append(('Refreshing %s' % path).ljust(40, ' ') + 'OK')
            except Exception, e:
                logger.exception(e)
                msg = e
                if hasattr(e, 'extendedMessages') and e.extendedMessages:
                    msg = e.extendedMessages[0]['text']
                output.append(('Refreshing %s' % path).ljust(43, ' ') + e.__class__.__name__ + ' ' + unicode(msg))
 def handleReload(self, confInfo=None):
     # Refresh the configuration (handles disk based updates)
     refreshInfo = entity.refreshEntities('properties/log_review', sessionKey=self.getSessionKey())
Beispiel #14
0
    def refresh(self, entity=None, **kwargs):
        '''
        Forces a refresh on splunkd resources

        This method calls a splunkd refresh on all registered EAI handlers that
        advertise a reload function.  Alternate entities can be specified by appending 
        them via URI parameters.  For example,

            http://localhost:8000/debug/refresh?entity=admin/conf-times&entity=data/ui/manager
    
        will request a refresh on only 'admin/conf-times' and 'data/ui/manager'.

        1) not all splunkd endpoints support refreshing.
        2) auth-services is excluded from the default set, as refreshing that system will
           logout the current user; use the 'entity' param to force it
        '''
        
        # get auto-list of refreshable EAI endpoints
        allEndpoints = en.getEntities('admin', namespace="search")
        eligibleEndpoints = {}
        
        for name in allEndpoints:
            for link in allEndpoints[name].links:
                if link[0] == '_reload':
                    logger.debug('FOUND reload for %s' % name)
                    eligibleEndpoints[name] = allEndpoints[name]
                    break

        if isinstance(entity, list):
            entityPaths = entity
        elif isinstance(entity, basestring):
            entityPaths = [entity]
        else:
            # seed manual endpoints
            entityPaths = [
                'admin/conf-times',
                'data/ui/manager',
                'data/ui/nav',
                'data/ui/views'
            ]
            
            # add capable endpoints
            for name in sorted(eligibleEndpoints.keys()):
                if name not in ['auth-services']: # refreshing auth causes logout
                    entityPaths.append('%s/%s' % (allEndpoints[name].path, allEndpoints[name].name))
            
            
        cherrypy.response.headers['content-type'] = MIME_TEXT

        output = ['Entity refresh control page']
        output.append('=' * len(output[0]))
        output.append("'''")
        output.append(self.refresh.__doc__.strip())
        output.append("'''")
        output.append('')

        # call refresh on each
        for path in entityPaths:
            try:
                en.refreshEntities(path, namespace='search')
                output.append(('Refreshing %s' % path).ljust(40, ' ') + 'OK')
            except Exception, e:
                logger.exception(e)
                msg = e
                if hasattr(e, 'extendedMessages') and e.extendedMessages:
                    msg = e.extendedMessages[0]['text']
                output.append(('Refreshing %s' % path).ljust(43, ' ') + e.__class__.__name__ + ' ' + unicode(msg))
 def handleReload(self, confInfo=None):
     """
     Handles refresh/reload of the configuration options
     """
     refreshInfo = en.refreshEntities('apps/local/splunk_app_cef',
                                      sessionKey=self.getSessionKey())
Beispiel #16
0
 def __refresh_savedsearches__(session_key=None):
     en.refreshEntities('properties/savedsearches', sessionKey=session_key)