From 54874018ec48acbd459fab5e09b77994b0c177fc Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Thu, 3 May 2018 00:44:04 -0500 Subject: [PATCH] Configure cors for glance for additional usability In order to enable image uploads in horizon we need to configure several things in glance, namely cors. This change implements default overrides allowing the system to provide for direct image uploads through horizon which will greatly improve our usability, especially for new users. Change-Id: I19f4027dd30b0ba22cbb195c676802ce908d3e8f Closes-Bug: #1747684 Signed-off-by: Kevin Carter (cherry picked from commit 01d3912af4b22cb22eabbf4d9d97df4b709fdb80) --- inventory/group_vars/all/glance.yml | 19 +++++++++++++++++++ inventory/group_vars/all/horizon.yml | 16 ++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 inventory/group_vars/all/horizon.yml diff --git a/inventory/group_vars/all/glance.yml b/inventory/group_vars/all/glance.yml index bb828b2d3c..33f18e1254 100644 --- a/inventory/group_vars/all/glance.yml +++ b/inventory/group_vars/all/glance.yml @@ -28,3 +28,22 @@ glance_service_internalurl: "{{ glance_service_internaluri }}" glance_service_adminuri: "{{ glance_service_adminuri_proto }}://{{ internal_lb_vip_address }}:{{ glance_service_port }}" glance_service_adminurl: "{{ glance_service_adminuri }}" glance_api_servers: "{{ glance_service_internaluri }}" + +# When running RBD or horizon image upload mode is direct allow multiple locations. +# See https://bugs.launchpad.net/openstack-ansible/+bug/1730722 for more on the +# this topic. +glance_show_multiple_locations: "{{ (glance_default_store == 'rbd') or (horizon_image_upload_mode == 'direct') }}" + +# Define the default required cors to allow image uploads through horizon +_cors_overrides: + cors: + # LP bug 1680062 + allow_headers: >- + origin,content-md5,x-image-meta-checksum,x-storage-token,accept-encoding, + x-auth-token,x-identity-status,x-roles,x-service-catalog,x-user-id, + x-tenant-id,x-openstack-request-id + allowed_origin: "{{ external_lb_vip_address }}" + allow_methods: "GET,POST,PUT,PATCH,DELETE" + +# Default glance API +glance_glance_api_conf_overrides: "{{ (glance_show_multiple_locations | bool) | ternary(_cors_overrides, {}) }}" diff --git a/inventory/group_vars/all/horizon.yml b/inventory/group_vars/all/horizon.yml new file mode 100644 index 0000000000..809e31a0ed --- /dev/null +++ b/inventory/group_vars/all/horizon.yml @@ -0,0 +1,16 @@ +--- +# Copyright 2017, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +horizon_image_upload_mode: direct