def save(self, app, action, **params): ''' save the posted hadoop ops setup content ''' error_key = None form_content = {} user = cherrypy.session['user']['name'] host_app = cherrypy.request.path_info.split('/')[3] this_app = App.get(App.build_id(app, app, user)) ftr = 0 if (this_app.is_configured) else 1 redirect_params = dict(ftr=ftr) logger.error(params) # pass 1: load all user-supplied values as models for k, v in params.iteritems(): try: key = k.split('.')[1] except IndexError: continue if key and key in MACROS: if isinstance(v, list): definition = (' OR ').join(v) else: definition = v try: form_content[key] = Macro.get( Macro.build_id(key, app, user)) except: form_content[key] = Macro(app, user, key) form_content[key].definition = definition form_content[key].metadata.sharing = 'app' # pass 2: try to save(), and if we fail we return the user-supplied values for key in form_content.keys(): try: if not form_content[key].passive_save(): logger.error('Error saving setup values') return self.render_template('/%s:/templates/setup_show.html' \ % host_app, dict(name=key, app=app, form_content=form_content)) except splunk.AuthorizationFailed: logger.error('User %s is unauthorized to perform setup on %s' % (user, app)) raise cherrypy.HTTPRedirect( self._redirect(host_app, app, 'unauthorized', **redirect_params), 303) except Exception, ex: logger.debug(ex) logger.error('Failed to save eventtype %s' % key) raise cherrypy.HTTPRedirect( self._redirect(host_app, app, 'failure', **redirect_params), 303)
def save(self, app, action, **params): ''' save the posted hadoop ops setup content ''' error_key = None form_content = {} user = cherrypy.session['user']['name'] host_app = cherrypy.request.path_info.split('/')[3] this_app = App.get(App.build_id(app, app, user)) ftr = 0 if (this_app.is_configured) else 1 redirect_params = dict(ftr=ftr) logger.error(params) # pass 1: load all user-supplied values as models for k, v in params.iteritems(): try: key = k.split('.')[1] except IndexError: continue if key and key in MACROS: if isinstance(v, list): definition = (' OR ').join(v) else: definition = v try: form_content[key] = Macro.get(Macro.build_id(key, app, user)) except: form_content[key] = Macro(app, user, key) form_content[key].definition = definition form_content[key].metadata.sharing = 'app' # pass 2: try to save(), and if we fail we return the user-supplied values for key in form_content.keys(): try: if not form_content[key].passive_save(): logger.error('Error saving setup values') return self.render_template('/%s:/templates/setup_show.html' \ % host_app, dict(name=key, app=app, form_content=form_content)) except splunk.AuthorizationFailed: logger.error('User %s is unauthorized to perform setup on %s' % (user, app)) raise cherrypy.HTTPRedirect(self._redirect(host_app, app, 'unauthorized', **redirect_params), 303) except Exception, ex: logger.debug(ex) logger.error('Failed to save eventtype %s' % key) raise cherrypy.HTTPRedirect(self._redirect(host_app, app, 'failure', **redirect_params), 303)
def show(self, app, action, **kwargs): ''' shows the hadoop ops setup page ''' form_content = {} user = cherrypy.session['user']['name'] host_app = cherrypy.request.path_info.split('/')[3] for key in MACROS: try: form_content[key] = Macro.get(Macro.build_id(key, app, user)) except: form_content[key] = Macro(app, user, key) return self.render_template('/%s:/templates/setup_show.html' % host_app, dict(form_content=form_content, app=app))
def show(self, app, action, **kwargs): ''' shows the hadoop ops setup page ''' form_content = {} user = cherrypy.session['user']['name'] host_app = cherrypy.request.path_info.split('/')[3] for key in MACROS: try: form_content[key] = Macro.get(Macro.build_id(key, app, user)) except: form_content[key] = Macro(app, user, key) return self.render_template( '/%s:/templates/setup_show.html' % host_app, dict(form_content=form_content, app=app))