示例#1
0
def main(args, name='hyperdex-control'):
    parser = argparse.ArgumentParser(prog=name)
    parser.add_argument('--host', metavar='COORDHOST',
                        help='Address of the coordiantor',
                        default='127.0.0.1')
    parser.add_argument('--port', metavar='COORDPORT', type=int,
                        help='Port for coordinator control connections',
                        default=6970)
    subparsers = parser.add_subparsers(help='sub-command help')
    parser_add_space = subparsers.add_parser('add-space', help='add-space help')
    parser_add_space.set_defaults(func=add_space)
    parser_del_space = subparsers.add_parser('del-space', help='del-space help')
    parser_del_space.add_argument('space', metavar='SPACE', help='the space to delete')
    parser_del_space.set_defaults(func=del_space)
    args = parser.parse_args(args)
    return args.func(args)
示例#2
0
def main(argv):
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('-b', '--bindto', default='')
    parser.add_argument('-c', '--control-port', type=int, default=0)
    parser.add_argument('-p', '--host-port', type=int, default=0)
    parser.add_argument('-l', '--logging', default='info',
            choices=['debug', 'info', 'warn', 'error', 'critical',
                     'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL'])
    args = parser.parse_args(argv)
    level = {'debug': logging.DEBUG
            ,'info': logging.INFO
            ,'warn': logging.WARN
            ,'error': logging.ERROR
            ,'critical': logging.CRITICAL
            }.get(args.logging.lower(), None)
    logging.basicConfig(level=level)
    cs = CoordinatorServer(args.bindto, args.control_port, args.host_port)
    cs.run()