Beispiel #1
0
def main(args):
    def load_format_file(format_file):
        if format_file.endswith('.py'):
            format_file = format_file[:-3].replace("/", ".")
        config = __import__(format_file, globals(), locals(), ["*"])
        return config

    if args.format_file is not None:
        format_def = load_format_file(args.format_file)
    else:
        format_def = object()

    dp_trace = None
    if args.dp_trace_path is not None:
        dp_trace = Trace(args.dp_trace_path).dataplane_trace

    if hasattr(format_def, "fields"):
        fields = format_def.fields
    else:
        fields = default_fields

    for field in fields:
        if field not in field_formatters:
            raise ValueError("unknown field %s" % field)

    if hasattr(format_def, "filtered_classes"):
        filtered_classes = format_def.filtered_classes
    else:
        filtered_classes = default_filtered_classes

    stats = Stats()

    # all events are printed with a fixed number of lines, and (optionally)
    # separated by delimiter lines of the form:
    # ----------------------------------
    with open(args.input) as input_file:
        trace = parse(input_file)
        for event in trace:
            if type(event) not in filtered_classes:
                if dp_trace is not None and type(
                        event) == replay_events.TrafficInjection:
                    event.dp_event = dp_trace.pop(0)
                for field in fields:
                    field_formatters[field](event)
                stats.update(event)

        if check_for_violation_signature(trace, args.violation_signature):
            print "Violation occurs at end of trace: %s" % args.violation_signature
        elif args.violation_signature is not None:
            print("Violation does not occur at end of trace: %s",
                  args.violation_signature)
        print

    if args.stats:
        print "Stats: %s" % stats
def main(args):
  def load_format_file(format_file):
    if format_file.endswith('.py'):
      format_file = format_file[:-3].replace("/", ".")
    config = __import__(format_file, globals(), locals(), ["*"])
    return config

  if args.format_file is not None:
    format_def = load_format_file(args.format_file)
  else:
    format_def = object()

  dp_trace = None
  if args.dp_trace_path is not None:
    dp_trace = Trace(args.dp_trace_path).dataplane_trace

  if hasattr(format_def, "fields"):
    fields = format_def.fields
  else:
    fields = default_fields

  for field in fields:
    if field not in field_formatters:
      raise ValueError("unknown field %s" % field)

  if hasattr(format_def, "filtered_classes"):
    filtered_classes = format_def.filtered_classes
  else:
    filtered_classes = default_filtered_classes

  stats = Stats()

  # all events are printed with a fixed number of lines, and (optionally)
  # separated by delimiter lines of the form:
  # ----------------------------------
  with open(args.input) as input_file:
    trace = parse(input_file)
    for event in trace:
      if type(event) not in filtered_classes:
        if dp_trace is not None and type(event) == replay_events.TrafficInjection:
          event.dp_event = dp_trace.pop(0)
        for field in fields:
          field_formatters[field](event)
        stats.update(event)

    if check_for_violation_signature(trace, args.violation_signature):
      print "Violation occurs at end of trace: %s" % args.violation_signature
    elif args.violation_signature is not None:
      print ("Violation does not occur at end of trace: %s",
             args.violation_signature)
    print

  if args.stats:
    print "Stats: %s" % stats
def main(args):
  if args.dp_trace_path is None:
    args.dp_trace_path = os.path.dirname(args.input) + "/dataplane.trace"

  dp_trace = Trace(args.dp_trace_path).dataplane_trace

  event_logger = InputLogger()
  event_logger.open(results_dir="/tmp/events.trace")

  with open(args.input) as input_file:
    trace = parse(input_file)
    for event in trace:
      if type(event) == replay_events.TrafficInjection:
        event.dp_event = dp_trace.pop(0)
      event_logger.log_input_event(event)

    event_logger.output.close()
Beispiel #4
0
def main(args):
    if args.dp_trace_path is None:
        args.dp_trace_path = os.path.dirname(args.input) + "/dataplane.trace"

    dp_trace = Trace(args.dp_trace_path).dataplane_trace

    event_logger = InputLogger()
    event_logger.open(results_dir="/tmp/events.trace")

    with open(args.input) as input_file:
        trace = parse(input_file)
        for event in trace:
            if type(event) == replay_events.TrafficInjection:
                event.dp_event = dp_trace.pop(0)
            event_logger.log_input_event(event)

        event_logger.output.close()