def main(): persistence_type = os.environ.get("GLUU_PERSISTENCE_TYPE", "ldap") ldap_mapping = os.environ.get("GLUU_PERSISTENCE_LDAP_MAPPING", "default") if persistence_type not in PERSISTENCE_TYPES: logger.error("Unsupported GLUU_PERSISTENCE_TYPE value; " "please choose one of {}".format( ", ".join(PERSISTENCE_TYPES))) sys.exit(1) if persistence_type == "hybrid" and ldap_mapping not in PERSISTENCE_LDAP_MAPPINGS: logger.error("Unsupported GLUU_PERSISTENCE_LDAP_MAPPING value; " "please choose one of {}".format( ", ".join(PERSISTENCE_LDAP_MAPPINGS))) sys.exit(1) manager = get_manager() deps = ["config", "secret"] if persistence_type == "hybrid": deps += ["ldap_conn", "couchbase_conn"] else: deps.append("{}_conn".format(persistence_type)) wait_for(manager, deps)
def dump(config_file, secret_file): """Dumps config and secret into JSON files. """ deps = ["config_conn", "secret_conn"] wait_for(manager, deps=deps) _dump_to_file(manager, config_file, "config") _dump_to_file(manager, secret_file, "secret")
def main(): persistence_type = os.environ.get("GLUU_PERSISTENCE_TYPE", "ldap") validate_persistence_type(persistence_type) ldap_mapping = os.environ.get("GLUU_PERSISTENCE_LDAP_MAPPING", "default") validate_persistence_ldap_mapping(persistence_type, ldap_mapping) manager = get_manager() deps = ["config", "secret"] if persistence_type == "hybrid": deps += ["ldap", "couchbase"] else: deps.append(persistence_type) wait_for(manager, deps)
def load(generate_file, config_file, secret_file): """Loads config and secret from JSON files (generate if not exist). """ config_file_found = os.path.isfile(config_file) secret_file_found = os.path.isfile(secret_file) should_generate = False params = {} if not any([config_file_found, secret_file_found]): should_generate = True logger.warning("Unable to find {0} or {1}".format( config_file, secret_file)) logger.info("Loading parameters from {}".format(generate_file)) params, err, code = params_from_file(generate_file) if code != 0: logger.error( "Unable to load generate parameters; reason={}".format(err)) raise click.Abort() deps = ["config_conn", "secret_conn"] wait_for(manager, deps=deps) if should_generate: logger.info("Generating config and secret.") # tolerancy before checking existing key time.sleep(5) ctx_generator = CtxGenerator(manager, params) ctx = ctx_generator.generate() _save_generated_ctx(manager, ctx["config"], "config") _dump_to_file(manager, config_file, "config") _save_generated_ctx(manager, ctx["secret"], "secret") _dump_to_file(manager, secret_file, "secret") return # load from existing files _load_from_file(manager, config_file, "config") _load_from_file(manager, secret_file, "secret")
def main(): persistence_type = os.environ.get("GLUU_PERSISTENCE_TYPE", "ldap") validate_persistence_type(persistence_type) ldap_mapping = os.environ.get("GLUU_PERSISTENCE_LDAP_MAPPING", "default") validate_persistence_ldap_mapping(persistence_type, ldap_mapping) meta = os.environ.get("GLUU_CONTAINER_METADATA") if meta not in CONTAINER_META_OPTS: logger.error( "Invalid value for GLUU_CONTAINER_METADATA environment variable; " "please choose one of {}".format(", ".join(CONTAINER_META_OPTS))) sys.exit(1) manager = get_manager() deps = ["config", "secret"] if persistence_type == "hybrid": deps += ["ldap", "couchbase"] else: deps.append(persistence_type) wait_for(manager, deps)
def main(): manager = get_manager() deps = ["config", "secret"] wait_for(manager, deps)