Esempio n. 1
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'])
    parser.add_argument('-s', '--state-file', default='')
    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)
    try:
        logging.basicConfig(level=level)
        state_data = open(args.state_file, 'r').read() if args.state_file else ""
        cs = CoordinatorServer(args.bindto, args.control_port, args.host_port, state_data)
        logging.info('Coordinator started')
        cs.run()
    except Coordinator.InvalidStateData as ise:
        logging.error("Error loading state from file {0}".format(args.state_file))
    except socket.error as se:
        logging.error("%s [%d]" % (se.strerror, se.errno))
    except IOError as ioe:
        logging.error("%s [%d]" % (ioe.strerror, ioe.errno))
Esempio n. 2
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)
    parser_validate_space = subparsers.add_parser('validate-space', help='validate help')
    parser_validate_space.set_defaults(func=validate_space)
    parser_lst_spaces = subparsers.add_parser('lst-spaces', help='lst-space help')
    parser_lst_spaces.set_defaults(func=lst_spaces)
    parser_get_space = subparsers.add_parser('get-space', help='get-space help')
    parser_get_space.add_argument('space', metavar='SPACE', help='the space to get')
    parser_get_space.set_defaults(func=get_space)
    parser_shutdown = subparsers.add_parser('shutdown', help='shutdown help')
    parser_shutdown.set_defaults(func=shutdown)
    parser_get_status = subparsers.add_parser('get-status', help='get-stataus help')
    parser_get_status.set_defaults(func=get_status)
    parser_go_live = subparsers.add_parser('go-live', help='get-stataus help')
    parser_go_live.set_defaults(func=go_live)
    parser_go_live = subparsers.add_parser('backup-state', help='backup-state help')
    parser_go_live.set_defaults(func=backup_state)
    args = parser.parse_args(args)
    return args.func(args)
Esempio n. 3
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)
    parser_validate_space = subparsers.add_parser('validate-space', help='validate help')
    parser_validate_space.set_defaults(func=validate_space)
    parser_lst_spaces = subparsers.add_parser('lst-spaces', help='lst-space help')
    parser_lst_spaces.set_defaults(func=lst_spaces)
    parser_get_space = subparsers.add_parser('get-space', help='get-space help')
    parser_get_space.add_argument('space', metavar='SPACE', help='the space to get')
    parser_get_space.set_defaults(func=get_space)
    parser_shutdown = subparsers.add_parser('quiesce', help='quiesce help')
    parser_shutdown.set_defaults(func=quiesce)
    parser_shutdown = subparsers.add_parser('shutdown', help='shutdown help')
    parser_shutdown.set_defaults(func=shutdown)
    parser_get_status = subparsers.add_parser('get-status', help='get-stataus help')
    parser_get_status.set_defaults(func=get_status)
    parser_go_live = subparsers.add_parser('go-live', help='get-stataus help')
    parser_go_live.set_defaults(func=go_live)
    parser_go_live = subparsers.add_parser('backup-state', help='backup-state help')
    parser_go_live.set_defaults(func=backup_state)
    args = parser.parse_args(args)
    return args.func(args)
Esempio n. 4
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)
    parser_validate_space = subparsers.add_parser('validate-space', help='validate help')
    parser_validate_space.set_defaults(func=validate_space)
    args = parser.parse_args(args)
    return args.func(args)
Esempio n. 5
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)
    try:
        logging.basicConfig(level=level)
        cs = CoordinatorServer(args.bindto, args.control_port, args.host_port)
        cs.run()
    except socket.error as se:
        logging.error("%s [%d]" % (se.strerror, se.errno))
Esempio n. 6
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'
                        ])
    parser.add_argument('-s', '--state-file', default='')
    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)
    try:
        logging.basicConfig(level=level)
        state_data = open(args.state_file,
                          'r').read() if args.state_file else ""
        cs = CoordinatorServer(args.bindto, args.control_port, args.host_port,
                               state_data)
        logging.info('Coordinator started')
        cs.run()
    except Coordinator.InvalidStateData as ise:
        logging.error("Error loading state from file {0}".format(
            args.state_file))
    except socket.error as se:
        logging.error("%s [%d]" % (se.strerror, se.errno))
    except IOError as ioe:
        logging.error("%s [%d]" % (ioe.strerror, ioe.errno))