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
diff --git a/lib/glance b/lib/glance
index f2a6db6..ce5f867 100644
--- a/lib/glance
+++ b/lib/glance
@@ -143,6 +143,13 @@
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