def _get_storage_manager(): """Configure and yield a storage_manager instance. This is to be used only OUTSIDE of the context of the REST API. """ config.instance.load_from_file(RESTSERVICE_CONFIG_PATH) app = server.CloudifyFlaskApp() try: with app.app_context(): sm = get_storage_manager() yield sm finally: config.reset(config.Config())
def _collect_cloudify_config(data): config.instance.load_from_file(RESTSERVICE_CONFIG_PATH) app = server.CloudifyFlaskApp() try: with app.app_context(): ldap = bool(app.ldap) data['cloudify_config'] = { 'ldap_enabled': ldap, 'ha_enabled': _is_clustered() } finally: config.reset(config.Config())
def generate_auth_token(): config.instance.load_from_file(RESTSERVICE_CONFIG_PATH) config.instance.rest_service_log_path = '/dev/null' app = server.CloudifyFlaskApp() try: with app.app_context(): sm = storage.get_storage_manager() enc_uid = storage.idencoder.get_encoder().encode(0) admin_user = sm.get(storage.models.User, 0) token_key = admin_user.api_token_key return enc_uid + token_key finally: config.reset(config.Config())