def uipool(self, action, **args): # unauthed calls get nothing if not cherrypy.session.get('sessionKey'): return '/* unauthorized */' return self.render_json(MsgPoolMgr.get_poolmgr_instance()[UI_MSG_POOL].list())
def uipool(self, action, **args): # unauthed calls get nothing if not cherrypy.session.get('sessionKey'): return '/* unauthorized */' return self.render_json( MsgPoolMgr.get_poolmgr_instance()[UI_MSG_POOL].list())
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)
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)
def checkstatus(self, appid, state=None, return_to=None, checkstatus=None, **kw): """ Check the status of the installed app Is the app enabled? If not prompt for that Is a restart required? If so prompt for that Does the app need to be setup? If so prompt for that Else set a message and bounce the user back to the return_url """ if state: if not isinstance(state, StateDict): state = StateDict.unserialize(state) else: state = StateDict({ 'return_to': return_to if return_to else self.make_url( ['manager', splunk.getDefault('namespace')], translate=False), }) app = self.getLocalApp(appid) if not app: logger.warn( "Attempted to access appinstall/checkstatus point for non-installed app %s" % appid) return self.redirect_to_url(['/manager/appinstall', appid], _qs={'state': state.serialize()}) force = 0 #if self.isRestartRequired() or True: if self.isRestartRequired() or force: # check the user has restart privileges serverControls = en.getEntities("server/control") restartLink = filter((lambda x: x[0] == 'restart'), serverControls.links) displayRestartButton = len(restartLink) > 0 return self.render_admin_template( '/admin/appinstall/restart-required.html', { 'displayRestartButton': displayRestartButton, 'restart_target_url': self.make_url( ['/manager/appinstall', appid, 'checkstatus'], _qs={'state': state.serialize()}), 'breadcrumbs': state.get('breadcrumbs', []), 'appid': appid, 'state': state }) # app is installed, does it need configuring? if self.appNeedsSetup(app): return self.render_admin_template( '/admin/appinstall/setup-required.html', { 'app': app, 'state': state, 'breadcrumbs': state.get('breadcrumbs', []), 'setup_url': self.getSetupURL(appid, state) }) if self.appIsDisabled(app): return self.render_admin_template( '/admin/appinstall/enable-required.html', { 'app': app, 'appid': appid, 'state': state, 'breadcrumbs': state.get('breadcrumbs', []) }) # else it's installed OK! msgid = MsgPoolMgr.get_poolmgr_instance()[UI_MSG_POOL].push( 'info', _('App "%(appname)s" was installed successfully') % {'appname': app.get('label', appid)}) return_to = state.get('return_to') return_to_success = state.get('return_to_success') if return_to_success: # an explicit success-page url was supplied return_to_success = return_to_success.replace( '__appid__', splunk.util.safeURLQuote(unicode(appid))) return self.redirect_to_url(return_to_success, _qs={'msgid': msgid}) if return_to: # else use the default return to return self.redirect_to_url(return_to, _qs={'msgid': msgid}) # else fallback to the manager home page return self.redirect_to( ['manager', splunk.getDefault('namespace')], _qs={'msgid': msgid})
def checkstatus(self, appid, state=None, return_to=None, checkstatus=None, **kw): """ Check the status of the installed app Is the app enabled? If not prompt for that Is a restart required? If so prompt for that Does the app need to be setup? If so prompt for that Else set a message and bounce the user back to the return_url """ if state: if not isinstance(state, StateDict): state = StateDict.unserialize(state) else: state = StateDict({ 'return_to': return_to if return_to else self.make_url(['manager', splunk.getDefault('namespace'), 'apps','local'], translate=False), }) app = self.getLocalApp(appid) if not app: logger.warn("Attempted to access appinstall/checkstatus point for non-installed app %s" % appid) return self.redirect_to_url(['/manager/appinstall', appid], _qs={'state': state.serialize()}) force = 0 #if self.isRestartRequired() or True: if self.isRestartRequired() or force: # check the user has restart privileges serverControls = en.getEntities("server/control") restartLink = filter((lambda x: x[0] == 'restart'), serverControls.links) displayRestartButton = len(restartLink)>0 return self.render_admin_template('/admin/appinstall/restart-required.html', { 'displayRestartButton': displayRestartButton, 'restart_target_url': self.make_url(['/manager/appinstall', appid, 'checkstatus'], _qs={'state': state.serialize()}), 'breadcrumbs': state.get('breadcrumbs', []), 'appid': appid, 'state': state }) # app is installed, does it need configuring? if self.appNeedsSetup(app): return self.render_admin_template('/admin/appinstall/setup-required.html', { 'app': app, 'state': state, 'breadcrumbs': state.get('breadcrumbs', []), 'setup_url': self.getSetupURL(appid, state) }) if self.appIsDisabled(app): return self.render_admin_template('/admin/appinstall/enable-required.html', { 'app': app, 'appid': appid, 'state': state, 'breadcrumbs': state.get('breadcrumbs', []) }) # else it's installed OK! try: msgid = MsgPoolMgr.get_poolmgr_instance()[UI_MSG_POOL].push('info', _('App "%(appname)s" was installed successfully') % {'appname': app.get('label', appid)}) except KeyError: msgid = '' return_to = state.get('return_to') return_to_success = state.get('return_to_success') if return_to_success: # an explicit success-page url was supplied return_to_success = return_to_success.replace('__appid__', splunk.util.safeURLQuote(unicode(appid))) return self.redirect_to_url(return_to_success, _qs={'msgid': msgid}) if return_to: # else use the default return to return self.redirect_to_url(return_to, _qs={'msgid': msgid}) return self.redirect_to_url(['manager', splunk.getDefault('namespace'), 'apps','local'], _qs={'msgid': msgid})