def pnp4nagios(request): """ View to handle integration with pnp4nagios """ c = {} c['errors'] = e = [] c['messages'] = m = [] c['broker_module'] = forms.PNPBrokerModuleForm(initial=request.GET) c['templates_form'] = forms.PNPTemplatesForm(initial=request.GET) c['action_url'] = forms.PNPActionUrlForm(initial=request.GET) c['pnp_templates'] = forms.PNPTemplatesForm(initial=request.GET) try: c['npcd_config'] = forms.PNPConfigForm(initial=request.GET) except Exception as e: c['errors'].append(e) #c['interesting_objects'] = form.interesting_objects if request.method == 'POST' and 'save_broker_module' in request.POST: c['broker_module'] = broker_form = forms.PNPBrokerModuleForm( data=request.POST) if broker_form.is_valid(): broker_form.save() m.append(_("Broker Module updated in nagios.cfg")) elif request.method == 'POST' and 'save_action_url' in request.POST: c['action_url'] = forms.PNPActionUrlForm(data=request.POST) if c['action_url'].is_valid(): c['action_url'].save() m.append( _('Action_url updated for %s services') % c['action_url'].total_services) if c['action_url'].error_services > 0: e.append( _("%s services could not be updated (check permissions?)") % c['action_url'].error_services) elif request.method == 'POST' and 'save_npcd_config' in request.POST: c['npcd_config'] = forms.PNPConfigForm(data=request.POST) if c['npcd_config'].is_valid(): c['npcd_config'].save() m.append(_("npcd.cfg updated")) return render_to_response('pnp4nagios.html', c, context_instance=RequestContext(request))
def pnp4nagios(request): """ View to handle integration with pnp4nagios """ c = {} c['errors'] = e = [] c['messages'] = m = [] c['broker_module'] = forms.PNPBrokerModuleForm(initial=request.GET) c['templates_form'] = forms.PNPTemplatesForm(initial=request.GET) c['action_url'] = forms.PNPActionUrlForm(initial=request.GET) c['pnp_templates'] = forms.PNPTemplatesForm(initial=request.GET) try: c['npcd_config'] = forms.PNPConfigForm(initial=request.GET) except Exception, e: c['errors'].append(e)
if broker_form.is_valid(): broker_form.save() m.append(_("Broker Module updated in nagios.cfg")) elif request.method == 'POST' and 'save_action_url' in request.POST: c['action_url'] = forms.PNPActionUrlForm(data=request.POST) if c['action_url'].is_valid(): c['action_url'].save() m.append( _('Action_url updated for %s services') % c['action_url'].total_services) if c['action_url'].error_services > 0: e.append( _("%s services could not be updated (check permissions?)") % c['action_url'].error_services) elif request.method == 'POST' and 'save_npcd_config' in request.POST: c['npcd_config'] = forms.PNPConfigForm(data=request.POST) if c['npcd_config'].is_valid(): c['npcd_config'].save() m.append(_("npcd.cfg updated")) return render_to_response('pnp4nagios.html', c, context_instance=RequestContext(request)) @adagios_decorator def edit_file(request, filename): """ This view gives raw read/write access to a given filename. Please be so kind as not to give direct url access to this function, because it will allow Editing of any file the webserver has access to.