コード例 #1
0
        "span_key_size": opt.span_key_size,
        "skip_table_opts": opt.skip_tbl_opts,
        "charset": opt.charset,
        "use_indexes": db_idxes_l,
        "compact": opt.compact,
        "all": opt.all,
        "use_regexp": opt.use_regexp,
        "exclude_patterns": exclude_list,
    }

    # Add ssl options to options instead of connection.
    options.update(get_ssl_dict(opt))

    # Check server options.
    if not opt.server1:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt='--server1'))
    if opt.all and not opt.server2:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt='--server2'))

    # Parse server connection values
    server1_values = None
    server2_values = None
    try:
        server1_values = parse_connection(opt.server1, None, options)
    except FormatError:
        _, err, _ = sys.exc_info()
        parser.error("Server1 connection values invalid: %s." % err)
    except UtilError:
        _, err, _ = sys.exc_info()
        parser.error("Server1 connection values invalid: %s." % err.errmsg)
コード例 #2
0
    # Now we process the rest of the arguments.
    opt, args = parser.parse_args()

    # Check security settings
    check_password_security(opt, args)

    # option --master is required (mandatory)
    if not opt.master:
        default_val = "root@localhost:3306"
        print(WARN_OPT_USING_DEFAULT.format(default=default_val, opt="--master"))
        # Print the WARNING to force determinism if a parser error occurs.
        sys.stdout.flush()

    # option --slave is required (mandatory)
    if not opt.slave:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt="--slave"))

    # option --rpl-user is required (mandatory)
    if not opt.rpl_user:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt="--rpl-user"))

    # Parse source connection values
    try:
        m_values = parse_connection(opt.master, None, opt)
    except FormatError:
        _, err, _ = sys.exc_info()
        parser.error("Master connection values invalid: {0}.".format(err))
    except UtilError:
        _, err, _ = sys.exc_info()
        parser.error("Master connection values invalid: {0}." "".format(err.errmsg))
コード例 #3
0
    # format for list
    add_format_option(
        parser, "display the list of users in either grid "
        "(default), tab, csv, or vertical format - "
        "valid only for --list option", "grid")

    # Add verbosity and quiet (silent) mode
    add_verbosity(parser, True)

    # Now we process the rest of the arguments where the first is the
    # base user and the next N are the new users.
    opt, args = parser.parse_args()

    # Fail if no --source provided
    if not opt.source:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt='--source'))

    # Fail if no users specified and not using the --list option
    if not args and not opt.list_users:
        parser.error("You must specify either a source user or use the --list "
                     "option. See --help for details.")

    # Check security settings
    check_password_security(opt, args)

    # Fail if dump and quiet set
    if opt.quiet and opt.dump:
        parser.error("You cannot use --quiet and --dump together.")

    # Warn if quiet and verbosity are both specified
    check_verbosity(opt)
コード例 #4
0
    # format for list
    add_format_option(parser, "display the list of users in either grid "
                              "(default), tab, csv, or vertical format - "
                              "valid only for --list option", "grid")

    # Add verbosity and quiet (silent) mode
    add_verbosity(parser, True)

    # Now we process the rest of the arguments where the first is the
    # base user and the next N are the new users.
    opt, args = parser.parse_args()

    # Fail if no --source provided
    if not opt.source:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt='--source'))

    # Fail if no users specified and not using the --list option
    if not args and not opt.list_users:
        parser.error("You must specify either a source user or use the --list "
                     "option. See --help for details.")

    # Check security settings
    check_password_security(opt, args)

    # Fail if dump and quiet set
    if opt.quiet and opt.dump:
        parser.error("You cannot use --quiet and --dump together.")

    # Warn if quiet and verbosity are both specified
    check_verbosity(opt)
コード例 #5
0
                         "'gitd' or 'uuid'".format(opt.report_values))

    # Check for errors
    if int(opt.interval) < 5:
        parser.error(
            PARSE_ERR_OPTS_REQ_GREATER_OR_EQUAL.format(opt="--interval",
                                                       value=5))

    if int(opt.switchover_interval) < 30:
        parser.error(
            PARSE_ERR_OPTS_REQ_GREATER_OR_EQUAL.format(
                opt="--switchover-interval", value=30))

    # option --slave is required (mandatory)
    if not opt.slave:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt="--slave"))

    # option --masters is required (mandatory)
    if not opt.masters:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt="--masters"))

    # option --rpl-user is required (mandatory)
    if not opt.rpl_user:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt="--rpl-user"))

    config_reader = MyDefaultsReader(opt, False)

    # Parse slave connection values
    try:
        slave_vals = parse_connection(opt.slave, config_reader, opt)
    except FormatError:
コード例 #6
0
    if opt.master is None and opt.discover:
        parser.error(
            PARSE_ERR_OPT_REQ_OPT.format(opt="--discover-slaves-login",
                                         opts="--master")
        )

    if opt.master and opt.slaves is None and opt.discover is None:
        err_msg = PARSE_ERR_OPT_REQ_OPT.format(
            opt="--master",
            opts="--slaves or --discover-slaves-login",
        )
        parser.error(err_msg)

    # Check mandatory options: --server or --master.
    if not opt.server and not opt.master:
        parser.error(PARSE_ERR_OPTS_REQ.format(
            opt="--server' or '--master"))

    # Check slaves list (master cannot be included in slaves list).
    if opt.master:
        check_server_lists(parser, opt.master, opt.slaves)

        # Parse the master and slaves connection parameters (no candidates).
        try:
            master_val, slaves_val, _ = parse_topology_connections(
                opt, parse_candidates=False
            )
        except UtilRplError:
            _, err, _ = sys.exc_info()
            parser.error("ERROR: {0}\n".format(err.errmsg))
            sys.exit(1)
コード例 #7
0
                      "-r",
                      action="store_true",
                      dest="report_indexes",
                      default=False,
                      help="reports if a table has neither UNIQUE indexes nor"
                      " a PRIMARY key")

    # Add verbosity mode
    add_verbosity(parser, False)

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

    # Check mandatory option: --server.
    if not opt.server:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt="--server"))

    # Check security settings
    check_password_security(opt, args)

    # Check to make sure at least one table specified.
    if len(args) == 0:
        parser.error("You must specify at least one table or database to "
                     "check.")

    # Parse source connection values
    try:
        conn_options = get_ssl_dict(opt)
        source_values = parse_connection(opt.server, options=conn_options)
    except FormatError:
        _, err, _ = sys.exc_info()
コード例 #8
0
    opt, args = parser.parse_args()

    # Check security settings
    check_password_security(opt, args)

    # option --master is required (mandatory)
    if not opt.master:
        default_val = 'root@localhost:3306'
        print(
            WARN_OPT_USING_DEFAULT.format(default=default_val, opt='--master'))
        # Print the WARNING to force determinism if a parser error occurs.
        sys.stdout.flush()

    # option --slave is required (mandatory)
    if not opt.slave:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt='--slave'))

    # option --rpl-user is required (mandatory)
    if not opt.rpl_user:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt="--rpl-user"))

    # Parse source connection values
    try:
        m_values = parse_connection(opt.master, None, opt)
    except FormatError:
        _, err, _ = sys.exc_info()
        parser.error("Master connection values invalid: {0}.".format(err))
    except UtilError:
        _, err, _ = sys.exc_info()
        parser.error("Master connection values invalid: {0}."
                     "".format(err.errmsg))
コード例 #9
0
                      help="Skip the binary/relay flush operation to reload "
                      "server's cache after moving files.")

    # Parse the options and arguments.
    opt, args = parser.parse_args()

    # The --server and --binlog-dir options cannot be used simultaneously
    # (only one).
    if opt.server and opt.binlog_dir:
        parser.error(
            PARSE_ERR_OPTS_EXCLD.format(opt1='--server', opt2='--binlog-dir'))

    # Check mandatory options: --server or --binlog-dir.
    if not opt.server and not opt.binlog_dir:
        parser.error(
            PARSE_ERR_OPTS_REQ.format(opt="--server' or '--binlog-dir"))

    # Check specified server.
    server_val = None
    if opt.server:
        # Parse server connection values
        try:
            server_val = parse_connection(opt.server, None, opt)
        except FormatError:
            _, err, _ = sys.exc_info()
            parser.error("Server connection values invalid: %s." % err)
        except UtilError:
            _, err, _ = sys.exc_info()
            parser.error("Server connection values invalid: %s." % err.errmsg)

    # Check specified source binlog directory.
コード例 #10
0
                      dest="skip_flush_binlogs", default=False,
                      help="Skip the binary/relay flush operation to reload "
                           "server's cache after moving files.")

    # Parse the options and arguments.
    opt, args = parser.parse_args()

    # The --server and --binlog-dir options cannot be used simultaneously
    # (only one).
    if opt.server and opt.binlog_dir:
        parser.error(PARSE_ERR_OPTS_EXCLD.format(opt1='--server',
                                                 opt2='--binlog-dir'))

    # Check mandatory options: --server or --binlog-dir.
    if not opt.server and not opt.binlog_dir:
        parser.error(PARSE_ERR_OPTS_REQ.format(
            opt="--server' or '--binlog-dir"))

    # Check specified server.
    server_val = None
    if opt.server:
        # Parse server connection values
        try:
            server_val = parse_connection(opt.server, None, opt)
        except FormatError:
            _, err, _ = sys.exc_info()
            parser.error("Server connection values invalid: %s." % err)
        except UtilError:
            _, err, _ = sys.exc_info()
            parser.error("Server connection values invalid: %s." % err.errmsg)

    # Check specified source binlog directory.
コード例 #11
0
        "span_key_size": opt.span_key_size,
        "skip_table_opts": opt.skip_tbl_opts,
        "charset": opt.charset,
        "use_indexes": db_idxes_l,
        "compact": opt.compact,
        "all": opt.all,
        "use_regexp": opt.use_regexp,
        "exclude_patterns": exclude_list,
    }

    # Add ssl options to options instead of connection.
    options.update(get_ssl_dict(opt))

    # Check server options.
    if not opt.server1:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt='--server1'))
    if opt.all and not opt.server2:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt='--server2'))

    # Parse server connection values
    server1_values = None
    server2_values = None
    try:
        server1_values = parse_connection(opt.server1, None, options)
    except FormatError:
        _, err, _ = sys.exc_info()
        parser.error("Server1 connection values invalid: %s." % err)
    except UtilError:
        _, err, _ = sys.exc_info()
        parser.error("Server1 connection values invalid: %s." % err.errmsg)
コード例 #12
0
                           "for each slave but without effectively skipping "
                           "them (injecting empty transactions) - useful to "
                           "test the transactions that would be skipped.")

    # Add verbosity option (no --quite option).
    add_verbosity(parser, False)

    # Parse the options and arguments.
    opt, args = parser.parse_args()

    # Check security settings
    check_password_security(opt, args)

    # Options --gtid-set and --slaves options are required.
    if not opt.gtid_set:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt='--gtid-set'))
    if not opt.slaves:
        parser.error(PARSE_ERR_OPTS_REQ.format(opt='--slaves'))

    # Check GTID set format.
    check_gtid_set_format(parser, opt.gtid_set)

    # Parse the connection parameters for the slaves (no candidates).
    try:
        opt.master = None  # No master option available, set value to None.
        _, slaves_val, _ = parse_topology_connections(
            opt, parse_candidates=False
        )
    except UtilRplError:
        _, err, _ = sys.exc_info()
        sys.stderr.write("ERROR: {0}\n".format(err.errmsg))