# Add the --slaves option. add_slaves_option(parser) # Add verbosity add_verbosity(parser, quiet=False) # Now we process the rest of the arguments. opt, args = parser.parse_args() server_val = None master_val = None slaves_val = None if opt.server and opt.master: parser.error(PARSE_ERR_OPTS_EXCLD.format(opt1="--server", opt2="--master")) if opt.master is None and opt.slaves: parser.error(PARSE_ERR_OPT_REQ_OPT.format(opt="--slaves", opts="--master")) 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",
# Parse the options and arguments. opt, args = parser.parse_args() # Check security settings check_password_security(opt, args) # At least one of the options --discover-slaves-login or --slaves is # required. if not opt.discover and not opt.slaves: parser.error(PARSE_ERR_SLAVE_DISCO_REQ) # The --discover-slaves-login and --slaves options cannot be used # simultaneously (only one). if opt.discover and opt.slaves: parser.error(PARSE_ERR_OPTS_EXCLD.format(opt1="--discover-slaves-login", opt2="--slaves")) if opt.discover and not opt.master: parser.error(PARSE_ERR_OPT_REQ_OPT.format(opt="--discover-slaves-login", opts="--master")) # Check timeout values, must be greater than zero. if opt.rpl_timeout < 0: parser.error(PARSE_ERR_OPT_REQ_NON_NEGATIVE_VALUE.format(opt="--rpl-timeout")) if opt.checksum_timeout < 0: parser.error(PARSE_ERR_OPT_REQ_NON_NEGATIVE_VALUE.format(opt="--checksum-timeout")) # Check interval value, must be greater than zero. if opt.interval < 1: parser.error(PARSE_ERR_OPT_REQ_GREATER_VALUE.format(opt="--interval", val="zero")) # Check slaves list (master cannot be included in slaves list).
# Add option to skip the flush binary/relay logs operation. parser.add_option("--skip-flush-binlogs", action="store_true", 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)
"yyyy-mm-ddThh:mm:ss or yyyy-mm-dd, or an integer " "for the elapsed days.") # Add option to skip the flush binary/relay logs operation. parser.add_option("--skip-flush-binlogs", action="store_true", 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)
# Parse the options and arguments. opt, args = parser.parse_args() # Check security settings check_password_security(opt, args) # At least one of the options --discover-slaves-login or --slaves is # required. if not opt.discover and not opt.slaves: parser.error(PARSE_ERR_SLAVE_DISCO_REQ) # The --discover-slaves-login and --slaves options cannot be used # simultaneously (only one). if opt.discover and opt.slaves: parser.error( PARSE_ERR_OPTS_EXCLD.format(opt1='--discover-slaves-login', opt2='--slaves')) if opt.discover and not opt.master: parser.error(PARSE_ERR_DISCO_REQ_MASTER) # Check timeout values, must be greater than zero. if opt.rpl_timeout < 0: parser.error( PARSE_ERR_OPT_REQ_NON_NEGATIVE_VALUE.format(opt='--rpl-timeout')) if opt.checksum_timeout < 0: parser.error( PARSE_ERR_OPT_REQ_NON_NEGATIVE_VALUE.format( opt='--checksum-timeout')) # Check interval value, must be greater than zero. if opt.interval < 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.") command = args[0].lower() # At least one of the options --discover-slaves-login or --slaves is # required unless we are doing a health command. if not opt.discover and not opt.slaves and not command == 'health': parser.error(PARSE_ERR_SLAVE_DISCO_REQ) # --discover-slaves-login and --slaves cannot be used simultaneously # (only one) if opt.discover and opt.slaves: parser.error(PARSE_ERR_OPTS_EXCLD.format( opt1='--discover-slaves-login', 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.
# Add the --slaves option. add_slaves_option(parser) # Add verbosity add_verbosity(parser, quiet=False) # Now we process the rest of the arguments. opt, args = parser.parse_args() server_val = None master_val = None slaves_val = None if opt.server and opt.master: parser.error( PARSE_ERR_OPTS_EXCLD.format(opt1="--server", opt2="--master")) if opt.master is None and opt.slaves: parser.error( PARSE_ERR_OPT_REQ_OPT.format(opt="--slaves", opts="--master")) 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", )