import pprint import log_config from python_mms_api.mms_client import MMSClient from isdb.job_helpers import * from isdb.snapshot_helpers import * from private_conf import config logger = logging.getLogger("qa") if __name__ == "__main__": log_config.config(logger) parser = argparse.ArgumentParser(description="Test integrity check job") parser.add_argument(dest='group_id', type=ObjectId, help="The group id to utilize") parser.add_argument(dest='rs_id', type=str, help="The existing rsId.") args = parser.parse_args() mms_client = MMSClient(config['mms_api_base_url'], config['mms_api_username'], config['mms_api_key']) host_client = mms_client.get_host_client() # while True: # cluster_id = cluster_client.get_cluster_for_replica_set(args.group_id, args.rs_id) # if cluster_id is not None: # break # logger.info("clusterId " + str(cluster_id)) host = host_client.get_primary_host_by_group_and_rs_id( args.group_id, args.rs_id) logger.info("host {}".format(host)) host_conn = pymongo.MongoClient(host=host["hostname"], port=host["port"]) host_conn.foo.bar.insert({})
parser.add_argument("-c", dest="cluster_id", type=ObjectId, help="Cluster to work upon. If blank, will create one.") parser.add_argument("-wt", dest="wired_tiger", action="store_const", const=True, help="Start backup as Wired Tiger.") args = parser.parse_args() mms_client = MMSClient( config['mms_api_base_url'], config['mms_api_username'], config['mms_api_key'] ) automation_client = mms_client.get_automation_client() backup_client = mms_client.get_backup_client() cluster_client = mms_client.get_cluster_client() snapshot_client = mms_client.get_snapshot_client() restore_client = mms_client.get_restore_client() host_client = mms_client.get_host_client() isdb_client = pymongo.MongoClient(host=config["mms_backup_db_host"], port=config["mms_backup_db_port"]) group_id = args.group_id hostname = args.hostname cluster_id = args.cluster_id wired_tiger = args.wired_tiger ## SET UP A BACKUP if not cluster_id: rs_id = add_replica_set_to_group(automation_client, hostname, group_id, run_id) logger.info("rsId {}".format(rs_id)) block_on_automation_finishing(automation_client, group_id) cluster_id = get_cluster_id_for_rs(cluster_client, group_id, rs_id) logger.info("clusterId {}".format(cluster_id)) else: