Esempio n. 1
0
def rotate_log(request, log_type=None):
  return_dict = {}
  try:
    if log_type not in ["alerts", "audit_trail"]:
      raise Exception("Unknown log type")
      return django.shortcuts.render_to_response('logged_in_error.html', return_dict, context_instance = django.template.context.RequestContext(request))
    if log_type == "alerts":
      return_dict['tab'] = 'view_current_alerts_tab'
      return_dict["page_title"] = 'Rotate system alerts log'
      ret, err = alerts.rotate_alerts()
      if err:
        raise Exception(err)
      return_dict["message"] = "Alerts log successfully rotated."
      return django.http.HttpResponseRedirect("/view_rotated_log_list/alerts?success=true")
    elif log_type == "audit_trail":
      return_dict['tab'] = 'view_current_audit_tab'
      return_dict["page_title"] = 'Rotate system audit trail'
      ret, err = audit.rotate_audit_trail()
      if err:
        raise Exception(err)
      return_dict["message"] = "Audit trail successfully rotated."
      return django.http.HttpResponseRedirect("/view_rotated_log_list/audit_trail/?success=true")
  except Exception, e:
    return_dict['base_template'] = "logging_base.html"
    return_dict["error"] = 'Error rotating log'
    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 rotate_log(request, log_type=None):
  return_dict = {}
  try:
    if log_type not in ["alerts", "audit_trail"]:
      raise Exception("Unknown log type")
      return django.shortcuts.render_to_response('logged_in_error.html', return_dict, context_instance = django.template.context.RequestContext(request))
    if log_type == "alerts":
      return_dict['tab'] = 'view_current_alerts_tab'
      return_dict["page_title"] = 'Rotate system alerts log'
      ret, err = alerts.rotate_alerts()
      if err:
        raise Exception(err)
      return_dict["message"] = "Alerts log successfully rotated."
      return django.http.HttpResponseRedirect("/view_rotated_log_list/alerts?success=true")
    elif log_type == "audit_trail":
      return_dict['tab'] = 'view_current_audit_tab'
      return_dict["page_title"] = 'Rotate system audit trail'
      ret, err = audit.rotate_audit_trail()
      if err:
        raise Exception(err)
      return_dict["message"] = "Audit trail successfully rotated."
      return django.http.HttpResponseRedirect("/view_rotated_log_list/audit_trail/?success=true")
  except Exception, e:
    return_dict['base_template'] = "logging_base.html"
    return_dict["error"] = 'Error rotating log'
    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 rotate_log(request, log_type):

  return_dict = {}
  try:
    if log_type == "alerts":
      try:
        alerts.rotate_alerts()
      except Exception, e:
        return_dict["error"] = "Error rotating alerts log: %s"%e
        return django.shortcuts.render_to_response('logged_in_error.html', return_dict, context_instance = django.template.context.RequestContext(request))
      #return_dict["topic"] = "Logging -> Rotate alerts log"
      return_dict["page_header"] = "Logging"
      return_dict["page_sub_header"] = "Rotate alerts log"
      return_dict["message"] = "Alerts log successfully rotated."
    elif log_type == "audit_trail":
      try:
        audit.rotate_audit_trail()
      except Exception, e:
        return_dict["error"] = "Error rotating audit trail : %s"%e
        return django.shortcuts.render_to_response('logged_in_error.html', return_dict, context_instance = django.template.context.RequestContext(request))