def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. file_chk_list -> contains the options which will have files included. file_crt_list -> contains options which require files to be created. func_dict -> dictionary list for the function calls or other options. opt_con_req_list -> contains the options that require other options. opt_def_dict -> contains options with their default values. opt_or_dict_list -> contains list of options that are OR and required. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d", "-p"] file_chk_list = ["-o"] file_crt_list = ["-o"] func_dict = {"-A": ["-C", "-S", "-E", "-T", "-O"], "-B": rpt_mst_log, "-D": rpt_slv_log, "-C": chk_mst_log, "-S": chk_slv_thr, "-E": chk_slv_err, "-T": chk_slv_time, "-O": chk_slv_other} opt_con_req_list = {"-b": ["-m"], "-u": ["-t"], "-A": ["-s"], "-B": ["-c"], "-C": ["-c", "-s"], "-D": ["-s"], "-E": ["-s"], "-O": ["-s"], "-T": ["-c", "-s"]} opt_def_dict = {"-b": "sysmon:mysql_rep_lag"} opt_multi_list = ["-u", "-t"] opt_or_dict_list = {"-c": ["-s"]} opt_req_list = ["-d"] opt_val_list = ["-d", "-c", "-p", "-s", "-o", "-b", "-m", "-u", "-t", "-y"] # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list, opt_def_dict, multi_val=opt_multi_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and arg_parser.arg_req_or_lst(args_array, opt_or_dict_list) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list) \ and not arg_parser.arg_file_chk(args_array, file_chk_list, file_crt_list): try: proglock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict) del proglock except gen_class.SingleInstanceException: print("WARNING: lock in place for mysql_rep_admin with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. func_dict -> dictionary list for the function calls or other options. opt_con_req_list -> contains the options that require other options. xor_noreq_list -> contains options that are XOR, but are not required. ord_prec_array -> holds options in order of precedence to be executed. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d", "-l", "-o"] func_dict = { "-F": flush_log_bkp, "-K": missing_log, "-M": bkp_log_miss, "-A": bkp_log_all, "-S": purge_log_day, "-R": purge_log_name } opt_con_req_list = { "-F": ["-o", "-l"], "-M": ["-o", "-l"], "-A": ["-o", "-l"], "-K": ["-o"] } xor_noreq_list = {"-S": "-R", "-M": "-A"} ord_prec_list = ["-F", "-K", "-M", "-A", "-S", "-R"] opt_req_list = ["-c", "-d"] opt_val_list = ["-c", "-d", "-l", "-o", "-R", "-S", "-y"] # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_noreq_xor(args_array, xor_noreq_list) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list): try: prog_lock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict, ord_prec_list) del prog_lock except gen_class.SingleInstanceException: print("WARNING: lock in place for mysql_binlog with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. ign_db_tbl -> contains list of databases and tables to be ignored. opt_con_req_list -> contains the options that require other options. opt_multi_list -> contains the options that will have multiple values. opt_req_list -> contains the options that are required for the program. opt_req_xor_list -> contains a list of options that are required XOR. opt_val_list -> contains options which require values. sys_ign_db -> contains a list of system databases to be ignored. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d"] ign_db_tbl = { "mysql": [ "innodb_index_stats", "innodb_table_stats", "slave_master_info", "slave_relay_log_info", "slave_worker_info" ] } opt_con_req_list = {"-t": ["-B"], "-s": ["-e"], "-u": ["-e"]} opt_multi_list = ["-B", "-e", "-s", "-t"] opt_req_list = ["-r", "-c", "-d"] opt_req_xor_list = {"-A": "-B"} opt_val_list = ["-r", "-c", "-d", "-e", "-s", "-y"] sys_ign_db = ["performance_schema", "information_schema"] # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list, multi_val=opt_multi_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and arg_parser.arg_req_xor(args_array, opt_req_xor_list) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list): try: prog_lock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, sys_ign_db, ign_db_tbl=ign_db_tbl) del prog_lock except gen_class.SingleInstanceException: print("WARNING: lock in place for mysql_rep_cmp with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. file_chk_list -> contains the options which will have files included. func_dict -> dictionary list for the function calls or other options. opt_arg_list-> contains list of optional arguments for command line. opt_arg_rep -> contains list of replaceable arguments for command line. opt_con_req_list -> contains the options that require other options. opt_multi_list -> contains the options that will have multiple values. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. opt_xor_dict -> contains options which are XOR with its values. xor_noreq_list -> contains options that are XOR, but are not required. Arguments: (input) argv -> Arguments from the command line. """ dir_chk_list = ["-d", "-p"] file_chk_list = ["-f"] func_dict = {"-I": insert_doc, "-D": delete_docs, "-T": truncate_coll} opt_arg_list = {"-a": "--authenticationDatabase=", "-b": "--db=", "-t": "--collection="} opt_arg_rep = {"-f": "--file="} opt_con_req_list = {"-k1": ["-l1"]} opt_multi_list = ["-f", "-l1", "-l2", "-l3", "-l4", "-l5"] opt_req_list = ["-b", "-c", "-d", "-t"] opt_val_list = ["-a", "-b", "-c", "-d", "-f", "-k1", "-l1", "-p", "-t", "-k2", "-l2", "-k3", "-l3", "-k4", "-l4", "-k5", "-l5"] opt_xor_dict = {"-D": ["-I", "-T"], "-I": ["-D", "-T"], "-T": ["-D", "-I"]} xor_noreq_list = {"-k1": "-f"} # Process argument list from command line. args_array = arg_parser.arg_parse2(sys.argv, opt_val_list, multi_val=opt_multi_list) # Remove dupe files. if "-f" in args_array: args_array["-f"] = gen_libs.rm_dup_list(args_array["-f"]) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and arg_parser.arg_noreq_xor(args_array, xor_noreq_list) \ and not arg_parser.arg_file_chk(args_array, file_chk_list): run_program(args_array, func_dict, opt_arg=opt_arg_list, opt_rep=opt_arg_rep)
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. func_dict -> dictionary list for the function calls or other options. opt_arg_list -> contains arguments to add to command line by default. opt_con_req_list -> contains the options that require other options. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. opt_valid_val -> contains list of types of values to be validated. opt_xor_dict -> contains options which are XOR with its values. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d", "-p"] func_dict = {"-L": fetch_log_pos, "-D": fetch_log_entries, "-R": load_log} opt_arg_list = ["--force-read", "--read-from-remote-server"] opt_con_req_list = {"-R": ["-e"]} opt_req_list = ["-c", "-d"] opt_val_list = ["-c", "-e", "-d", "-f", "-g", "-p", "-s", "-t", "-y"] opt_valid_val = { "-s": gen_libs.validate_date, "-t": gen_libs.validate_date } opt_xor_dict = {"-L": ["-D", "-R"], "-D": ["-L", "-R"], "-R": ["-D", "-L"]} # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list) \ and arg_parser.arg_validate(args_array, opt_valid_val) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list): try: prog_lock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict, opt_arg_list) del prog_lock except gen_class.SingleInstanceException: print( "WARNING: lock in place for mysql_log_admin with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. file_chk_list -> contains the options which will have files included. file_crt_list -> contains options which require files to be created. func_dict -> dictionary list for the function calls or other options. opt_con_req_list -> contains the options that require other options. opt_def_dict -> contains options with their default values. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d"] file_chk_list = ["-o"] file_crt_list = ["-o"] func_dict = { "-L": chk_rep_lag, "-M": fetch_members, "-S": chk_rep_stat, "-P": fetch_priority, "-T": prt_rep_stat, "-N": node_chk } opt_con_req_list = {"-i": ["-m"], "-s": ["-e"]} opt_def_dict = {"-j": False, "-i": "sysmon:mongo_rep_lag"} opt_multi_list = ["-e", "-s"] opt_req_list = ["-c", "-d"] opt_val_list = ["-c", "-d", "-i", "-m", "-o", "-e", "-s"] # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list, opt_def_dict, multi_val=opt_multi_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list) \ and not arg_parser.arg_file_chk(args_array, file_chk_list, file_crt_list): run_program(args_array, func_dict)
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. file_chk_list -> contains the options which will have files included. file_crt_list -> contains options which require files to be created. func_dict -> dictionary list for the function calls or other options. opt_def_dict -> contains options with their default values. opt_con_req_list -> contains the options that require other options. opt_multi_list -> contains the options that will have multiple values. opt_val_list -> contains options which require values. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d"] file_chk_list = ["-o"] file_crt_list = ["-o"] func_dict = {"-L": list_ins_pkg, "-U": list_upd_pkg, "-R": list_repo} opt_def_dict = {"-i": "sysmon:server_pkgs"} opt_con_req_list = {"-i": ["-c", "-d"], "-s": ["-e"], "-u": ["-e"]} opt_multi_list = ["-e", "-s"] opt_val_list = ["-c", "-d", "-i", "-o", "-e", "-s", "-y"] # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list, opt_def_dict, multi_val=opt_multi_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list) \ and not arg_parser.arg_file_chk(args_array, file_chk_list, file_crt_list): try: proglock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict) del proglock except gen_class.SingleInstanceException: print("WARNING: Lock in place for package_admin with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. file_chk_list -> contains the options which will have files included. file_crt_list -> contains options which require files to be created. func_dict -> dictionary list for the function calls or other options. opt_arg_list -> contains optional arguments for the command line. opt_con_req_list -> contains the options that require other options. opt_def_dict -> contains options with their default values. opt_def_dict2 -> default values for "-S" and "-j" options combination. opt_def_dict3 -> default values for "-i" setup. opt_multi_list -> contains the options that will have multiple values. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. req_arg_list -> contains arguments to add to command line by default. Arguments: (input) argv -> Arguments from the command line. """ global AUTH_DB cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d", "-p"] file_chk_list = ["-o"] file_crt_list = ["-o"] func_dict = {"-S": mongo_stat} opt_arg_list = {"-j": "--json", "-n": "-n="} opt_con_req_list = {"-i": ["-m", "-j"], "-s": ["-t"], "-u": ["-t"]} opt_def_dict = {"-i": "sysmon:mongo_perf", "-n": "1", "-b": "1"} opt_def_dict2 = {"-n": "1", "-b": "1"} opt_def_dict3 = {"-j": True} opt_multi_list = ["-s", "-t"] opt_req_list = ["-c", "-d"] opt_val_list = ["-c", "-d", "-b", "-i", "-m", "-n", "-o", "-p", "-s", "-t"] req_arg_list = [AUTH_DB] # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list, opt_def_dict, multi_val=opt_multi_list) # Add default arguments for certain argument combinations. if "-i" in args_array.keys() and "-j" not in args_array.keys(): args_array = arg_parser.arg_add_def(args_array, opt_def_dict3) if "-S" in args_array.keys() and "-j" in args_array.keys(): args_array = arg_parser.arg_add_def(args_array, opt_def_dict2) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list) \ and not arg_parser.arg_file_chk(args_array, file_chk_list, file_crt_list): try: proglock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict, req_arg=req_arg_list, opt_arg=opt_arg_list) del proglock except gen_class.SingleInstanceException: print("WARNING: lock in place for mongo_perf with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. func_dict -> dictionary list for the function calls or other options. opt_con_req_list -> contains the options that require other options. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. opt_xor_dict -> contains dict with key that is xor with it's values. slv_key -> contains dict with keys to be converted to data types. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d"] func_dict = {"-M": move_slave, "-R": move_slave, "-S": move_slave_up} opt_con_req_list = { "-M": ["-m", "-n"], "-R": ["-m", "-n"], "-S": ["-m", "-n"] } opt_req_list = ["-c", "-d", "-s"] opt_val_list = ["-c", "-d", "-m", "-n", "-s", "-y"] opt_xor_dict = {"-M": ["-R", "-S"], "-R": ["-M", "-S"], "-S": ["-M", "-R"]} slv_key = { "sid": "int", "port": "int", "cfg_file": "None", "ssl_client_ca": "None", "ssl_ca_path": "None", "ssl_client_key": "None", "ssl_client_cert": "None", "ssl_client_flag": "int", "ssl_disabled": "bool", "ssl_verify_id": "bool", "ssl_verify_cert": "bool" } # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list): try: proglock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict, slv_key=slv_key) del proglock except gen_class.SingleInstanceException: print( "WARNING: lock in place for mysql_rep_change with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: arg_req_dict -> contains link between config entry and required option. dir_chk_list -> contains options which will be directories. dir_crt_list -> contain options that require directory to be created. func_dict -> dictionary list for the function calls or other options. opt_arg_list -> contains optional arguments for the command line. opt_con_req_list -> contains the options that require other options. opt_multi_list -> contains the options that will have multiple values. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. xor_noreq_list -> contains options that are XOR, but are not required. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) arg_req_dict = {"auth_db": "--authenticationDatabase="} dir_chk_list = ["-d", "-o", "-p"] dir_crt_list = ["-o"] func_dict = {"-A": sync_cp_dump, "-M": mongo_dump} opt_arg_list = {"-l": "--oplog", "-z": "--gzip", "-b": "--db=", "-o": "--out=", "-q": "--quiet", "-r": "--dumpDbUsersAndRoles", "-t": "--collection="} opt_con_req_list = {"-A": ["-o"], "-r": ["-b"], "-t": ["-b"], "-s": ["-e"]} opt_multi_list = ["-e", "-s"] opt_req_list = ["-c", "-d", "-o"] opt_req_xor_list = {"-A": "-M"} opt_val_list = ["-b", "-c", "-d", "-o", "-p", "-t", "-e", "-s", "-y"] xor_noreq_list = {"-l": "-b"} # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list, multi_val=opt_multi_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_req_xor(args_array, opt_req_xor_list) \ and arg_parser.arg_noreq_xor(args_array, xor_noreq_list) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list, dir_crt_list): try: prog_lock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict, opt_arg=opt_arg_list, arg_req_dict=arg_req_dict) del prog_lock except gen_class.SingleInstanceException: print("WARNING: Lock in place for mongo_db_dump with id: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. file_chk_list -> contains the options which will have files included. file_crt_list -> contains options which require files to be created. func_dict -> dictionary list for the function calls or other options. opt_def_dict -> contains options with their default values. opt_con_req_list -> contains the options that require other options. opt_multi_list -> contains the options that will have multiple values. opt_req_list -> contains options that are required for the program. opt_val_list -> contains options which require values. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d"] file_chk_list = ["-o"] file_crt_list = ["-o"] func_dict = {"-S": mysql_stat} opt_def_dict = {"-i": "sysmon:mysql_perf", "-n": "1", "-b": "1"} opt_con_req_list = {"-i": ["-m", "-j"], "-s": ["-t"], "-u": ["-t"]} opt_multi_list = ["-s", "-t"] opt_req_list = ["-c", "-d", "-b", "-n"] opt_val_list = ["-c", "-d", "-b", "-i", "-m", "-n", "-o", "-s", "-t", "-y"] # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list, opt_def_dict, multi_val=opt_multi_list) # Add required default options and values to argument dictionary. args_array = arg_parser.arg_add_def(args_array, opt_def_dict, opt_req_list) if not gen_libs.is_pos_int(int(args_array["-b"])): args_array["-b"] = "1" if not gen_libs.is_pos_int(int(args_array["-n"])): args_array["-n"] = "1" if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list) \ and not arg_parser.arg_file_chk(args_array, file_chk_list, file_crt_list): try: proglock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict) del proglock except gen_class.SingleInstanceException: print("WARNING: lock in place for mysql_perf with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. file_chk_list -> contains the options which will have files included. file_crt_list -> contains options which require files to be created. func_dict -> dictionary list for the function calls or other options. opt_con_req_list -> contains the options that require other options. opt_def_dict -> contains options with their default values. opt_multi_list -> contains the options that will have multiple values. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. opt_xor_dict -> contains options which are XOR with its values. sys_dbs -> contains a list of system databases that will be skipped over for some functions. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d"] file_chk_list = ["-o"] file_crt_list = ["-o"] func_dict = {"-A": analyze, "-C": check, "-D": optimize, "-S": checksum, "-M": status, "-L": listdbs} opt_con_req_list = {"-i": ["-m"], "-s": ["-e"], "-u": ["-e"]} opt_def_dict = {"-t": None, "-A": [], "-C": [], "-D": [], "-S": [], "-i": "sysmon:mysql_db_status"} opt_multi_list = ["-A", "-C", "-D", "-S", "-t", "-e", "-s"] opt_req_list = ["-c", "-d"] opt_val_list = ["-c", "-d", "-t", "-A", "-C", "-D", "-S", "-i", "-m", "-o", "-e", "-s", "-y"] opt_xor_dict = {"-A": ["-C", "-D", "-M", "-S", "-L"], "-C": ["-A", "-D", "-M", "-S", "-L"], "-D": ["-A", "-C", "-M", "-S", "-L"], "-S": ["-A", "-C", "-D", "-M", "-L"], "-M": ["-A", "-C", "-D", "-S", "-L"], "-L": ["-A", "-C", "-D", "-S", "-M"]} sys_dbs = ["performance_schema", "information_schema", "mysql", "sys"] # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list, opt_def_dict, multi_val=opt_multi_list) # Set JSON format for certain option settings if "-i" in args_array.keys() and "-m" in args_array.keys() \ and "-j" not in args_array.keys(): args_array["-j"] = True if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list) \ and not arg_parser.arg_file_chk(args_array, file_chk_list, file_crt_list): try: proglock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict, sys_dbs=sys_dbs, multi_val=opt_multi_list) del proglock except gen_class.SingleInstanceException: print("WARNING: lock in place for mysql_db_admin with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. file_chk_list -> contains the options which will have files included. file_crt_list -> contains options which require files to be created. func_dict -> dictionary list for the function calls or other options. opt_arg_list -> contains optional arguments for the command line. opt_con_req_dict -> contains options requiring one or more options. opt_con_req_list -> contains the options that require other options. opt_def_dict -> contains options with their default values. opt_multi_list -> contains the options that will have multiple values. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. opt_valid_val -> contains a list of valid values for options. opt_xor_dict -> contains dict with key that is xor with it's values. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d", "-n"] file_chk_list = ["-o"] file_crt_list = ["-o"] func_dict = {"-C": defrag, "-D": dbcc, "-R": repair_db, "-M": status, "-L": rotate, "-G": get_log} opt_con_req_dict = {"-j": ["-M", "-G"]} opt_con_req_list = {"-i": ["-m"], "-n": ["-L"], "-l": ["-G"], "-f": ["-D"], "-s": ["-e"]} opt_def_dict = {"-C": [], "-D": [], "-R": [], "-G": "global", "-i": "sysmon:mongo_db_status"} opt_multi_list = ["-C", "-D", "-R", "-t", "-e", "-s"] opt_req_list = ["-c", "-d"] opt_val_list = ["-c", "-d", "-t", "-C", "-D", "-R", "-i", "-m", "-o", "-G", "-n", "-e", "-s", "-y"] opt_valid_val = {"-G": ["global", "rs", "startupWarnings"]} opt_xor_dict = {"-R": ["-C", "-M", "-D"], "-C": ["-D", "-M", "-R"], "-D": ["-C", "-M", "-R"], "-M": ["-C", "-D", "-R", "-G"], "-G": ["-M"], "-j": ["-l"], "-l": ["-j"]} # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list, opt_def_dict, multi_val=opt_multi_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_valid_val(args_array, opt_valid_val) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and arg_parser.arg_cond_req_or(args_array, opt_con_req_dict) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list) \ and not arg_parser.arg_file_chk(args_array, file_chk_list, file_crt_list): try: prog_lock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict) del prog_lock except gen_class.SingleInstanceException: print("WARNING: lock in place for mongo_db_admin with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. opt_arg_list -> contains arguments to add to command line by default. opt_con_req_list -> contains the options that require other options. opt_dump_list -> contains optional arguments for mysqldump command. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. req_rep_cfg -> contains replication config settings got master/slave. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d", "-p"] opt_arg_list = [ "--single-transaction", "--all-databases", "--triggers", "--routines", "--events", "--ignore-table=mysql.event" ] opt_con_req_list = {"-r": ["-n"]} opt_dump_list = {"-r": "--set-gtid-purged=OFF"} opt_req_list = ["-c", "-t", "-d"] opt_val_list = ["-c", "-t", "-d", "-p", "-y"] req_rep_cfg = { "master": { "log_bin": "ON", "sync_binlog": "1", "innodb_flush_log_at_trx_commit": "1", "innodb_support_xa": "ON", "binlog_format": "ROW" }, "slave": { "log_bin": "ON", "read_only": "ON", "log_slave_updates": "ON", "sync_master_info": "1", "sync_relay_log": "1", "sync_relay_log_info": "1" } } # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list): try: proglock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, req_rep_cfg, opt_arg_list, opt_dump_list=opt_dump_list) del proglock except gen_class.SingleInstanceException: print("WARNING: lock in place for mysql_clone with id of: %s" % (args_array.get("-y", "")))