示例#1
0
        ))

    # Check slaves list
    check_server_lists(parser, opt.master, opt.slaves)

    # The value for --timeout needs to be an integer > 0.
    try:
        if int(opt.timeout) <= 0:
            parser.error("The --timeout option requires a value greater "
                         "than 0.")
    except ValueError:
        parser.error("The --timeout option requires an integer value.")

    # Check errors and warnings of options and combinations.

    if command not in get_valid_rpl_commands():
        parser.error("'{0}' is not a valid command.".format(command))

    # --master and --new-master options are required by 'switchover'
    if command == 'switchover' and (not opt.new_master or not opt.master):
        req_opts = '--master and --new-master'
        parser.error(PARSE_ERR_OPTS_REQ_BY_CMD.format(cmd=command,
                                                      opts=req_opts))

    # Allow health report for --master or --slaves
    if command == 'health' and not opt.master and not opt.slaves:
        req_opts = '--master or --slaves'
        parser.error(PARSE_ERR_OPTS_REQ_BY_CMD.format(cmd=command,
                                                      opts=req_opts))

    # --master and either --slaves or --discover-slaves-login options are
示例#2
0
# Add verbosity mode
add_verbosity(parser, True)

# Now we process the rest of the arguments.
opt, args = parser.parse_args()

# Check for invalid command
if len(args) > 1:
    parser.error("You can only specify one command to execute at a time.")
elif len(args) == 0:
    parser.error("You must specify a command to execute.")

# Check errors and warnings of options and combinations.
    
command = args[0].lower()
if not command in get_valid_rpl_commands():
    parser.error("'%s' is not a valid command." % command)

if command == 'switchover' and (opt.new_master is None or opt.master is None):
    parser.error("The switchover command requires the --master and "
                 "--new-master options.")
    
if command in ['health', 'gtid'] and opt.discover is None and \
   (opt.slaves is None or opt.master is None):
    parser.error("The health and gtid commands requires the --master and "
                 "--slaves options.")
    
if command in ['elect', 'failover', 'start', 'stop', 'reset'] and \
    not opt.discover and not opt.slaves:
    parser.error("You must supply a list of slaves or the "
                 "--discover-slaves-login option.")
示例#3
0
                                        opt2='--slaves'))

    # Check slaves list
    check_server_lists(parser, opt.master, opt.slaves)

    # The value for --timeout needs to be an integer > 0.
    try:
        if int(opt.timeout) <= 0:
            parser.error("The --timeout option requires a value greater "
                         "than 0.")
    except ValueError:
        parser.error("The --timeout option requires an integer value.")

    # Check errors and warnings of options and combinations.

    if command not in get_valid_rpl_commands():
        parser.error("'{0}' is not a valid command.".format(command))

    # --master and --new-master options are required by 'switchover'
    if command == 'switchover' and (not opt.new_master or not opt.master):
        req_opts = '--master and --new-master'
        parser.error(
            PARSE_ERR_OPTS_REQ_BY_CMD.format(cmd=command, opts=req_opts))

    # Allow health report for --master or --slaves
    if command == 'health' and not opt.master and not opt.slaves:
        req_opts = '--master or --slaves'
        parser.error(
            PARSE_ERR_OPTS_REQ_BY_CMD.format(cmd=command, opts=req_opts))

    # --master and either --slaves or --discover-slaves-login options are