Add support for showing / returing multiple locations (#8)
* Add support for showing / returing multiple locations
* Update readme for multiple locations support
* Adding unit test for multiple backends and showing the multiple locations
* Updating test usecase to run for mitaka version
diff --git a/README.rst b/README.rst
index 0a94ee3..dac4563 100644
--- a/README.rst
+++ b/README.rst
@@ -198,6 +198,26 @@
allow_credentials: True
max_age: 86400
+Enable Viewing Multiple Locations
+---------------------------------
+If you want to expose all locations available (for example when you have
+multiple backends configured), then you can configure this like so:
+
+.. code-block:: yaml
+
+ glance:
+ server:
+ show_multiple_locations: True
+ location_strategy: store_type
+ store_type_preference: rbd,swift,file
+
+Please note: the show_multiple_locations option is deprecated since Newton and is planned
+ to be handled by policy files _only_ starting with the Pike release.
+
+This feature is convenient in a scenario when you have swift and rbd configured and want to
+benefit from rbd enhancements.
+
+
Client role
-----------
diff --git a/glance/files/mitaka/glance-api.conf.Debian b/glance/files/mitaka/glance-api.conf.Debian
index b8de9c6..3efb9dc 100644
--- a/glance/files/mitaka/glance-api.conf.Debian
+++ b/glance/files/mitaka/glance-api.conf.Debian
@@ -73,6 +73,7 @@
# security risk, so use this setting with caution! Setting this to
# true overrides the show_image_direct_url option. (boolean value)
#show_multiple_locations = false
+show_multiple_locations = {{ server.get('show_multiple_locations', False) | lower }}
# Maximum size of image a user can upload in bytes. Defaults to
# 1099511627776 bytes (1 TB).WARNING: this value should only be
@@ -130,6 +131,11 @@
# 'location_order' and 'store_type'. (string value)
# Allowed values: location_order, store_type
#location_strategy = location_order
+{% if server.get('location_strategy', 'location_order') == 'location_order' %}
+location_strategy = location_order
+{% else %}
+location_strategy = store_type
+{% endif %}
# The location of the property protection file.This file contains the
# rules for property protections and the roles/policies associated
@@ -1855,6 +1861,9 @@
# option as image location strategy defined by the 'location_strategy'
# config option. (list value)
#store_type_preference =
+{% if server.get('location_strategy', 'location_order') == 'store_type' and server.store_type_preference is defined %}
+store_type_preference = {{ server.store_type_preference }}
+{% endif %}
[task]
diff --git a/glance/files/newton/glance-api.conf.Debian b/glance/files/newton/glance-api.conf.Debian
index ef3fd74..de83148 100644
--- a/glance/files/newton/glance-api.conf.Debian
+++ b/glance/files/newton/glance-api.conf.Debian
@@ -330,6 +330,7 @@
# functionality can be achieved with greater granularity by using policies.
# Please see the Newton release notes for more information.
#show_multiple_locations = false
+show_multiple_locations = {{ server.get('show_multiple_locations', False) | lower }}
#
# Maximum size of image a user can upload in bytes.
@@ -602,6 +603,11 @@
# (string value)
# Allowed values: location_order, store_type
#location_strategy = location_order
+{% if server.get('location_strategy', 'location_order') == 'location_order' %}
+location_strategy = location_order
+{% else %}
+location_strategy = store_type
+{% endif %}
#
# The location of the property protection file.
@@ -4278,6 +4284,9 @@
#
# (list value)
#store_type_preference =
+{% if server.get('location_strategy', 'location_order') == 'store_type' and server.store_type_preference is defined %}
+store_type_preference = {{ server.store_type_preference }}
+{% endif %}
[task]
diff --git a/glance/files/ocata/glance-api.conf.Debian b/glance/files/ocata/glance-api.conf.Debian
index 8c5b479..8b3f40d 100644
--- a/glance/files/ocata/glance-api.conf.Debian
+++ b/glance/files/ocata/glance-api.conf.Debian
@@ -330,6 +330,7 @@
# functionality can be achieved with greater granularity by using policies.
# Please see the Newton release notes for more information.
#show_multiple_locations = false
+show_multiple_locations = {{ server.get('show_multiple_locations', False) | lower }}
#
# Maximum size of image a user can upload in bytes.
@@ -602,6 +603,11 @@
# (string value)
# Allowed values: location_order, store_type
#location_strategy = location_order
+{% if server.get('location_strategy', 'location_order') == 'location_order' %}
+location_strategy = location_order
+{% else %}
+location_strategy = store_type
+{% endif %}
#
# The location of the property protection file.
@@ -4344,6 +4350,9 @@
#
# (list value)
#store_type_preference =
+{% if server.get('location_strategy', 'location_order') == 'store_type' and server.store_type_preference is defined %}
+store_type_preference = {{ server.store_type_preference }}
+{% endif %}
[task]
diff --git a/tests/pillar/single_multiple_backends.sls b/tests/pillar/single_multiple_backends.sls
new file mode 100644
index 0000000..4a9d6a2
--- /dev/null
+++ b/tests/pillar/single_multiple_backends.sls
@@ -0,0 +1,70 @@
+glance:
+ server:
+ enabled: true
+ version: mitaka
+ workers: 1
+ show_multiple_locations: True
+ location_strategy: store_type
+ store_type_preference: rbd,swift
+ database:
+ engine: mysql
+ host: localhost
+ port: 3306
+ name: glance
+ user: glance
+ password: password
+ registry:
+ host: 127.0.0.1
+ port: 9191
+ bind:
+ address: 127.0.0.1
+ port: 9292
+ identity:
+ engine: keystone
+ host: 127.0.0.1
+ port: 35357
+ user: glance
+ password: password
+ region: RegionOne
+ tenant: service
+ endpoint_type: internalURL
+ message_queue:
+ engine: rabbitmq
+ host: 127.0.0.1
+ port: 5672
+ user: openstack
+ password: password
+ virtual_host: '/openstack'
+ storage:
+ engine: swift,rbd,http
+ # Rbd configuration
+ user: glance
+ pool: glance-images
+ chunk_size: 8
+ client_glance_key: AQAqcXhWk+3UARAAGmV4USB6I7wLJ/W+dVbUWw==
+ # Swift configuration
+ swift:
+ store:
+ # admin_tenants:
+ auth:
+ address: http://127.0.0.1:5000/v2.0
+ insecure: false
+ version: 2
+ cacert: /etc/ssl/certs/ca-certificates.crt
+ # config_file:
+ container: glance
+ create_container_on_put: true
+ endpoint: swift
+ endpoint_type: internalURL
+ expire_soon_interval: 60
+ key: someRandomPassword
+ large_object_size: 5120
+ large_object_chunk_size: 200
+ multi_tenant: false
+ multiple_containers_seed: 0
+ retry_get_count: 5
+ region: RegionOne
+ service_type: object-store
+ ssl_compression: false
+ use_trusts: false
+ user: 2ec7966596504f59acc3a76b3b9d9291:glance-project