def view_remote_monitoring_servers(request): return_dict = {} try: if "ack" in request.GET: if request.GET["ack"] == "updated": return_dict[ 'ack_message'] = "Remote monitoring server successfully updated" elif request.GET["ack"] == "deleted": return_dict[ 'ack_message'] = "Remote monitoring server successfully deleted" servers, err = remote_monitoring.get_servers() if err: raise Exception(err) return_dict['servers'] = servers return django.shortcuts.render_to_response( "view_remote_monitoring_servers.html", return_dict, context_instance=django.template.context.RequestContext(request)) except Exception, e: return_dict["page_title"] = 'Remote server monitoring' return_dict['tab'] = 'remote_monitoring_tab' return_dict["error"] = 'Error loading remote monitoring server list' return_dict['base_template'] = "logging_base.html" return_dict["error_details"] = str(e) return django.shortcuts.render_to_response( "logged_in_error.html", return_dict, context_instance=django.template.context.RequestContext(request))
def delete_remote_monitoring_server(request): return_dict = {} try: req_ret, err = django_utils.get_request_parameter_values(request, [ 'view', 'ip']) if err: raise Exception(err) if 'ip' not in req_ret: raise Exception('Invalid request, please use the menus.') ip = req_ret['ip'] servers, err = remote_monitoring.get_servers() if err: raise Exception(err) if ip not in servers.keys(): raise Exception( 'Specified server is currently not being remote monitored.') name = servers[ip]['name'] ret, err = remote_monitoring.delete_server(ip) if err: raise Exception(err) audit_str = 'Removed the remote monitoring server with IP : %s name : %s' % ( ip, name) audit.audit("delete_remote_monitoring_server", audit_str, request) return django.http.HttpResponseRedirect('/monitoring/view_remote_monitoring_servers?ack=deleted') except Exception, e: return_dict["page_title"] = 'Remove remote server monitoring server' return_dict['tab'] = 'remote_monitoring_tab' return_dict["error"] = 'Error removing remote monitoring server' return_dict['base_template'] = "monitoring_base.html" return_dict["error_details"] = str(e) return django.shortcuts.render_to_response("logged_in_error.html", return_dict, context_instance=django.template.context.RequestContext(request))
def update_remote_monitoring_server(request): return_dict = {} try: if request.method == "GET": servers, err = remote_monitoring.get_servers() if err: raise Exception(err) req_ret, err = django_utils.get_request_parameter_values(request, [ 'view', 'ip']) if err: raise Exception(err) initial = {} if 'ip' in req_ret: ip = req_ret['ip'] if ip in servers.keys(): initial['ip'] = ip initial['name'] = servers[ip]['name'] return_dict['action'] = 'update' else: return_dict['action'] = 'create' form = monitoring_forms.RemoteMonitoringServerForm(initial=initial) return_dict['form'] = form return django.shortcuts.render_to_response("update_remote_monitoring_server.html", return_dict, context_instance=django.template.context.RequestContext(request)) else: form = monitoring_forms.RemoteMonitoringServerForm(request.POST) return_dict["form"] = form if form.is_valid(): cd = form.cleaned_data res, err = remote_monitoring.update_server( cd['ip'], cd['name']) if not res: if err: raise Exception(err) else: raise Exception( 'Error updating remote monitoring server list') audit_str = 'Updated the remote monitoring server with IP : %s and name : %s' % ( cd['ip'], cd['name']) audit.audit("update_remote_monitoring_server", audit_str, request) return django.http.HttpResponseRedirect('/monitoring/view_remote_monitoring_servers?ack=updated') else: # invalid form return django.shortcuts.render_to_response("update_remote_monitoring_server.html", return_dict, context_instance=django.template.context.RequestContext(request)) except Exception, e: return_dict["page_title"] = 'Update remote server monitoring server' return_dict['tab'] = 'remote_monitoring_tab' return_dict["error"] = 'Error updating remote monitoring server' return_dict['base_template'] = "monitoring_base.html" return_dict["error_details"] = str(e) return django.shortcuts.render_to_response("logged_in_error.html", return_dict, context_instance=django.template.context.RequestContext(request))
def view_remote_monitoring_servers(request): return_dict = {} try: if "ack" in request.GET: if request.GET["ack"] == "updated": return_dict['ack_message'] = "Remote monitoring server successfully updated" elif request.GET["ack"] == "deleted": return_dict['ack_message'] = "Remote monitoring server successfully deleted" servers, err = remote_monitoring.get_servers() if err: raise Exception(err) return_dict['servers'] = servers return django.shortcuts.render_to_response("view_remote_monitoring_servers.html", return_dict, context_instance=django.template.context.RequestContext(request)) except Exception, e: return_dict["page_title"] = 'Remote server monitoring' return_dict['tab'] = 'remote_monitoring_tab' return_dict["error"] = 'Error loading remote monitoring server list' return_dict['base_template'] = "monitoring_base.html" return_dict["error_details"] = str(e) return django.shortcuts.render_to_response("logged_in_error.html", return_dict, context_instance=django.template.context.RequestContext(request))