def configure_keystore()

in plugins/v1/repository_gcs/plugin.py [0:0]


def configure_keystore(config_names, variables, **kwargs):
    logger = logging.getLogger(LOGGER_NAME)
    keystore_params = ["gcs_client_name", "gcs_credentials_file"]
    client_name = variables.get(keystore_params[0])
    credentials_file = variables.get(keystore_params[1])

    if not (credentials_file and client_name):
        logger.warning("Skipping keystore configuration for repository-gcs as plugin-params %s were not supplied", keystore_params)
        return False

    keystore_binary_filename = "elasticsearch-keystore"
    install_root = variables["install_root_path"]
    keystore_binary = resolve_binary(install_root, keystore_binary_filename)
    env = kwargs.get("env")

    if not os.path.isfile(resolve_keystore_config(install_root)):
        create_keystore(install_root, keystore_binary, env)

    keystore_command = "{keystore} --silent add-file gcs.client.{client_name}.credentials_file {credentials_file}".format(
        keystore=keystore_binary,
        client_name=client_name,
        credentials_file=credentials_file)

    return_code = process.run_subprocess_with_logging(
        keystore_command,
        env=env
    )

    if return_code != 0:
        logger.error("%s has exited with code [%d]", keystore_command, return_code)
        raise exceptions.SystemSetupError(
            "Could not add GCS keystore secure setting. Please see the log for details.")

    # Success
    return True