import os import shutil from conpeek_setup import util def run(config): util.print_black_light("Preparing mariadb file") output_directory = os.path.join(util.get_output_path(), "mariadb") template_mariadb_directory = os.path.join(util.get_templates_path(), "mariadb") shutil.rmtree(output_directory, ignore_errors=True) os.makedirs(output_directory, exist_ok=True) shutil.copytree(template_mariadb_directory, output_directory, dirs_exist_ok=True) topology_data_file_path = os.path.join(output_directory, "07_topology_data_for_1_tenant.sql") tenant_data = util.get_minimal_configuration() topology_replacements = { # machine secrets 'MASTER_PASSWORD': config["machine_secrets"]["master_password"], # new machine network 'KAMAILIO_NAME': tenant_data["kamailio_name"], 'INSTANCE_NAME': config["new_machine_network"]["app_installation_domain"], 'ACCESS_DOMAIN_NAME': config["new_machine_network"]["app_installation_domain"], 'SYSTEM_DOMAIN_NAME': config["new_machine_network"]["system_app_installation_domain"], 'CORE_IP': config["new_machine_network"]["internal_ip"], 'CORE_MASK': config["new_machine_network"]["internal_mask"], 'CORE_NET_ADDRESS': config["new_machine_network"]["internal_net_address"], 'ACCESS_IP': config["new_machine_network"]["external_ip"], 'ACCESS_MASK': config["new_machine_network"]["external_mask"], 'ACCESS_NET_ADDRESS': config["new_machine_network"]["external_net_address"], 'TELCO_IP': config["new_machine_network"]["telco_ip"], 'TELCO_GATEWAY': config["new_machine_network"]["telco_gateway"], 'TELCO_MASK': config["new_machine_network"]["telco_mask"], 'TELCO_NET_ADDRESS': config["new_machine_network"]["telco_net_address"], 'MONGO_REPLICASET_NAME': config["new_machine_network"]["cluster_name"], 'SYSTEM_TOKEN_SECRETKEY': util.get_token("system_token_secretkey"), } for name in topology_replacements.keys(): util.basic_on_location_sed(topology_data_file_path, name, topology_replacements[name]) manager_data_file_path = os.path.join(output_directory, "06_manager_data_for_1_tenant.sql") manager_replacements = { 'OPERATOR_DOMAIN': config["operator"]["domain"], 'OPERATOR_USERNAME': config["operator"]["username"], 'OPERATOR_PASSWORD': config["operator"]["password"] } for name in manager_replacements.keys(): util.basic_on_location_sed(manager_data_file_path, name, manager_replacements[name])