cf0aac9400
Implements wrappers necessary for Horizon to work with either Glance v1 or v2 and removes the dependency on the Glance v1 endpoint. Handles the differences between setting properties with v1 and v2 and restricts some Glance functions that aren't supported in v2. Implements blueprint: horizon-glance-v2 Co-Authored-By: Travis Tripp <travis.tripp@hp.com> Co-Authored-By: Brad Pokorny <Brad_Pokorny@symantec.com> Co-Authored-By: Timur Sufiev <tsufiev@mirantis.com> Co-Authored-By: Liuqing Jing <jing.liuqing@99cloud.net> Change-Id: Icca91c53eabf18c3109b3931ed53f70eaaaa0e56
55 lines
2.0 KiB
Python
55 lines
2.0 KiB
Python
# Copyright 2015 IBM Corp.
|
|
# Copyright 2015, Hewlett-Packard Development Company, L.P.
|
|
#
|
|
# 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.
|
|
|
|
from django.conf import settings
|
|
from django.views import generic
|
|
|
|
from openstack_dashboard import api
|
|
from openstack_dashboard.api.rest import urls
|
|
from openstack_dashboard.api.rest import utils as rest_utils
|
|
|
|
|
|
# settings that we allow to be retrieved via REST API
|
|
# these settings are available to the client and are not secured.
|
|
# *** THEY SHOULD BE TREATED WITH EXTREME CAUTION ***
|
|
settings_required = getattr(settings, 'REST_API_REQUIRED_SETTINGS', [])
|
|
settings_additional = getattr(settings, 'REST_API_ADDITIONAL_SETTINGS', [])
|
|
|
|
settings_allowed = settings_required + settings_additional
|
|
|
|
|
|
@urls.register
|
|
class Settings(generic.View):
|
|
"""API for retrieving settings.
|
|
|
|
This API returns read-only settings values.
|
|
This configuration object can be fetched as needed.
|
|
Examples of settings: OPENSTACK_HYPERVISOR_FEATURES
|
|
"""
|
|
url_regex = r'settings/$'
|
|
SPECIALS = {
|
|
'HORIZON_IMAGES_UPLOAD_MODE': api.glance.get_image_upload_mode(),
|
|
'HORIZON_ACTIVE_IMAGE_VERSION': api.glance.VERSIONS.active,
|
|
'IMAGES_ALLOW_LOCATION': getattr(settings, 'IMAGES_ALLOW_LOCATION',
|
|
False)
|
|
}
|
|
|
|
@rest_utils.ajax()
|
|
def get(self, request):
|
|
plain_settings = {k: getattr(settings, k, None) for k
|
|
in settings_allowed if k not in self.SPECIALS}
|
|
plain_settings.update(self.SPECIALS)
|
|
return plain_settings
|