2 # vim: tabstop=4 shiftwidth=4 softtabstop=4
3 # -*- coding: utf-8 -*-
5 # ftg.py : It is a tool that ,
6 # you can capture and anlyze.
14 from optparse import OptionParser, OptionGroup
15 from ftg.grapher import Grapher
16 from ftg.utils.common import CommonUtils
17 from ftg.formatter.graphviz_tb import GraphvizTBFormatter
18 from ftg.formatter.csv import CSVFormatter
19 from ftg.formatter.tsv import TSVFormatter
22 if __name__ == "__main__":
23 # init program options
24 p = OptionParser(version="ver: %s" % __version__)
26 '-i', '--dump_file', dest='dump_file',
27 help="specify Open vSwitch dump-flows FILE", metavar="FILE")
29 '-f', '--formatter', dest='formatter',
30 help="specify formatter (graphviz, csv, tsv)", default="graphviz")
32 '-b', '--entries_per_block', dest='entries_per_block', type='int',
33 help="specify number of entries in priority block", default=10)
35 '-v', '--verbose', dest='verbose', action="store_true", default=False,
36 help="verbose output")
38 '-s', '--output_summary', dest='output_summary', action="store_true", default=False,
39 help="output summary informations")
41 '-d', '--debug', dest='debug', action="store_true", default=False,
43 g1 = OptionGroup(p, "Output Flags")
45 '--enable_resubmit_loop_output', dest='resubmit_loop_output',
46 action="store_true", default=True,
47 help="enable the output of the 'resubmit to start' that re-evaluate at the same table")
49 '--disable_resubmit_loop_output', dest='resubmit_loop_output',
50 action="store_false", default=True,
51 help="disable the output of the 'resubmit to start' that re-evaluate at the same table")
53 '--enable_note_output', dest='note_output',
54 action="store_true", default=True,
55 help="enable the output of the 'note action'")
57 '--disable_note_output', dest='note_output',
58 action="store_false", default=True,
59 help="disable the output of the 'note action'")
60 p.add_option_group(g1)
61 (opts, args) = p.parse_args()
63 util = CommonUtils(opts)
65 if opts.formatter == "graphviz":
66 formatter = GraphvizTBFormatter(util)
67 formatter.set_entries_per_block(opts.entries_per_block)
68 formatter.set_output_summary(opts.output_summary)
69 elif opts.formatter == "csv":
70 formatter = CSVFormatter(util)
71 elif opts.formatter == "tsv":
72 formatter = TSVFormatter(util)
74 util.error_out("specify valid formatter.")
77 if opts.dump_file is not None and opts.dump_file != "":
78 grapher = Grapher(util, opts.dump_file, formatter)
81 util.error_out("specify Open vSwitch dump-flows file with -i option.")