def __argparse__(subparser, parents): """ Add the argparse cmdline arguments for data processing to the subparser """ parser = subparser.add_parser('process', formatter_class=argparse.RawTextHelpFormatter, description=__doc__, parents=parents) subparsers = parser.add_subparsers() # {parse} command parser_parse = subparsers.add_parser("parse", help="Parse Trace Routes. " "Perform ASN lookups for " "IPs as we go.", parents=parents) #parser_parse.add_argument("--geoipdb", #help='MaxMind GeoIP Database to use' #'for ASN lookups.', #required=True) parser_parse.add_argument("trace", help="CAIDA trace file", metavar="<trace file>") parser_parse.set_defaults( func=lazy_load('data.process', 'parse'), dump=False) parser_process_joins = subparsers.add_parser("process_joins", help="Process queued PoP joins", parents=parents) parser_process_joins.add_argument("--log_joins", type=str, metavar="LOG_FILE") parser_process_joins.set_defaults( func=lazy_load('data.process', 'process_delayed_joins')) parser_assign_pops = subparsers.add_parser( "assign_pops", help="Assign pops to the loaded links", parents=parents) parser_assign_pops.add_argument("--reset", action="store_true") parser_assign_pops.add_argument( "--process_failed", action="store_true", help="Process any links that were skipped in the initial run.") parser_assign_pops.set_defaults( func=lazy_load('data.process', 'assign_pops')) parser_cleanup = subparsers.add_parser( "cleanup", help="Remove all PoP related info from " "the database (but not the IP data)", parents=parents) parser_cleanup.add_argument( "--ip_links", help="Remove ip_links", action='store_true') parser_cleanup.set_defaults( func=lazy_load('data.cleanup', 'cleanup'))
def __argparse__(subparser, parents): """ Add command line subparsers for this module to the subparser module provided to this function. This helps build part of a chain of commands. :subparser: an argparse.Subparser object :parents: A list of argparse.ArgumentParsers for which the intent is for them to be parents :returns: Nothing """ parser = subparser.add_parser('graph', formatter_class=argparse.RawTextHelpFormatter, description=__doc__, parents=parents) sub = parser.add_subparsers() # {cleanup} cleanup_parser = sub.add_parser( "cleanup", help="Cleanup any extraneous keys in the database") cleanup_parser.set_defaults(func=lazy_load('graph.cleanup', 'cleanup')) # {create} create_parser = sub.add_parser( "create", help="Create a graph") # [save|reload] group = create_parser.add_mutually_exclusive_group(required=True) group.add_argument( "--reload", type=str, help="Reload the data from redis. Store the " "GraphML intermediary representation in FILENAME", metavar="FILENAME") group.add_argument( "--xml", type=str, help="Load from the GraphML file FILENAME", metavar="FILENAME") create_parser.add_argument( '--save', type=str, help="Save output with this prefix", metavar="PREFIX", required=True) create_parser.add_argument( "-c", "--num_clients", help="The number of clients to attach", type=int, dest="num_clients") create_parser.add_argument("--client_data", help="File containing client data", metavar="CLIENT_DATAFILE") create_parser.add_argument( "-d", "--num_dests", help="The number of destinations to " "attach. Destinations are drawn from the IP addresses " "used by the Alexa top 10000 sites", type=int, dest="num_dests") create_parser.add_argument( "--pointsofinterest", help="A JSON file containing points of interest to use as a list " "of objects. Each object should at the minimum contain " "the following keys: `id`, `pop` (the attach point), " " and `asn`. A document of this type for Tor relays can " "be created using " "{0}.".format( pkg_resources.resource_filename( 'inettopology_popmap.resources', 'ruby_ip_matcher')), metavar="RELAY_FILE") create_parser.add_argument( "--log", help="Log output here. Defaults to <save_opt>.log", metavar='<log file>') create_parser.set_defaults( func=lazy_load('graph.core', 'create_graph', check_create_args))