Example #1
0
def main(argv=sys.argv[1:]):
    # Test for color support to setup options 
    # We may be able to just remove this.
    color_support = is_color_supported()

    parser = argparse.ArgumentParser(description="""
        Find optimal autocost reference bandwidth for OSPF by comparing 
        the calulated value against common links found in modern networks.""")
    parser.add_argument('ref_bw', metavar='REFBW',
                        help="Reference bandwidth to calulate against")
    default_compairisons = [str(Bandwidth(x)) for x in DEFAULT_COMPARISON_BW]
    parser.add_argument('-b', '--comparison-bw', metavar='BW', nargs='*', 
                        default=DEFAULT_COMPARISON_BW, dest="bw_values",
                        help="Bandwith values to test (default: %s)" % 
                              ', '.join(default_compairisons))
    parser.add_argument('-a', '--add-comparison', metavar='BW', nargs='*',
                        default = [], dest="add_bw_values",
                        help="Add additional bandwidth values to test.")
    parser.add_argument('-n', '--no-color', action='store_false', 
                        dest='color', default=color_support,
                        help="Don't show any colors in the output.")
    parser.add_argument('-c', '--color', action='store_true', dest='color', 
                        default=color_support, help="Force output of colors.")
    parser.add_argument('-f', '--format', choices=['normal', 'csv'], 
                        default='normal',
                        help="Output format. 'normal' outputs fancy formating "\
                             "(optionally colored). 'csv' outputs CSV format "\
                             "with header.")
    parser.add_argument('--version', action='version', 
                        version='%(prog)s ' + get_version())

    args = parser.parse_args(argv)  
    refbw = Bandwidth(args.ref_bw, default_unit='m')

    comp_list = [Bandwidth(x) for x in args.bw_values + args.add_bw_values]
    comp_list = unique(sorted(comp_list, reverse=True))

    if args.format == 'normal':
        output_terminal(refbw, comp_list, args.color)
    elif args.format == 'csv':
        output_csv(refbw, comp_list)
Example #2
0
#!/usr/bin/env python
from distutils.core import setup
from refbwcalc import get_version

setup(
    name="refbwcalc",
    version=get_version(),
    description="Script to calculate the resulting OSPF metrics for different" "autobw settings",
    author="Brandon Bennett",
    author_email="*****@*****.**",
    license="BSD",
    packages=["refbwcalc"],
    scripts=["bin/refbwcalc"],
)