Make default visibility option on create image modal configurable

If the user is allowed to create public images, the default visibility
option on the create image modal is public unless the setting
image_visibility is set to "private" on local_settings.py.

Closes-bug: #1699144
Change-Id: Ib1fc6c846ba3b7e2ee303749aca797b0e6707f37
This commit is contained in:
Ying Zuo 2017-07-06 13:54:13 -07:00
parent 9e9db4660a
commit 9edda95f04
4 changed files with 39 additions and 1 deletions

View File

@ -898,6 +898,26 @@ by cinder. Currently only the backup service is available.
Glance
------
CREATE_IMAGE_DEFAULTS
~~~~~~~~~~~~~~~~~~~~~
.. versionadded:: 12.0.0(Pike)
Default:
.. code-block:: python
{
'image_visibility': "public",
}
A dictionary of default settings for create image modal.
The ``image_visibility`` setting specifies the default visibility option.
Valid values are ``"public"`` and ``"private"``. By default, the visibility
option is public on create image modal. If it's set to ``"private"``, the
default visibility option is private.
HORIZON_IMAGES_ALLOW_UPLOAD
~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -410,6 +410,11 @@ IMAGE_RESERVED_CUSTOM_PROPERTIES = []
# configuration and policies allow setting locations.
#IMAGES_ALLOW_LOCATION = False
# A dictionary of default settings for create image modal.
#CREATE_IMAGE_DEFAULTS = {
# 'image_visibility': "public",
#}
# OPENSTACK_ENDPOINT_TYPE specifies the endpoint type to use for the endpoints
# in the Keystone service catalog. Use this setting when Horizon is running
# external to the OpenStack environment. The default is 'publicURL'.
@ -813,7 +818,8 @@ SECURITY_GROUP_RULES = {
REST_API_REQUIRED_SETTINGS = ['OPENSTACK_HYPERVISOR_FEATURES',
'LAUNCH_INSTANCE_DEFAULTS',
'OPENSTACK_IMAGE_FORMATS',
'OPENSTACK_KEYSTONE_DEFAULT_DOMAIN']
'OPENSTACK_KEYSTONE_DEFAULT_DOMAIN',
'CREATE_IMAGE_DEFAULTS']
# Additional settings can be made available to the client side for
# extensibility by specifying them in REST_API_ADDITIONAL_SETTINGS

View File

@ -119,6 +119,8 @@
var settingsFormats = response.OPENSTACK_IMAGE_FORMATS;
var uploadMode = response.HORIZON_IMAGES_UPLOAD_MODE;
var dupe = angular.copy(imageFormats);
var imageDefaults = response.CREATE_IMAGE_DEFAULTS;
angular.forEach(dupe, function stripUnknown(name, key) {
if (settingsFormats.indexOf(key) === -1) {
delete dupe[key];
@ -136,6 +138,9 @@
ctrl.image.source_type = 'url';
}
ctrl.imageFormats = dupe;
if (imageDefaults && imageDefaults.image_visibility === "private") {
ctrl.image.visibility = "private";
}
}
function isLocalFileUpload() {

View File

@ -0,0 +1,7 @@
---
features:
- |
Added a new setting CREATE_IMAGE_DEFAULTS(dictionary) to configure the
default options shown on create image modal. By default, the visibility
option is public on create image modal. If ``image_visibility`` in this
setting is set to ``"private"``, the default visibility option is private.