From a44dd9a741a08d9f586ae8fe1d2543bcf32f6593 Mon Sep 17 00:00:00 2001 From: Timur Sufiev Date: Fri, 29 Apr 2016 14:08:51 +0300 Subject: [PATCH] Support Glance CORS options in devstack configuration To properly test the integration between Glance CORS feature and Horizon Javascript environment uploading image files directly to Glance (using this feature), we need to enable CORS support for Glance in integration tests. Adding corresponding Devstack variable to configure Glance in such a way that it accepts direct requests from Horizon Javascript is the prerequisite step for the integration testing of this feature. By default Horizon and Glance are located on the same host, hence default value cors.allowed_origin = http://$SERVICE_HOST should work. If a more complicated setup is desired, where Horizon is located on a different host, GLANCE_CORS_ALLOWED_ORIGIN environment variable should be exported to Devstack. Partially implements blueprint: horizon-glance-large-image-upload Change-Id: I4881fb6631c2daa2ad8946210eff4bb021957374 --- lib/glance | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/glance b/lib/glance index f2a6db6edc..ce5f867430 100644 --- a/lib/glance +++ b/lib/glance @@ -143,6 +143,13 @@ function configure_glance { iniset $GLANCE_API_CONF DEFAULT workers "$API_WORKERS" + # CORS feature support - to allow calls from Horizon by default + if [ -n "$GLANCE_CORS_ALLOWED_ORIGIN" ]; then + iniset $GLANCE_API_CONF cors allowed_origin "$GLANCE_CORS_ALLOWED_ORIGIN" + else + iniset $GLANCE_API_CONF cors allowed_origin "http://$SERVICE_HOST" + fi + # Store the images in swift if enabled. if is_service_enabled s-proxy; then iniset $GLANCE_API_CONF glance_store default_store swift