def run_program(args_array, func_dict, **kwargs): """Function: run_program Description: Creates class instance and controls flow of the program. Set a program lock to prevent other instantiations from running. Arguments: (input) args_array -> Dict of command line options and values. (input) func_dict -> Dict of function calls and associated options. """ cmdline = gen_libs.get_inst(sys) args_array = dict(args_array) func_dict = dict(func_dict) cfg = gen_libs.load_module(args_array["-c"], args_array["-d"]) cfg.mongo = gen_libs.load_module(cfg.mongo_cfg, args_array["-d"]) cfg, status_flag, err_msg = validate_create_settings(cfg) if status_flag: log = gen_class.Logger(cfg.log_file, cfg.log_file, "INFO", "%(asctime)s %(levelname)s %(message)s", "%Y-%m-%dT%H:%M:%SZ") str_val = "=" * 80 log.log_info("%s:%s Initialized" % (cfg.host, cfg.exchange_name)) log.log_info("%s" % (str_val)) log.log_info("Exchange Name: %s" % (cfg.exchange_name)) log.log_info("Queue Configuration:") for queue in cfg.queue_list: log.log_info("\tQueue Name: %s, Routing Key: %s" % (queue["queue"], queue["routing_key"])) log.log_info("To Email: %s" % (cfg.to_line)) log.log_info("%s" % (str_val)) try: flavor_id = cfg.exchange_name prog_lock = gen_class.ProgramLock(cmdline.argv, flavor_id) # Intersect args_array & func_dict to find which functions to call. for opt in set(args_array.keys()) & set(func_dict.keys()): func_dict[opt](cfg, log, **kwargs) del prog_lock except gen_class.SingleInstanceException: log.log_warn("rmq_metadata lock in place for: %s" % (flavor_id)) log.log_close() else: print("Error: Problem in configuration file or directory setup.") print(err_msg)
def run_program(args_array, func_dict, **kwargs): """Function: run_program Description: Creates class instance(s) and controls flow of the program. Arguments: (input) args_array -> Dict of command line options and values. (input) func_dict -> Dictionary list of functions and options. """ mongo = None args_array = dict(args_array) func_dict = dict(func_dict) server = mysql_libs.create_instance(args_array["-c"], args_array["-d"], mysql_class.Server) server.connect(silent=True) if server.conn_msg and not args_array.get("-w", False): print("run_program: Error encountered on server(%s): %s" % (server.name, server.conn_msg)) elif not server.conn_msg: if args_array.get("-m", False): mongo = gen_libs.load_module(args_array["-m"], args_array["-d"]) # Call function(s) - intersection of command line and function dict. for opt in set(args_array.keys()) & set(func_dict.keys()): func_dict[opt](server, args_array, class_cfg=mongo, **kwargs) mysql_libs.disconnect(server)
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.base_dir = "test/integration" self.config_dir = os.path.join(self.base_dir, "config") self.config_name = "mongo" self.cfg = gen_libs.load_module(self.config_name, self.config_dir) self.mongo = mongo_class.Server( self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host, port=self.cfg.port, use_uri=self.cfg.use_uri, auth=self.cfg.auth, use_arg=self.cfg.use_arg, auth_db=self.cfg.auth_db, conf_file=self.cfg.conf_file, ssl_client_ca=self.cfg.ssl_client_ca, ssl_client_key=self.cfg.ssl_client_key, ssl_client_cert=self.cfg.ssl_client_cert, ssl_client_phrase=self.cfg.ssl_client_phrase) self.mongo.connect()
def __init__(self, cfg_file, cfg_dir, **kwargs): """Method: __init__ Description: Initialization of an instance of the SSH class. Arguments: (input) cfg_file -> Configuration file for the sftp connection. (input) cfg_dir -> Directory path containing configuration file. """ self.cfg_file = cfg_file self.cfg_dir = cfg_dir cfg = gen_libs.load_module(self.cfg_file, self.cfg_dir) self.username = cfg.username self.password = cfg.password self.host = cfg.host self.port = cfg.port self.log_file = cfg.log_file paramiko.util.log_to_file(self.log_file) self.ssh = paramiko.SSHClient() self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.is_connected = False self.sftp = None
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.base_dir = "test/integration/server_usage" self.test_path = os.path.join(os.getcwd(), self.base_dir) self.config_path = os.path.join(self.test_path, "config") self.cfg = gen_libs.load_module("configuration", self.config_path) self.args_array = {"-c": "configuration", "-d": self.config_path} svr = mongo_class.Server(self.cfg.name, self.cfg.user, self.cfg.passwd, host=self.cfg.host, port=self.cfg.port, auth=self.cfg.auth, conf_file=self.cfg.conf_file) svr.connect() if self.cfg.db in svr.fetch_dbs(): print("ERROR: Test environment not clean - database: %s exists" % (self.cfg.db)) cmds_gen.disconnect([svr]) self.skipTest("Pre-conditions not met.") cmds_gen.disconnect([svr])
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ global SKIP_PRINT self.base_dir = "test/integration/elastic_db_repo" self.test_path = os.path.join(os.getcwd(), self.base_dir) self.config_path = os.path.join(self.test_path, "config") self.cfg = gen_libs.load_module("elastic", self.config_path) self.argv_list = [ os.path.join(self.base_dir, "main.py"), "-c", "elastic", "-d", self.config_path ] self.repo_name = "TEST_INTR_REPO" self.repo_name2 = "TEST_INTR_REPO2" self.dump_name = "test_dump" self.repo_dir = os.path.join(self.cfg.log_repo_dir, self.repo_name) self.phy_repo_dir = os.path.join(self.cfg.phy_repo_dir, self.repo_name) self.els = None els = elastic_class.ElasticSearchRepo(self.cfg.host, self.cfg.port) if els.repo_dict: print("ERROR: Test environment not clean - repositories exist.") self.skipTest(SKIP_PRINT)
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.base_dir = "test/integration/elastic_class" self.test_path = os.path.join(os.getcwd(), self.base_dir) self.config_path = os.path.join(self.test_path, "config") self.cfg = gen_libs.load_module("elastic", self.config_path) self.repo_name = "TEST_INTR_REPO" self.repo_name2 = "TEST_INTR_REPO2" self.repo_dir = os.path.join(self.cfg.log_repo_dir, self.repo_name) self.repo_dir2 = os.path.join(self.cfg.log_repo_dir, self.repo_name2) self.phy_repo_dir = os.path.join(self.cfg.phy_repo_dir, self.repo_name) self.phy_repo_dir2 = os.path.join(self.cfg.phy_repo_dir, self.repo_name2) esr = elastic_class.ElasticSearchRepo(self.cfg.host, repo=self.repo_name, repo_dir=self.repo_dir) if esr.repo_dict: print("ERROR: Test environment not clean - repositories exist.") self.skipTest("Pre-conditions not met.")
def run_program(args_array, func_dict, **kwargs): """Function: run_program Description: Creates class instance and controls flow of the program. Create a program lock to prevent other instantiations from running. Arguments: (input) args_array -> Dict of command line options and values. (input) func_dict -> Dictionary list of functions and options. (input) **kwargs: status_call -> Contains class method names for the '-D' option. check_call -> Contains class method names for the '-C' option. """ cmdline = gen_libs.get_inst(sys) args_array = dict(args_array) func_dict = dict(func_dict) cfg = gen_libs.load_module(args_array["-c"], args_array["-d"]) try: prog_lock = gen_class.ProgramLock(cmdline.argv, cfg.host) # Intersect args_array & func_dict to find which functions to call. for opt in set(args_array.keys()) & set(func_dict.keys()): els = elastic_class.ElasticSearchStatus(cfg.host, cfg.port, **kwargs) func_dict[opt](els, args_array=args_array, cfg=cfg, **kwargs) del prog_lock except gen_class.SingleInstanceException: print("Warning: elastic_db_admin lock in place for: %s" % (cfg.host))
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.base_dir = "test/integration" self.config_dir = os.path.join(self.base_dir, "config") self.config_name = "mongo" self.cfg = gen_libs.load_module(self.config_name, self.config_dir) self.mongo = mongo_class.Server( self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host, port=self.cfg.port, auth=self.cfg.auth, conf_file=self.cfg.conf_file, auth_db=self.cfg.auth_db, use_arg=self.cfg.use_arg, use_uri=self.cfg.use_uri, ssl_client_ca=self.cfg.ssl_client_ca, ssl_client_key=self.cfg.ssl_client_key, ssl_client_cert=self.cfg.ssl_client_cert, ssl_client_phrase=self.cfg.ssl_client_phrase) self.cmd_line = ["program_name"] self.ssl = "--ssl" self.ssl_ca = "--sslCAFile=" self.ssl_key = "--sslPEMKeyFile=" self.ssl_phrase = "--sslPEMKeyPass" self.ca_file = "CAFile" self.key_file = "KeyFile" self.key_phrase = "KeyPhraseFile"
def run_program(args_array, func_dict, **kwargs): """Function: run_program Description: Creates class instance and controls flow of the program. Create a program lock to prevent other instantiations from running. Arguments: (input) args_array -> Dict of command line options and values. (input) func_dict -> Dictionary list of functions and options. """ cmdline = gen_libs.get_inst(sys) args_array = dict(args_array) func_dict = dict(func_dict) cfg = gen_libs.load_module(args_array["-c"], args_array["-d"]) hostname = socket.gethostname().strip().split(".")[0] try: prog_lock = gen_class.ProgramLock(cmdline.argv, hostname) # Find which functions to call. for opt in set(args_array.keys()) & set(func_dict.keys()): els = elastic_class.ElasticSearchRepo(cfg.host, cfg.port, repo=args_array.get("-L")) func_dict[opt](els, args_array=args_array, **kwargs) del prog_lock except gen_class.SingleInstanceException: print("WARNING: elastic_db_repo lock in place for: %s" % (hostname))
def run_program(args_array, func_dict, **kwargs): """Function: run_program Description: Creates class instance(s) and controls flow of the program. Arguments: (input) args_array -> Dict of command line options and values. (input) func_dict -> Dictionary list of functions and options. """ args_array = dict(args_array) func_dict = dict(func_dict) svr_cfg = gen_libs.load_module(args_array["-c"], args_array["-d"]) rep_set = get_repset_name(svr_cfg) repset_hosts = get_repset_hosts(svr_cfg) repclu = mongo_class.RepSet(svr_cfg.name, svr_cfg.user, svr_cfg.passwd, host=svr_cfg.host, port=svr_cfg.port, auth=svr_cfg.auth, repset=rep_set, repset_hosts=repset_hosts) # Intersect args_array and func_dict to determine which functions to call. for func in set(args_array.keys()) & set(func_dict.keys()): func_dict[func](repclu, args_array, **kwargs)
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.base_dir = "test/integration" self.config_dir = os.path.join(self.base_dir, "config") self.config_name = "slave_mysql_cfg" self.cfg = gen_libs.load_module(self.config_name, self.config_dir) self.svr = mysql_class.SlaveRep(self.cfg.name, self.cfg.sid, self.cfg.user, self.cfg.japd, os_type=getattr( machine, self.cfg.serv_os)(), host=self.cfg.host, port=self.cfg.port, defaults_file=self.cfg.cfg_file) self.svr2 = mysql_class.SlaveRep(self.cfg.name, self.cfg.sid, self.cfg.user, "testmenopwd", os_type=getattr( machine, self.cfg.serv_os)(), host=self.cfg.host, port=self.cfg.port, defaults_file=self.cfg.cfg_file) self.err_msg = "Couldn't connect to database. MySQL error 1045:"
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.base_dir = "test/integration" self.config_dir = os.path.join(self.base_dir, "config") self.config_name = "mongo" self.cfg = gen_libs.load_module(self.config_name, self.config_dir) self.database = "admin" self.tbl_name = "system.users" self.mongo = mongo_class.DB( self.cfg.name, self.cfg.user, self.cfg.japd, host=self.cfg.host, port=self.cfg.port, db=self.database, use_arg=self.cfg.use_arg, ssl_client_ca=self.cfg.ssl_client_ca, ssl_client_key=self.cfg.ssl_client_key, ssl_client_cert=self.cfg.ssl_client_cert, ssl_client_phrase=self.cfg.ssl_client_phrase) self.mongo.connect() self.mongo.chg_db(self.database)
def create_instance(cfg_file, dir_path, cls_name): """Function: create_instance Description: Create a instance for the class received on the argument line. Arguments: (input) cfg_file -> Configuration file name. (input) dir_path -> Directory path. (input) cls_name -> Reference to a Class type. (output) Instance of the class name passed. """ cfg = gen_libs.load_module(cfg_file, dir_path) return cls_name(cfg.name, cfg.sid, cfg.user, cfg.japd, os_type=getattr(machine, cfg.serv_os)(), host=cfg.host, port=cfg.port, defaults_file=cfg.cfg_file, extra_def_file=cfg.__dict__.get("extra_def_file", None), rep_user=cfg.__dict__.get("rep_user", None), rep_japd=cfg.__dict__.get("rep_japd", None))
def mongo_check(config_path, config_file): """Function: mongo_check Description: Check the contents of the output file based on the items in the search_list variable and check to see if file is in JSON format. Arguments: (input) config_path -> Path name to configuration file. (input) config_file -> Name of configuration file, without .py ext. (output) status -> True|False - Status of checks. """ status = True cfg = gen_libs.load_module(config_file, config_path) coll = mongo_libs.crt_coll_inst(cfg, cfg.db, cfg.coll) coll.connect() status = coll.coll_cnt() == 1 mongo = mongo_class.DB(cfg.name, cfg.user, cfg.passwd, host=cfg.host, port=cfg.port, db=cfg.db, auth=cfg.auth, conf_file=cfg.conf_file) mongo.db_connect(cfg.db) mongo.db_cmd("dropDatabase") cmds_gen.disconnect([coll, mongo]) return status
def run_program(args_array, **kwargs): """Function: run_program Description: Creates class instance and controls flow of the program. Create a program lock to prevent other instantiations from running. Arguments: (input) args_array -> Dictionary of command line options and values. """ cmdline = gen_libs.get_inst(sys) args_array = dict(args_array) cfg = gen_libs.load_module(args_array["-c"], args_array["-d"]) server = gen_class.System() server.set_host_name() try: prog_lock = gen_class.ProgramLock(cmdline.argv, server.host_name) proc_data = get_svr_info(server) proc_data.update(get_svr_mem()) proc_data["processes"] = get_proc_mem(cfg.memory_threshold) post_process(proc_data, args_array, cfg) del prog_lock except gen_class.SingleInstanceException: print("WARNING: server_usage lock in place for: %s" % (server.host_name))
def main(): """Function: main Description: Control the blackbox testing of rmq_2_sysmon.py program. Variables: base_dir -> Directory path to blackbox testing directory. test_path -> Current full directory path, including base_dir. config_path -> Directory path to config, including test_path. file_path -> Directory path the test files. Arguments: """ base_dir = "test/blackbox/rmq_2_sysmon" test_path = os.path.join(os.getcwd(), base_dir) config_path = os.path.join(test_path, "config") file_path = os.path.join(test_path, "testfiles") cfg = gen_libs.load_module("rabbitmq", config_path) rmq = blackbox_libs.create_rq_pub(cfg) if rmq: test_1(rmq, file_path, cfg.message_dir, cfg.log_dir) else: print("Error: Failed to create RabbitMQ Publisher instance")
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.base_dir = "test/integration/elastic_db_dump" self.test_path = os.path.join(os.getcwd(), self.base_dir) self.config_path = os.path.join(self.test_path, "config") self.cfg = gen_libs.load_module("elastic", self.config_path) self.phy_repo_dir = os.path.join(self.cfg.phy_repo_dir, self.cfg.repo_name) self.func_dict = { "-C": elastic_db_dump.create_repo, "-D": elastic_db_dump.initate_dump, "-L": elastic_db_dump.list_dumps, "-R": elastic_db_dump.list_repos } self.args = {"-c": "elastic", "-d": self.config_path} elr = elastic_class.ElasticSearchRepo(self.cfg.host, self.cfg.port) if elr.repo_dict: print("ERROR: Test environment not clean - repositories exist.") self.skipTest("Pre-conditions not met.") else: self.elr = None
def run_program(args_array, func_dict): """Function: run_program Description: Creates class instance(s) and controls flow of the program. Arguments: (input) args_array -> Dict of command line options and values. (input) func_dict -> Dictionary list of functions and options. """ args_array = dict(args_array) func_dict = dict(func_dict) yum = gen_class.Yum() mongo_cfg = None if args_array.get("-c", False): mongo_cfg = gen_libs.load_module(args_array["-c"], args_array["-d"]) # Intersect args_array & func_dict to find which functions to call. for item in set(args_array.keys()) & set(func_dict.keys()): status = func_dict[item](args_array, yum, class_cfg=mongo_cfg) if not status[0]: print("Error Detected: %s" % (status[1]))
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.base_dir = "test/integration/elastic_db_dump" self.test_path = os.path.join(os.getcwd(), self.base_dir) self.config_path = os.path.join(self.test_path, "config") self.cfg = gen_libs.load_module("elastic", self.config_path) self.phy_repo_dir = os.path.join(self.cfg.phy_repo_dir, self.cfg.repo_name) self.elr = elastic_class.ElasticSearchRepo(self.cfg.host, self.cfg.port) if self.elr.repo_dict: print("ERROR: Test environment not clean - repositories exist.") self.skipTest("Pre-conditions not met.") else: _, _ = self.elr.create_repo( self.cfg.repo_name, os.path.join(self.cfg.repo_dir, self.cfg.repo_name)) self.els = elastic_class.ElasticSearchDump(self.cfg.host, self.cfg.port, repo=self.cfg.repo_name)
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.base_dir = "test/integration" self.config_dir = os.path.join(self.base_dir, "config") self.config_name = "mongo" self.config_name2 = "slave_mongo" self.cfg = gen_libs.load_module(self.config_name, self.config_dir) self.cfg2 = gen_libs.load_module(self.config_name2, self.config_dir) self.database = "admin"
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ key1 = "pass" key2 = "wd" self.base_dir = "test/integration" self.config_dir = os.path.join(self.base_dir, "config") self.config_name = "mysql_cfg" cfg = gen_libs.load_module(self.config_name, self.config_dir) self.svr = mysql_class.Server(cfg.name, cfg.sid, cfg.user, cfg.japd, os_type=getattr(machine, cfg.serv_os)(), host=cfg.host, port=cfg.port, defaults_file=cfg.cfg_file) self.ssl_client_ca = "CAFile" self.ssl_client_key = "KeyFile" self.ssl_client_cert = "CertFile" self.ssl_client_flag = mysql.connector.ClientFlag.SSL self.config = {} self.config[key1 + key2] = self.svr.sql_pass self.config["ssl_ca"] = "CAFile" self.config["client_flags"] = [mysql.connector.ClientFlag.SSL] self.config["ssl_disabled"] = False self.config["ssl_verify_identity"] = False self.config["ssl_verify_cert"] = False self.config2 = {} self.config2[key1 + key2] = self.svr.sql_pass self.config2["ssl_key"] = "KeyFile" self.config2["ssl_cert"] = "CertFile" self.config2["client_flags"] = [mysql.connector.ClientFlag.SSL] self.config2["ssl_ca"] = "" self.config2["ssl_disabled"] = False self.config2["ssl_verify_identity"] = False self.config3 = {} self.config3[key1 + key2] = self.svr.sql_pass self.config3["ssl_ca"] = "CAFile" self.config3["ssl_key"] = "KeyFile" self.config3["ssl_cert"] = "CertFile" self.config3["client_flags"] = [mysql.connector.ClientFlag.SSL] self.config3["ssl_disabled"] = False self.config3["ssl_verify_identity"] = False self.config3["ssl_verify_cert"] = False
def load_cfg(args_array): """Function: load_cfg Description: Read and load configuration into cfg. Arguments: (input) args_array -> Dict of command line options and values. (output) -> Server configuration settings. """ return gen_libs.load_module(args_array["-c"], args_array["-d"])
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.base_dir = "test/integration/elastic_class" self.test_path = os.path.join(os.getcwd(), self.base_dir) self.config_path = os.path.join(self.test_path, "config") self.cfg = gen_libs.load_module("elastic", self.config_path)
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.base_dir = "test/integration" self.config_dir = os.path.join(self.base_dir, "config") self.config_name = "mongo" self.cfg = gen_libs.load_module(self.config_name, self.config_dir) self.errmsg = "Error: Server not detected."
def chk_rep_lag(repset, args_array, **kwargs): """Function: chk_rep_lag Description: See if replication is running and find the best Oplog datetime whether Primary or Secondary. Arguments: (input) repset -> Replication set instance. (input) args_array -> Array of command line options and values. (output) status -> Tuple on connection status. status[0] - True|False - Connection successful. status[1] - Error message if connection failed. """ args_array = dict(args_array) json_fmt = args_array.get("-j", False) outfile = args_array.get("-o", None) db_tbl = args_array.get("-i", None) rep_status = repset.adm_cmd("replSetGetStatus") primary = get_master(rep_status) mongo_cfg = None if args_array.get("-m", None): mongo_cfg = gen_libs.load_module(args_array["-m"], args_array["-d"]) if primary: optime_date = primary.get("optimeDate") suffix = "primary" # Use best datetime from Secondaries. else: optime_date = get_optimedate(rep_status) suffix = "freshest secondary" status = chk_mem_rep_lag(rep_status, optdt=optime_date, suf=suffix, json=json_fmt, ofile=outfile, db_tbl=db_tbl, class_cfg=mongo_cfg, args_array=args_array, **kwargs) return status
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.base_dir = "test/integration" self.config_dir = os.path.join(self.base_dir, "config") self.config_name = "mongo" self.cfg = gen_libs.load_module(self.config_name, self.config_dir) self.database = "admin" self.coll = "system.users" self.errmsg = "Error: Server not detected." self.errmsg2 = "Error: Unable to connect, no collection passed."
def main(): """Function: main Description: Control the cleanup of RabbitMQ exchange and queues. Variables: Arguments: """ base_dir = "test/integration/rmq_2_sysmon" test_path = os.path.join(os.getcwd(), base_dir) config_path = os.path.join(test_path, "config") cfg = gen_libs.load_module("rabbitmq", config_path) print("\nRabbitMQ cleanup...") rmq_cleanup(cfg, cfg.queue_name, True)
def setUp(self): """Function: setUp Description: Initialization for unit testing. Arguments: """ self.base_dir = "test/integration" self.config_dir = os.path.join(self.base_dir, "config") self.config_name = "mongo" self.cfg = gen_libs.load_module(self.config_name, self.config_dir) self.database = "admin" self.failure = "Authentication failed." self.ermsg = "Error: Auth flag or login params is incorrect: %s" self.errmsg2 = "Error: Server not detected."
def run_program(args_array, func_dict, **kwargs): """Function: run_program Description: Creates class instance(s) and controls flow of the program. Arguments: (input) args_array -> Dict of command line options and values. (input) func_dict -> Dictionary list of functions and options. """ args_array = dict(args_array) func_dict = dict(func_dict) server = mongo_libs.create_instance(args_array["-c"], args_array["-d"], mongo_class.Server) state = server.connect() if state[0]: outfile = args_array.get("-o", None) db_tbl = args_array.get("-i", None) repcfg = None mail = None if args_array.get("-m", None): repcfg = gen_libs.load_module(args_array["-m"], args_array["-d"]) if args_array.get("-e", None): mail = gen_class.setup_mail(args_array.get("-e"), subj=args_array.get("-s", None)) # Call function(s) - intersection of command line and function dict. for item in set(args_array.keys()) & set(func_dict.keys()): err_flag, err_msg = func_dict[item]( server, args_array, ofile=outfile, db_tbl=db_tbl, class_cfg=repcfg, mail=mail, **kwargs) if err_flag: print("Error: %s" % (err_msg)) break mongo_libs.disconnect([server]) else: print("Connection failure: %s" % (state[1]))