def configure_product():
    try:
        global datasource_paths
        global target_dir_abs_path
        global storage_dist_abs_path
        global storage_dir_abs_path

        datasource_paths = DATASOURCE_PATHS
        zip_name = dist_name + ZIP_FILE_EXTENSION

        storage_dir_abs_path = Path(cm.workspace + "/" +
                                    PRODUCT_STORAGE_DIR_NAME)
        target_dir_abs_path = Path(cm.workspace + "/" + cm.product_id + "/" +
                                   DISTRIBUTION_PATH)
        storage_zip_abs_path = Path(storage_dir_abs_path / zip_name)
        storage_dist_abs_path = Path(storage_dir_abs_path / dist_name)
        configured_dist_storing_loc = Path(target_dir_abs_path / dist_name)
        script_name = Path(WSO2SERVER)

        script_path = Path(storage_dist_abs_path / script_name)

        cm.extract_product(storage_dir_abs_path, storage_zip_abs_path)
        cm.attach_jolokia_agent(script_path)
        cm.copy_jar_file(Path(cm.database_config['sql_driver_location']),
                         Path(storage_dist_abs_path / LIB_PATH))

        if datasource_paths is not None:
            modify_datasources()
        else:
            logger.info("datasource paths are not defined in the config file")
        os.remove(str(storage_zip_abs_path))
        cm.compress_distribution(configured_dist_storing_loc,
                                 storage_dir_abs_path)
        cm.add_distribution_to_m2(storage_dir_abs_path, M2_PATH)
        shutil.rmtree(configured_dist_storing_loc, onerror=cm.on_rm_error)
        return database_names
    except FileNotFoundError as e:
        logger.error("Error occurred while finding files", exc_info=True)
    except IOError as e:
        logger.error("Error occurred while accessing files", exc_info=True)
    except Exception as e:
        logger.error("Error occurred while configuring the product",
                     exc_info=True)
예제 #2
0
def configure_product():
    try:
        global target_dir_abs_path
        global storage_dist_abs_path
        global storage_dir_abs_path

        zip_name = dist_name + ZIP_FILE_EXTENSION

        storage_dir_abs_path = Path(cm.workspace + "/" +
                                    PRODUCT_STORAGE_DIR_NAME)
        target_dir_abs_path = Path(cm.workspace + "/" + cm.product_id + "/" +
                                   DISTRIBUTION_PATH)
        storage_zip_abs_path = Path(storage_dir_abs_path / zip_name)
        storage_dist_abs_path = Path(storage_dir_abs_path / dist_name)
        configured_dist_storing_loc = Path(target_dir_abs_path / dist_name)
        script_name = [INTEGRATOR, BP, BROKER, ANALYTICS, MICRO_INTG]

        cm.extract_product(storage_dir_abs_path, storage_zip_abs_path)
        for scripts in script_name:
            script_path = Path(storage_dist_abs_path / Path(scripts))
            cm.attach_jolokia_agent(script_path)

        cm.copy_jar_file(Path(cm.database_config['sql_driver_location']),
                         Path(storage_dist_abs_path / LIB_PATH))
        modify_datasources()
        os.remove(str(storage_zip_abs_path))
        cm.compress_distribution(configured_dist_storing_loc,
                                 storage_dir_abs_path)
        cm.add_distribution_to_m2(storage_dir_abs_path, M2_PATH)
        shutil.rmtree(configured_dist_storing_loc, onerror=cm.on_rm_error)
        return database_names
    except FileNotFoundError as e:
        logger.error("Error occurred while finding files", exc_info=True)
    except IOError as e:
        logger.error("Error occurred while accessing files", exc_info=True)
    except Exception as e:
        logger.error("Error occurred while configuring the product",
                     exc_info=True)