# Setup log file logging.basicConfig(filename=opt.log_file, level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s', datefmt=_DATE_FORMAT) # Warn user about script threshold checking. if opt.script_threshold: print(SCRIPT_THRESHOLD_WARNING) # Check if script files exist and are executable and warn users if they # are not. script_opts = ['after', 'before', 'exec_fail', 'post_fail'] for key in script_opts: parameter_val = options[key] check_script_option(parser, parameter_val) # Check if the values specified for the --report-values option are valid. for report in opt.report_values.split(','): if report.lower() not in ("health", "gtid", "uuid"): parser.error("The value for the option --report-values is not " "valid: '{0}', the values allowed are 'health', " "'gitd' or 'uuid'".format(opt.report_values)) # Check the daemon options if opt.daemon: # Check if a POSIX system if os.name != "posix": parser.error("Running mysqlfailover with --daemon is only " "available for POSIX systems.")
'timeout': int(opt.timeout), 'demote': opt.demote, 'quiet': opt.quiet, 'logging': opt.log_file is not None, 'log_file': opt.log_file, 'no_health': opt.no_health, 'rpl_user': opt.rpl_user, 'script_threshold': opt.script_threshold, } # Check if script files exist and are executable and warn users if they # are not. script_opts = ['after', 'before'] for key in script_opts: parameter_val = options[key] check_script_option(parser, parameter_val) # Add ssl options to options instead of connection. options.update(get_ssl_dict(opt)) # If command = HEALTH, turn on --force if command == 'health' or command == 'gtid': options['force'] = True # Purge log file of old data if opt.log_file is not None and not purge_log(opt.log_file, opt.log_age): parser.error("Error purging log file.") # Warn user about script threshold checking. if opt.script_threshold: print(SCRIPT_THRESHOLD_WARNING)