コード例 #1
0
ファイル: taunixsetup.py プロジェクト: skywalka/puppet-splunk
    def save(self, app, action, host_app=None, **params):
        ''' save the posted setup content '''

        user = cherrypy.session['user']['name']

        mon = MonitorInput.all()
        mon = mon.filter_by_app(app)

        scripted = ScriptedInput.all()
        scripted = scripted.filter_by_app(app)

        for m in mon:
            disabled = normBool(params.get(m.name + '.disabled'))
            if disabled:
                m.disable()
            else:
                m.enable()
            m.share_global()

        for s in scripted:
            disabled = normBool(params.get(s.name + '.disabled'))
            if disabled:
                s.disable()
            else:
                s.enable()
            s.share_global()
            interval = params.get(s.name + '.interval')
            if interval:
                s.interval = interval
                try:
                    if not s.passive_save():
                        logger.error(m.errors)
                        return self.render_template(
                            '/%s:/templates/setup_show.html' \
                                % host_app,
                            dict(app=app,
                                 errors=s,
                                 scripted=scripted,
                                 mon=mon)
                        )
                except splunk.AuthorizationFailed:
                    raise cherrypy.HTTPRedirect(
                        self._redirect(host_app, app, 'unauthorized'))
                except Exception, ex:
                    logger.info(ex)
                    raise cherrypy.HTTPRedirect(
                        self._redirect(host_app, app, 'failure'))
コード例 #2
0
ファイル: taunixsetup.py プロジェクト: amoswood/puppet-splunk
    def save(self, app, action, host_app=None, **params):
        ''' save the posted setup content '''

        user = cherrypy.session['user']['name'] 

        mon = MonitorInput.all()
        mon = mon.filter_by_app(app)
  
        scripted = ScriptedInput.all()
        scripted = scripted.filter_by_app(app)
            
        for m in mon:
            disabled = normBool(params.get(m.name + '.disabled'))
            if disabled:
                m.disable()
            else:
                m.enable()
            m.share_global()

        for s in scripted:
            disabled = normBool(params.get(s.name + '.disabled'))
            if disabled:
                s.disable()
            else:
                s.enable()
            s.share_global()
            interval = params.get(s.name + '.interval')
            if interval:
                s.interval = interval
                try:
                    if not s.passive_save():
                        logger.error(m.errors)
                        return self.render_template(
                            '/%s:/templates/setup_show.html' \
                                % host_app,
                            dict(app=app, 
                                 errors=s,
                                 scripted=scripted, 
                                 mon=mon)
                        )
                except splunk.AuthorizationFailed:
                    raise cherrypy.HTTPRedirect(self._redirect(host_app, app, 'unauthorized'))
                except Exception, ex:
                    logger.info(ex)
                    raise cherrypy.HTTPRedirect(self._redirect(host_app, app, 'failure'))
コード例 #3
0
ファイル: taunixsetup.py プロジェクト: amoswood/puppet-splunk
    def setup(self, app, action, host_app=None, **kwargs):
        ''' show the setup page '''

        user = cherrypy.session['user']['name'] 
        
        if not self.is_app_admin(host_app, user):
            raise cherrypy.HTTPRedirect(self._redirect(host_app, app, 'unauthorized'))

        mon = MonitorInput.all()
        mon = mon.filter_by_app(app)
  
        scripted = ScriptedInput.all()
        scripted = scripted.filter_by_app(app)
        
        system = (not(sys.platform.startswith('win')))
   
        return self.render_template('/%s:/templates/setup_show.html' % host_app, 
                                    dict(system=system, mon=mon, scripted=scripted, app=app))
コード例 #4
0
ファイル: taunixsetup.py プロジェクト: skywalka/puppet-splunk
    def setup(self, app, action, host_app=None, **kwargs):
        ''' show the setup page '''

        user = cherrypy.session['user']['name']

        if not self.is_app_admin(host_app, user):
            raise cherrypy.HTTPRedirect(
                self._redirect(host_app, app, 'unauthorized'))

        mon = MonitorInput.all()
        mon = mon.filter_by_app(app)

        scripted = ScriptedInput.all()
        scripted = scripted.filter_by_app(app)

        system = (not (sys.platform.startswith('win')))

        return self.render_template(
            '/%s:/templates/setup_show.html' % host_app,
            dict(system=system, mon=mon, scripted=scripted, app=app))