if opt.master_log_pos >= 0 and opt.master_log_file is None:
        parser.error("You must specify a master log file to use the master " "log file position option.")

    if (opt.master_log_pos >= 0 or (opt.master_log_file is not None)) and opt.from_beginning:
        parser.error(
            "The --start-from-beginning option is not valid in "
            "combination with --master-log-file or --master-log-pos."
        )

    # Create dictionary of options
    options = {
        "verbosity": opt.verbosity,
        "pedantic": opt.pedantic,
        "quiet": False,
        "master_log_file": opt.master_log_file,
        "master_log_pos": opt.master_log_pos,
        "from_beginning": opt.from_beginning,
    }

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

    try:
        setup_replication(m_values, s_values, opt.rpl_user, options, opt.test_db)
    except UtilError:
        _, e, _ = sys.exc_info()
        print("ERROR: {0}".format(e.errmsg))
        sys.exit(1)

    sys.exit()
示例#2
0
    # 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()
        parser.error("Server connection values invalid: %s." % err)
    except UtilError:
        _, err, _ = sys.exc_info()
        parser.error("Server connection values invalid: %s." % err.errmsg)

    # Check best, worst for validity
    best = None
    if opt.best is not None:
        try:
            best = int(opt.best)
        except ValueError:
            best = -1
        if master_val:
            for slave_val in slaves_val:
                if check_hostname_alias(master_val, slave_val):
                    err = ERROR_MASTER_IN_SLAVES.format(
                        master_host=master_val['host'],
                        master_port=master_val['port'],
                        slaves_candidates="slaves",
                        slave_host=slave_val['host'],
                        slave_port=slave_val['port'],
                    )
                    parser.error(err)

    # Parse source connection values of --server
    if opt.server:
        try:
            ssl_opts = get_ssl_dict(opt)
            server_val = parse_connection(opt.server, None, ssl_opts)
        except FormatError as err:
            parser.error("ERROR: {0}\n".format(err.errmsg))
        except UtilError as err:
            parser.error("ERROR: {0}\n".format(err.errmsg))

    # Create dictionary of options
    options = {
        'discover': opt.discover,
        'verbosity': 0 if opt.verbosity is None else opt.verbosity,
        'to_binlog_name': opt.binlog,
        'dry_run': opt.dry_run,
    }

    try:
示例#4
0
        parser.error("You should not include servers in the call if you are "
                     "using the --sql option")

    # If no option was supplied, we print the processes by default
    if len(options.actions) == 0:
        options.actions.append(PRINT_PROCESS)

    try:
        command = ProcessGrep(options.matches,
                              options.actions,
                              options.use_regexp,
                              age=options.age)
        if options.print_sql:
            print(command.sql(options.sql_body).strip())
        else:
            ssl_opts = get_ssl_dict(options)
            command.execute(options.server,
                            format=options.format,
                            charset=options.charset,
                            ssl_opts=ssl_opts)
    except EmptyResultError:
        _, details, _ = sys.exc_info()
        sys.stderr.write("No matches\n")
        sys.exit(1)
    except:
        _, details, _ = sys.exc_info()
        sys.stderr.write('ERROR: {0}\n'.format(details))
        sys.exit(2)

    sys.exit()
        'force': opt.force,
    }

    # Expand user paths and resolve relative paths
    if opt.new_data and opt.new_data[0] == '~':
        options['new_data'] = os.path.expanduser(opt.new_data)
    if opt.basedir and opt.basedir[0] == '~':
        options['basedir'] = os.path.expanduser(opt.basedir)
    if opt.new_data and opt.new_data[0] == '.':
        options['new_data'] = os.path.abspath(opt.new_data)
    if opt.basedir and opt.basedir[0] == '.':
        options['basedir'] = os.path.abspath(opt.basedir)

    # Parse source connection values if we have a running server
    if opt.basedir is None:
        conn_options = get_ssl_dict(opt)
        try:
            conn = parse_connection(opt.server, options=conn_options)

            # Now check for local server
            server = Server({'conn_info': conn})
            if not server.is_alias('localhost'):
                parser.error("Server to be cloned must be running on the same "
                             "machine as mysqlserverclone.")
        except exception.FormatError:
            _, err, _ = sys.exc_info()
            parser.error("Server connection values invalid: %s." % err)
        except exception.UtilError:
            _, err, _ = sys.exc_info()
            parser.error("Server connection values invalid: %s." % err.errmsg)
    else:
示例#6
0
    # supplied if --sql is not used.
    if options.print_sql:
        if options.server is not None and len(options.server) > 0:
            parser.error(_NO_SERVERS_ALLOWED_MSG)
    else:
        if options.server is None or len(options.server) == 0:
            parser.error(_AT_LEAST_ONE_SERVER_MSG)

    object_types = re.split(r"\s*,\s*", options.object_types)

    try:
        command = ObjectGrep(options.pattern, options.database_pattern,
                             object_types, options.check_body,
                             options.use_regexp)
        if options.print_sql:
            print(command.sql())
        else:
            ssl_opts = get_ssl_dict(options)
            command.execute(options.server, format=options.format,
                            charset=options.charset, ssl_opts=ssl_opts)
    except UtilError:
        _, err, _ = sys.exc_info()
        sys.stderr.write("ERROR: {0}\n".format(err.errmsg))
        sys.exit(1)
    except:
        _, details, _ = sys.exc_info()
        sys.stderr.write("ERROR: {0}\n".format(details))
        sys.exit(1)

    sys.exit()