Merge "Handle partial dict setting"
This commit is contained in:
commit
ab429363ba
@ -22,6 +22,8 @@ from django.core.exceptions import MiddlewareNotUsed
|
|||||||
|
|
||||||
import six.moves.urllib.parse as urlparse
|
import six.moves.urllib.parse as urlparse
|
||||||
|
|
||||||
|
from horizon.utils import settings as setting_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -44,7 +46,7 @@ class OperationLogMiddleware(object):
|
|||||||
- ``http status``
|
- ``http status``
|
||||||
- ``request parameters``
|
- ``request parameters``
|
||||||
|
|
||||||
and log format is defined OPERATION_LOG_OPTIONS.
|
and log format is defined in OPERATION_LOG_OPTIONS.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -59,15 +61,18 @@ class OperationLogMiddleware(object):
|
|||||||
self.get_response = get_response
|
self.get_response = get_response
|
||||||
|
|
||||||
# set configurations
|
# set configurations
|
||||||
_log_option = settings.OPERATION_LOG_OPTIONS
|
|
||||||
_available_methods = ['POST', 'GET', 'PUT', 'DELETE']
|
_available_methods = ['POST', 'GET', 'PUT', 'DELETE']
|
||||||
_methods = _log_option["target_methods"]
|
_methods = setting_utils.get_dict_config(
|
||||||
|
'OPERATION_LOG_OPTIONS', 'target_methods')
|
||||||
self.target_methods = [x for x in _methods if x in _available_methods]
|
self.target_methods = [x for x in _methods if x in _available_methods]
|
||||||
self.mask_fields = _log_option["mask_fields"]
|
self.mask_fields = setting_utils.get_dict_config(
|
||||||
self.format = _log_option["format"]
|
'OPERATION_LOG_OPTIONS', 'mask_fields')
|
||||||
|
self.format = setting_utils.get_dict_config(
|
||||||
|
'OPERATION_LOG_OPTIONS', 'format')
|
||||||
self._logger = logging.getLogger('horizon.operation_log')
|
self._logger = logging.getLogger('horizon.operation_log')
|
||||||
self._ignored_urls = [re.compile(url)
|
self._ignored_urls = [re.compile(url) for url
|
||||||
for url in _log_option["ignore_urls"]]
|
in setting_utils.get_dict_config(
|
||||||
|
'OPERATION_LOG_OPTIONS', 'ignore_urls')]
|
||||||
|
|
||||||
def __call__(self, request):
|
def __call__(self, request):
|
||||||
response = self.get_response(request)
|
response = self.get_response(request)
|
||||||
|
@ -15,6 +15,8 @@ import six
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.module_loading import import_string
|
from django.utils.module_loading import import_string
|
||||||
|
|
||||||
|
from horizon import defaults
|
||||||
|
|
||||||
|
|
||||||
def import_object(name_or_object):
|
def import_object(name_or_object):
|
||||||
if isinstance(name_or_object, six.string_types):
|
if isinstance(name_or_object, six.string_types):
|
||||||
@ -26,3 +28,20 @@ def import_setting(name):
|
|||||||
"""Imports an object specified either directly or as a module path."""
|
"""Imports an object specified either directly or as a module path."""
|
||||||
value = getattr(settings, name, None)
|
value = getattr(settings, name, None)
|
||||||
return import_object(value)
|
return import_object(value)
|
||||||
|
|
||||||
|
|
||||||
|
# NOTE(amotoki):
|
||||||
|
# This is a copy from openstack_dashboard.utils.settings.get_dict_config().
|
||||||
|
# This copy is needed to look up defaults for horizon.defaults
|
||||||
|
# instead of openstack_dashboard.defaults.
|
||||||
|
# NOTE(amotoki): The limitation of this approach is that we cannot handle
|
||||||
|
# a case where default values in horizon are overridden by
|
||||||
|
# openstack_dashboard.defaults. This can be addressed by set_override()
|
||||||
|
# from oslo.config.
|
||||||
|
# TODO(amotoki): This copy might be cleanup if we can use oslo.config
|
||||||
|
# for horizon configurations.
|
||||||
|
def get_dict_config(name, key):
|
||||||
|
config = getattr(settings, name)
|
||||||
|
if key in config:
|
||||||
|
return config[key]
|
||||||
|
return getattr(defaults, name)[key]
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django import shortcuts
|
from django import shortcuts
|
||||||
from django import template
|
from django import template
|
||||||
from django.utils import encoding
|
from django.utils import encoding
|
||||||
@ -21,6 +20,7 @@ from osprofiler import profiler
|
|||||||
|
|
||||||
import horizon
|
import horizon
|
||||||
from horizon import exceptions
|
from horizon import exceptions
|
||||||
|
from horizon.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
class PageTitleMixin(object):
|
class PageTitleMixin(object):
|
||||||
@ -73,7 +73,7 @@ class PageTitleMixin(object):
|
|||||||
|
|
||||||
def trace(name):
|
def trace(name):
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
if settings.OPENSTACK_PROFILER['enabled']:
|
if setting_utils.get_dict_config('OPENSTACK_PROFILER', 'enabled'):
|
||||||
return profiler.trace(name, info=None, hide_args=False,
|
return profiler.trace(name, info=None, hide_args=False,
|
||||||
allow_multiple_trace=True)(func)
|
allow_multiple_trace=True)(func)
|
||||||
else:
|
else:
|
||||||
|
@ -25,6 +25,7 @@ from keystoneauth1 import token_endpoint
|
|||||||
from keystoneclient.v3 import client as client_v3
|
from keystoneclient.v3 import client as client_v3
|
||||||
from six.moves.urllib import parse as urlparse
|
from six.moves.urllib import parse as urlparse
|
||||||
|
|
||||||
|
from openstack_auth import defaults
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -97,10 +98,23 @@ def is_token_valid(token, margin=None):
|
|||||||
return expiration > timezone.now()
|
return expiration > timezone.now()
|
||||||
|
|
||||||
|
|
||||||
|
# NOTE(amotoki):
|
||||||
|
# This is a copy from openstack_dashboard.utils.settings.get_dict_config().
|
||||||
|
# This copy is needed to look up defaults for openstack_auth.defaults
|
||||||
|
# instead of openstack_dashboard.defaults.
|
||||||
|
# TODO(amotoki): This copy might be cleanup if we can use oslo.config
|
||||||
|
# for openstack_auth configurations.
|
||||||
|
def _get_dict_config(name, key):
|
||||||
|
config = getattr(settings, name)
|
||||||
|
if key in config:
|
||||||
|
return config[key]
|
||||||
|
return getattr(defaults, name)[key]
|
||||||
|
|
||||||
|
|
||||||
# Helper for figuring out keystone version
|
# Helper for figuring out keystone version
|
||||||
# Implementation will change when API version discovery is available
|
# Implementation will change when API version discovery is available
|
||||||
def get_keystone_version():
|
def get_keystone_version():
|
||||||
return settings.OPENSTACK_API_VERSIONS['identity']
|
return _get_dict_config('OPENSTACK_API_VERSIONS', 'identity')
|
||||||
|
|
||||||
|
|
||||||
def get_session(**kwargs):
|
def get_session(**kwargs):
|
||||||
|
@ -587,8 +587,7 @@ def volume_backup_supported(request):
|
|||||||
# backup is configured yet. This is a workaround until that
|
# backup is configured yet. This is a workaround until that
|
||||||
# capability is available.
|
# capability is available.
|
||||||
# https://bugs.launchpad.net/cinder/+bug/1334856
|
# https://bugs.launchpad.net/cinder/+bug/1334856
|
||||||
cinder_config = settings.OPENSTACK_CINDER_FEATURES
|
return utils.get_dict_config('OPENSTACK_CINDER_FEATURES', 'enable_backup')
|
||||||
return cinder_config['enable_backup']
|
|
||||||
|
|
||||||
|
|
||||||
@profiler.trace
|
@profiler.trace
|
||||||
|
@ -37,6 +37,7 @@ from horizon import exceptions
|
|||||||
from openstack_dashboard.api import base
|
from openstack_dashboard.api import base
|
||||||
from openstack_dashboard.contrib.developer.profiler import api as profiler
|
from openstack_dashboard.contrib.developer.profiler import api as profiler
|
||||||
from openstack_dashboard import policy
|
from openstack_dashboard import policy
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -823,34 +824,35 @@ def delete_user_ec2_credentials(request, user_id, access_token):
|
|||||||
|
|
||||||
|
|
||||||
def keystone_can_edit_domain():
|
def keystone_can_edit_domain():
|
||||||
backend_settings = settings.OPENSTACK_KEYSTONE_BACKEND
|
can_edit_domain = setting_utils.get_dict_config(
|
||||||
can_edit_domain = backend_settings['can_edit_domain']
|
'OPENSTACK_KEYSTONE_BACKEND', 'can_edit_domain')
|
||||||
multi_domain_support = settings.OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT
|
multi_domain_support = settings.OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT
|
||||||
return can_edit_domain and multi_domain_support
|
return can_edit_domain and multi_domain_support
|
||||||
|
|
||||||
|
|
||||||
def keystone_can_edit_user():
|
def keystone_can_edit_user():
|
||||||
backend_settings = settings.OPENSTACK_KEYSTONE_BACKEND
|
return setting_utils.get_dict_config(
|
||||||
return backend_settings['can_edit_user']
|
'OPENSTACK_KEYSTONE_BACKEND', 'can_edit_user')
|
||||||
|
|
||||||
|
|
||||||
def keystone_can_edit_project():
|
def keystone_can_edit_project():
|
||||||
backend_settings = settings.OPENSTACK_KEYSTONE_BACKEND
|
return setting_utils.get_dict_config(
|
||||||
return backend_settings['can_edit_project']
|
'OPENSTACK_KEYSTONE_BACKEND', 'can_edit_project')
|
||||||
|
|
||||||
|
|
||||||
def keystone_can_edit_group():
|
def keystone_can_edit_group():
|
||||||
backend_settings = settings.OPENSTACK_KEYSTONE_BACKEND
|
return setting_utils.get_dict_config(
|
||||||
return backend_settings['can_edit_group']
|
'OPENSTACK_KEYSTONE_BACKEND', 'can_edit_group')
|
||||||
|
|
||||||
|
|
||||||
def keystone_can_edit_role():
|
def keystone_can_edit_role():
|
||||||
backend_settings = settings.OPENSTACK_KEYSTONE_BACKEND
|
return setting_utils.get_dict_config(
|
||||||
return backend_settings['can_edit_role']
|
'OPENSTACK_KEYSTONE_BACKEND', 'can_edit_role')
|
||||||
|
|
||||||
|
|
||||||
def keystone_backend_name():
|
def keystone_backend_name():
|
||||||
return settings.OPENSTACK_KEYSTONE_BACKEND['name'] or 'unknown'
|
return setting_utils.get_dict_config(
|
||||||
|
'OPENSTACK_KEYSTONE_BACKEND', 'name') or 'unknown'
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
|
@ -39,6 +39,7 @@ from openstack_dashboard.api import base
|
|||||||
from openstack_dashboard.api import nova
|
from openstack_dashboard.api import nova
|
||||||
from openstack_dashboard.contrib.developer.profiler import api as profiler
|
from openstack_dashboard.contrib.developer.profiler import api as profiler
|
||||||
from openstack_dashboard import policy
|
from openstack_dashboard import policy
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
# Python 3.8 removes the ability to import the abstract base classes from
|
# Python 3.8 removes the ability to import the abstract base classes from
|
||||||
# 'collections', but 'collections.abc' is not present in Python 2.7
|
# 'collections', but 'collections.abc' is not present in Python 2.7
|
||||||
@ -799,8 +800,8 @@ class FloatingIpManager(object):
|
|||||||
|
|
||||||
def is_supported(self):
|
def is_supported(self):
|
||||||
"""Returns True if floating IP feature is supported."""
|
"""Returns True if floating IP feature is supported."""
|
||||||
network_config = settings.OPENSTACK_NEUTRON_NETWORK
|
return setting_utils.get_dict_config(
|
||||||
return network_config['enable_router']
|
'OPENSTACK_NEUTRON_NETWORK', 'enable_router')
|
||||||
|
|
||||||
|
|
||||||
def get_ipver_str(ip_version):
|
def get_ipver_str(ip_version):
|
||||||
@ -1841,11 +1842,12 @@ def is_extension_supported(request, extension_alias):
|
|||||||
# values are pre-defined now, so 'default' argument is meaningless
|
# values are pre-defined now, so 'default' argument is meaningless
|
||||||
# in most cases.
|
# in most cases.
|
||||||
def is_enabled_by_config(name, default=True):
|
def is_enabled_by_config(name, default=True):
|
||||||
network_config = settings.OPENSTACK_NEUTRON_NETWORK
|
try:
|
||||||
# NOTE(amotoki): This function is used by horizon plugins
|
return setting_utils.get_dict_config('OPENSTACK_NEUTRON_NETWORK', name)
|
||||||
# via is_service_enabled() function, so we need to keep .get()
|
except KeyError:
|
||||||
# rather than [] dict operator.
|
# No default value is defined.
|
||||||
return network_config.get(name, default)
|
# This is a fallback logic for horizon plugins.
|
||||||
|
return default
|
||||||
|
|
||||||
|
|
||||||
# TODO(amotoki): Clean up 'default' parameter because the default
|
# TODO(amotoki): Clean up 'default' parameter because the default
|
||||||
@ -1879,7 +1881,6 @@ FEATURE_MAP = {
|
|||||||
'extension': 'dvr',
|
'extension': 'dvr',
|
||||||
'config': {
|
'config': {
|
||||||
'name': 'enable_distributed_router',
|
'name': 'enable_distributed_router',
|
||||||
'default': False,
|
|
||||||
},
|
},
|
||||||
'policies': {
|
'policies': {
|
||||||
'get': 'get_router:distributed',
|
'get': 'get_router:distributed',
|
||||||
@ -1889,8 +1890,9 @@ FEATURE_MAP = {
|
|||||||
},
|
},
|
||||||
'l3-ha': {
|
'l3-ha': {
|
||||||
'extension': 'l3-ha',
|
'extension': 'l3-ha',
|
||||||
'config': {'name': 'enable_ha_router',
|
'config': {
|
||||||
'default': False},
|
'name': 'enable_ha_router',
|
||||||
|
},
|
||||||
'policies': {
|
'policies': {
|
||||||
'get': 'get_router:ha',
|
'get': 'get_router:ha',
|
||||||
'create': 'create_router:ha',
|
'create': 'create_router:ha',
|
||||||
@ -1921,7 +1923,6 @@ def get_feature_permission(request, feature, operation=None):
|
|||||||
defined in FEATURE_MAP[feature]['policies']
|
defined in FEATURE_MAP[feature]['policies']
|
||||||
It must be specified if FEATURE_MAP[feature] has 'policies'.
|
It must be specified if FEATURE_MAP[feature] has 'policies'.
|
||||||
"""
|
"""
|
||||||
network_config = settings.OPENSTACK_NEUTRON_NETWORK
|
|
||||||
feature_info = FEATURE_MAP.get(feature)
|
feature_info = FEATURE_MAP.get(feature)
|
||||||
if not feature_info:
|
if not feature_info:
|
||||||
raise ValueError("The requested feature '%(feature)s' is unknown. "
|
raise ValueError("The requested feature '%(feature)s' is unknown. "
|
||||||
@ -1931,10 +1932,8 @@ def get_feature_permission(request, feature, operation=None):
|
|||||||
# Check dashboard settings
|
# Check dashboard settings
|
||||||
feature_config = feature_info.get('config')
|
feature_config = feature_info.get('config')
|
||||||
if feature_config:
|
if feature_config:
|
||||||
# TODO(amotoki): Drop 'default' from FEATURE_MAP as it will be
|
if not setting_utils.get_dict_config('OPENSTACK_NEUTRON_NETWORK',
|
||||||
# meaningless once all default settings are pre-defined.
|
feature_config['name']):
|
||||||
if not network_config.get(feature_config['name'],
|
|
||||||
feature_config['default']):
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Check policy
|
# Check policy
|
||||||
|
@ -1036,8 +1036,8 @@ def extension_supported(extension_name, request):
|
|||||||
|
|
||||||
@profiler.trace
|
@profiler.trace
|
||||||
def can_set_server_password():
|
def can_set_server_password():
|
||||||
features = settings.OPENSTACK_HYPERVISOR_FEATURES
|
return utils.get_dict_config('OPENSTACK_HYPERVISOR_FEATURES',
|
||||||
return features['can_set_password']
|
'can_set_password')
|
||||||
|
|
||||||
|
|
||||||
@profiler.trace
|
@profiler.trace
|
||||||
@ -1049,16 +1049,16 @@ def instance_action_list(request, instance_id):
|
|||||||
@profiler.trace
|
@profiler.trace
|
||||||
def can_set_mount_point():
|
def can_set_mount_point():
|
||||||
"""Return the Hypervisor's capability of setting mount points."""
|
"""Return the Hypervisor's capability of setting mount points."""
|
||||||
hypervisor_features = settings.OPENSTACK_HYPERVISOR_FEATURES
|
return utils.get_dict_config('OPENSTACK_HYPERVISOR_FEATURES',
|
||||||
return hypervisor_features["can_set_mount_point"]
|
'can_set_mount_point')
|
||||||
|
|
||||||
|
|
||||||
@profiler.trace
|
@profiler.trace
|
||||||
def requires_keypair():
|
def requires_keypair():
|
||||||
features = settings.OPENSTACK_HYPERVISOR_FEATURES
|
return utils.get_dict_config('OPENSTACK_HYPERVISOR_FEATURES',
|
||||||
return features['requires_keypair']
|
'requires_keypair')
|
||||||
|
|
||||||
|
|
||||||
def can_set_quotas():
|
def can_set_quotas():
|
||||||
features = settings.OPENSTACK_HYPERVISOR_FEATURES
|
return utils.get_dict_config('OPENSTACK_HYPERVISOR_FEATURES',
|
||||||
return features['enable_quotas']
|
'enable_quotas')
|
||||||
|
@ -25,9 +25,10 @@ from osprofiler import web
|
|||||||
import six
|
import six
|
||||||
from six.moves.urllib.parse import urlparse
|
from six.moves.urllib.parse import urlparse
|
||||||
|
|
||||||
|
from horizon.utils import settings as horizon_settings
|
||||||
|
|
||||||
|
|
||||||
ROOT_HEADER = 'PARENT_VIEW_TRACE_ID'
|
ROOT_HEADER = 'PARENT_VIEW_TRACE_ID'
|
||||||
PROFILER_SETTINGS = settings.OPENSTACK_PROFILER
|
|
||||||
|
|
||||||
|
|
||||||
def init_notifier(connection_str, host="localhost"):
|
def init_notifier(connection_str, host="localhost"):
|
||||||
@ -71,7 +72,8 @@ def _get_engine_kwargs(request, connection_str):
|
|||||||
|
|
||||||
|
|
||||||
def _get_engine(request):
|
def _get_engine(request):
|
||||||
connection_str = PROFILER_SETTINGS['receiver_connection_string']
|
connection_str = horizon_settings.get_dict_config(
|
||||||
|
'OPENSTACK_PROFILER', 'receiver_connection_string')
|
||||||
kwargs = _get_engine_kwargs(request, connection_str)
|
kwargs = _get_engine_kwargs(request, connection_str)
|
||||||
return profiler_get_driver(connection_str, **kwargs)
|
return profiler_get_driver(connection_str, **kwargs)
|
||||||
|
|
||||||
@ -124,7 +126,7 @@ def update_trace_headers(keys, **kwargs):
|
|||||||
web.X_TRACE_HMAC: trace_data[1]})
|
web.X_TRACE_HMAC: trace_data[1]})
|
||||||
|
|
||||||
|
|
||||||
if not PROFILER_SETTINGS['enabled']:
|
if not horizon_settings.get_dict_config('OPENSTACK_PROFILER', 'enabled'):
|
||||||
def trace(function):
|
def trace(function):
|
||||||
return function
|
return function
|
||||||
else:
|
else:
|
||||||
|
@ -24,13 +24,14 @@ from osprofiler import web
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from horizon import messages
|
from horizon import messages
|
||||||
|
from horizon.utils import settings as horizon_settings
|
||||||
from openstack_dashboard.contrib.developer.profiler import api
|
from openstack_dashboard.contrib.developer.profiler import api
|
||||||
|
|
||||||
_REQUIRED_KEYS = ("base_id", "hmac_key")
|
_REQUIRED_KEYS = ("base_id", "hmac_key")
|
||||||
_OPTIONAL_KEYS = ("parent_id",)
|
_OPTIONAL_KEYS = ("parent_id",)
|
||||||
|
|
||||||
PROFILER_CONF = settings.OPENSTACK_PROFILER
|
PROFILER_ENABLED = horizon_settings.get_dict_config(
|
||||||
PROFILER_ENABLED = PROFILER_CONF['enabled']
|
'OPENSTACK_PROFILER', 'enabled')
|
||||||
|
|
||||||
|
|
||||||
class ProfilerClientMiddleware(object):
|
class ProfilerClientMiddleware(object):
|
||||||
@ -60,7 +61,8 @@ class ProfilerClientMiddleware(object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if 'profile_page' in request.COOKIES:
|
if 'profile_page' in request.COOKIES:
|
||||||
hmac_key = PROFILER_CONF['keys'][0]
|
hmac_key = horizon_settings.get_dict_config(
|
||||||
|
'OPENSTACK_PROFILER', 'keys')[0]
|
||||||
profiler.init(hmac_key)
|
profiler.init(hmac_key)
|
||||||
for hdr_key, hdr_value in web.get_trace_id_headers().items():
|
for hdr_key, hdr_value in web.get_trace_id_headers().items():
|
||||||
request.META[hdr_key] = hdr_value
|
request.META[hdr_key] = hdr_value
|
||||||
@ -69,11 +71,14 @@ class ProfilerClientMiddleware(object):
|
|||||||
|
|
||||||
class ProfilerMiddleware(object):
|
class ProfilerMiddleware(object):
|
||||||
def __init__(self, get_response):
|
def __init__(self, get_response):
|
||||||
self.name = PROFILER_CONF['facility_name']
|
self.name = horizon_settings.get_dict_config(
|
||||||
self.hmac_keys = PROFILER_CONF['keys']
|
'OPENSTACK_PROFILER', 'facility_name')
|
||||||
|
self.hmac_keys = horizon_settings.get_dict_config(
|
||||||
|
'OPENSTACK_PROFILER', 'keys')
|
||||||
self.get_response = get_response
|
self.get_response = get_response
|
||||||
if PROFILER_ENABLED:
|
if PROFILER_ENABLED:
|
||||||
api.init_notifier(PROFILER_CONF['notifier_connection_string'])
|
api.init_notifier(horizon_settings.get_dict_config(
|
||||||
|
'OPENSTACK_PROFILER', 'notifier_connection_string'))
|
||||||
else:
|
else:
|
||||||
raise exceptions.MiddlewareNotUsed()
|
raise exceptions.MiddlewareNotUsed()
|
||||||
|
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import horizon
|
import horizon
|
||||||
|
from horizon.utils import settings as horizon_settings
|
||||||
|
|
||||||
|
|
||||||
if settings.OPENSTACK_PROFILER['enabled']:
|
if horizon_settings.get_dict_config('OPENSTACK_PROFILER', 'enabled'):
|
||||||
class Profiler(horizon.Panel):
|
class Profiler(horizon.Panel):
|
||||||
name = _("OpenStack Profiler")
|
name = _("OpenStack Profiler")
|
||||||
slug = 'profiler'
|
slug = 'profiler'
|
||||||
|
@ -16,15 +16,15 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from horizon.browsers.views import AngularIndexView
|
from horizon.browsers.views import AngularIndexView
|
||||||
from openstack_dashboard.dashboards.admin.flavors import views
|
from openstack_dashboard.dashboards.admin.flavors import views
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
if settings.ANGULAR_FEATURES['flavors_panel']:
|
if setting_utils.get_dict_config('ANGULAR_FEATURES', 'flavors_panel'):
|
||||||
title = _("Flavors")
|
title = _("Flavors")
|
||||||
# New angular panel
|
# New angular panel
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
@ -13,11 +13,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import horizon
|
import horizon
|
||||||
|
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
class AdminFloatingIps(horizon.Panel):
|
class AdminFloatingIps(horizon.Panel):
|
||||||
name = _("Floating IPs")
|
name = _("Floating IPs")
|
||||||
@ -27,5 +28,5 @@ class AdminFloatingIps(horizon.Panel):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def can_register():
|
def can_register():
|
||||||
network_config = settings.OPENSTACK_NEUTRON_NETWORK
|
return setting_utils.get_dict_config(
|
||||||
return network_config['enable_router']
|
'OPENSTACK_NEUTRON_NETWORK', 'enable_router')
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from horizon.browsers.views import AngularIndexView
|
from horizon.browsers.views import AngularIndexView
|
||||||
from openstack_dashboard.dashboards.admin.images import views
|
from openstack_dashboard.dashboards.admin.images import views
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
if settings.ANGULAR_FEATURES['images_panel']:
|
if setting_utils.get_dict_config('ANGULAR_FEATURES', 'images_panel'):
|
||||||
title = _("Images")
|
title = _("Images")
|
||||||
# New angular images
|
# New angular images
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
@ -21,7 +21,6 @@ import logging
|
|||||||
from oslo_utils import units
|
from oslo_utils import units
|
||||||
from six.moves import builtins
|
from six.moves import builtins
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@ -33,6 +32,7 @@ from horizon import tables
|
|||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
from openstack_dashboard.dashboards.project.images.images import views
|
from openstack_dashboard.dashboards.project.images.images import views
|
||||||
from openstack_dashboard import policy
|
from openstack_dashboard import policy
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
from openstack_dashboard.dashboards.admin.images import forms as project_forms
|
from openstack_dashboard.dashboards.admin.images import forms as project_forms
|
||||||
from openstack_dashboard.dashboards.admin.images \
|
from openstack_dashboard.dashboards.admin.images \
|
||||||
@ -65,8 +65,8 @@ class IndexView(tables.DataTableView):
|
|||||||
return images
|
return images
|
||||||
filters = self.get_filters()
|
filters = self.get_filters()
|
||||||
|
|
||||||
filter_first = settings.FILTER_DATA_FIRST
|
if (setting_utils.get_dict_config('FILTER_DATA_FIRST',
|
||||||
if (filter_first['admin.images'] and
|
'admin.images') and
|
||||||
len(filters) == len(self.DEFAULT_FILTERS)):
|
len(filters) == len(self.DEFAULT_FILTERS)):
|
||||||
self._prev = False
|
self._prev = False
|
||||||
self._more = False
|
self._more = False
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django import template
|
from django import template
|
||||||
from django.template import defaultfilters as filters
|
from django.template import defaultfilters as filters
|
||||||
from django import urls
|
from django import urls
|
||||||
@ -20,6 +19,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
from horizon import tables
|
from horizon import tables
|
||||||
from horizon.utils import filters as utils_filters
|
from horizon.utils import filters as utils_filters
|
||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
SERVICE_ENABLED = "enabled"
|
SERVICE_ENABLED = "enabled"
|
||||||
@ -187,8 +187,8 @@ class NetworkL3AgentRoutersLinkAction(tables.LinkAction):
|
|||||||
verbose_name = _("View Routers")
|
verbose_name = _("View Routers")
|
||||||
|
|
||||||
def allowed(self, request, datum):
|
def allowed(self, request, datum):
|
||||||
network_config = settings.OPENSTACK_NEUTRON_NETWORK
|
if not setting_utils.get_dict_config('OPENSTACK_NEUTRON_NETWORK',
|
||||||
if not network_config['enable_router']:
|
'enable_router'):
|
||||||
return False
|
return False
|
||||||
# Determine whether this action is allowed for the current request.
|
# Determine whether this action is allowed for the current request.
|
||||||
return datum.agent_type == "L3 agent"
|
return datum.agent_type == "L3 agent"
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@ -38,6 +37,7 @@ from openstack_dashboard.dashboards.project.instances import views
|
|||||||
from openstack_dashboard.dashboards.project.instances.workflows \
|
from openstack_dashboard.dashboards.project.instances.workflows \
|
||||||
import update_instance
|
import update_instance
|
||||||
from openstack_dashboard.utils import futurist_utils
|
from openstack_dashboard.utils import futurist_utils
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
# re-use console from project.instances.views to make reflection work
|
# re-use console from project.instances.views to make reflection work
|
||||||
@ -142,8 +142,8 @@ class AdminIndexView(tables.PagedTableMixin, tables.DataTableView):
|
|||||||
# If filter_first is set and if there are not other filters
|
# If filter_first is set and if there are not other filters
|
||||||
# selected, then search criteria must be provided and return an empty
|
# selected, then search criteria must be provided and return an empty
|
||||||
# list
|
# list
|
||||||
filter_first = settings.FILTER_DATA_FIRST
|
if (setting_utils.get_dict_config('FILTER_DATA_FIRST',
|
||||||
if (filter_first['admin.instances'] and
|
'admin.instances') and
|
||||||
len(search_opts) == len(default_search_opts)):
|
len(search_opts) == len(default_search_opts)):
|
||||||
self._needs_filter_first = True
|
self._needs_filter_first = True
|
||||||
self._more = False
|
self._more = False
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@ -23,6 +22,7 @@ from horizon import forms
|
|||||||
from horizon import messages
|
from horizon import messages
|
||||||
|
|
||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -171,14 +171,15 @@ class CreateNetwork(forms.SelfHandlingForm):
|
|||||||
is_extension_supported = False
|
is_extension_supported = False
|
||||||
|
|
||||||
if is_extension_supported:
|
if is_extension_supported:
|
||||||
neutron_settings = settings.OPENSTACK_NEUTRON_NETWORK
|
|
||||||
self.seg_id_range = SEGMENTATION_ID_RANGE.copy()
|
self.seg_id_range = SEGMENTATION_ID_RANGE.copy()
|
||||||
seg_id_range = neutron_settings['segmentation_id_range']
|
seg_id_range = setting_utils.get_dict_config(
|
||||||
|
'OPENSTACK_NEUTRON_NETWORK', 'segmentation_id_range')
|
||||||
if seg_id_range:
|
if seg_id_range:
|
||||||
self.seg_id_range.update(seg_id_range)
|
self.seg_id_range.update(seg_id_range)
|
||||||
|
|
||||||
self.provider_types = PROVIDER_TYPES.copy()
|
self.provider_types = PROVIDER_TYPES.copy()
|
||||||
extra_provider_types = neutron_settings['extra_provider_types']
|
extra_provider_types = setting_utils.get_dict_config(
|
||||||
|
'OPENSTACK_NEUTRON_NETWORK', 'extra_provider_types')
|
||||||
if extra_provider_types:
|
if extra_provider_types:
|
||||||
self.provider_types.update(extra_provider_types)
|
self.provider_types.update(extra_provider_types)
|
||||||
|
|
||||||
@ -189,8 +190,8 @@ class CreateNetwork(forms.SelfHandlingForm):
|
|||||||
net_type for net_type in self.provider_types
|
net_type for net_type in self.provider_types
|
||||||
if self.provider_types[net_type]['require_physical_network']]
|
if self.provider_types[net_type]['require_physical_network']]
|
||||||
|
|
||||||
supported_provider_types = neutron_settings[
|
supported_provider_types = setting_utils.get_dict_config(
|
||||||
'supported_provider_types']
|
'OPENSTACK_NEUTRON_NETWORK', 'supported_provider_types')
|
||||||
if supported_provider_types == ['*']:
|
if supported_provider_types == ['*']:
|
||||||
supported_provider_types = DEFAULT_PROVIDER_TYPES
|
supported_provider_types = DEFAULT_PROVIDER_TYPES
|
||||||
|
|
||||||
@ -215,8 +216,8 @@ class CreateNetwork(forms.SelfHandlingForm):
|
|||||||
for network_type in self.nettypes_with_seg_id)
|
for network_type in self.nettypes_with_seg_id)
|
||||||
self.fields['segmentation_id'].widget.attrs.update(attrs)
|
self.fields['segmentation_id'].widget.attrs.update(attrs)
|
||||||
|
|
||||||
physical_networks = settings.OPENSTACK_NEUTRON_NETWORK[
|
physical_networks = setting_utils.get_dict_config(
|
||||||
'physical_networks']
|
'OPENSTACK_NEUTRON_NETWORK', 'physical_networks')
|
||||||
|
|
||||||
if physical_networks:
|
if physical_networks:
|
||||||
self.fields['physical_network'] = forms.ThemableChoiceField(
|
self.fields['physical_network'] = forms.ThemableChoiceField(
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@ -27,6 +26,7 @@ from openstack_dashboard import api
|
|||||||
from openstack_dashboard.dashboards.project.networks.tabs import OverviewTab
|
from openstack_dashboard.dashboards.project.networks.tabs import OverviewTab
|
||||||
from openstack_dashboard.dashboards.project.networks import views as user_views
|
from openstack_dashboard.dashboards.project.networks import views as user_views
|
||||||
from openstack_dashboard.utils import filters
|
from openstack_dashboard.utils import filters
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
from openstack_dashboard.dashboards.admin.networks.agents import tabs \
|
from openstack_dashboard.dashboards.admin.networks.agents import tabs \
|
||||||
as agents_tabs
|
as agents_tabs
|
||||||
@ -95,8 +95,9 @@ class IndexView(tables.DataTableView):
|
|||||||
# If filter_first is set and if there are not other filters
|
# If filter_first is set and if there are not other filters
|
||||||
# selected, then search criteria must be provided and return an
|
# selected, then search criteria must be provided and return an
|
||||||
# empty list
|
# empty list
|
||||||
filter_first = settings.FILTER_DATA_FIRST
|
if (setting_utils.get_dict_config('FILTER_DATA_FIRST',
|
||||||
if filter_first['admin.networks'] and not search_opts:
|
'admin.networks') and
|
||||||
|
not search_opts):
|
||||||
self._needs_filter_first = True
|
self._needs_filter_first = True
|
||||||
return []
|
return []
|
||||||
self._needs_filter_first = False
|
self._needs_filter_first = False
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import horizon
|
import horizon
|
||||||
|
|
||||||
from openstack_dashboard.api import neutron
|
from openstack_dashboard.api import neutron
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -30,10 +30,10 @@ class RBACPolicies(horizon.Panel):
|
|||||||
|
|
||||||
def allowed(self, context):
|
def allowed(self, context):
|
||||||
request = context['request']
|
request = context['request']
|
||||||
network_config = settings.OPENSTACK_NEUTRON_NETWORK
|
|
||||||
try:
|
try:
|
||||||
return (
|
return (
|
||||||
network_config['enable_rbac_policy'] and
|
setting_utils.get_dict_config(
|
||||||
|
'OPENSTACK_NEUTRON_NETWORK', 'enable_rbac_policy') and
|
||||||
neutron.is_extension_supported(request,
|
neutron.is_extension_supported(request,
|
||||||
extension_alias='rbac-policies')
|
extension_alias='rbac-policies')
|
||||||
)
|
)
|
||||||
|
@ -12,11 +12,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import horizon
|
import horizon
|
||||||
|
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
class Routers(horizon.Panel):
|
class Routers(horizon.Panel):
|
||||||
name = _("Routers")
|
name = _("Routers")
|
||||||
@ -26,5 +27,5 @@ class Routers(horizon.Panel):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def can_register():
|
def can_register():
|
||||||
network_config = settings.OPENSTACK_NEUTRON_NETWORK
|
return setting_utils.get_dict_config(
|
||||||
return network_config['enable_router']
|
'OPENSTACK_NEUTRON_NETWORK', 'enable_router')
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
Views for managing Neutron Routers.
|
Views for managing Neutron Routers.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@ -27,6 +26,7 @@ from openstack_dashboard.dashboards.admin.routers import forms as rforms
|
|||||||
from openstack_dashboard.dashboards.admin.routers import tables as rtbl
|
from openstack_dashboard.dashboards.admin.routers import tables as rtbl
|
||||||
from openstack_dashboard.dashboards.admin.routers import tabs as rtabs
|
from openstack_dashboard.dashboards.admin.routers import tabs as rtabs
|
||||||
from openstack_dashboard.dashboards.project.routers import views as r_views
|
from openstack_dashboard.dashboards.project.routers import views as r_views
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
class IndexView(r_views.IndexView, n_views.IndexView):
|
class IndexView(r_views.IndexView, n_views.IndexView):
|
||||||
@ -50,8 +50,9 @@ class IndexView(r_views.IndexView, n_views.IndexView):
|
|||||||
# If admin_filter_first is set and if there are not other filters
|
# If admin_filter_first is set and if there are not other filters
|
||||||
# selected, then search criteria must be provided and return an
|
# selected, then search criteria must be provided and return an
|
||||||
# empty list
|
# empty list
|
||||||
filter_first = settings.FILTER_DATA_FIRST
|
if (setting_utils.get_dict_config('FILTER_DATA_FIRST',
|
||||||
if filter_first['admin.routers'] and not filters:
|
'admin.routers') and
|
||||||
|
not filters):
|
||||||
self._needs_filter_first = True
|
self._needs_filter_first = True
|
||||||
return []
|
return []
|
||||||
self._needs_filter_first = False
|
self._needs_filter_first = False
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
Admin views for managing volumes and snapshots.
|
Admin views for managing volumes and snapshots.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@ -37,6 +36,7 @@ from openstack_dashboard.dashboards.admin.volumes \
|
|||||||
from openstack_dashboard.dashboards.project.volumes \
|
from openstack_dashboard.dashboards.project.volumes \
|
||||||
import views as volumes_views
|
import views as volumes_views
|
||||||
from openstack_dashboard.utils import futurist_utils
|
from openstack_dashboard.utils import futurist_utils
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
class VolumesView(tables.PagedTableMixin, volumes_views.VolumeTableMixIn,
|
class VolumesView(tables.PagedTableMixin, volumes_views.VolumeTableMixIn,
|
||||||
@ -51,12 +51,12 @@ class VolumesView(tables.PagedTableMixin, volumes_views.VolumeTableMixIn,
|
|||||||
default_filters = {'all_tenants': True}
|
default_filters = {'all_tenants': True}
|
||||||
|
|
||||||
filters = self.get_filters(default_filters.copy())
|
filters = self.get_filters(default_filters.copy())
|
||||||
filter_first = settings.FILTER_DATA_FIRST
|
|
||||||
volumes = []
|
volumes = []
|
||||||
|
|
||||||
self.table.needs_filter_first = False
|
self.table.needs_filter_first = False
|
||||||
|
|
||||||
if (filter_first['admin.volumes'] and
|
if (setting_utils.get_dict_config('FILTER_DATA_FIRST',
|
||||||
|
'admin.volumes') and
|
||||||
len(filters) == len(default_filters)):
|
len(filters) == len(default_filters)):
|
||||||
self.table.needs_filter_first = True
|
self.table.needs_filter_first = True
|
||||||
return volumes
|
return volumes
|
||||||
|
@ -26,6 +26,7 @@ from horizon.utils import memoized
|
|||||||
from horizon import views
|
from horizon import views
|
||||||
|
|
||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
from openstack_dashboard.dashboards.identity.application_credentials \
|
from openstack_dashboard.dashboards.identity.application_credentials \
|
||||||
import forms as project_forms
|
import forms as project_forms
|
||||||
@ -52,8 +53,9 @@ class IndexView(tables.DataTableView):
|
|||||||
# If filter_first is set and if there are not other filters
|
# If filter_first is set and if there are not other filters
|
||||||
# selected, then search criteria must be provided
|
# selected, then search criteria must be provided
|
||||||
# and return an empty list
|
# and return an empty list
|
||||||
filter_first = settings.FILTER_DATA_FIRST
|
if (setting_utils.get_dict_config(
|
||||||
if filter_first['identity.application_credentials'] and not filters:
|
'FILTER_DATA_FIRST',
|
||||||
|
'identity.application_credentials') and not filters):
|
||||||
self._needs_filter_first = True
|
self._needs_filter_first = True
|
||||||
return app_creds
|
return app_creds
|
||||||
|
|
||||||
|
@ -12,16 +12,16 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from horizon.browsers import views
|
from horizon.browsers import views
|
||||||
|
|
||||||
from openstack_dashboard.dashboards.identity.domains import views as legacyView
|
from openstack_dashboard.dashboards.identity.domains import views as legacyView
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
if settings.ANGULAR_FEATURES.get('domains_panel'):
|
if setting_utils.get_dict_config('ANGULAR_FEATURES', 'domains_panel'):
|
||||||
title = _("Domains")
|
title = _("Domains")
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url('', views.AngularIndexView.as_view(title=title), name='index'),
|
url('', views.AngularIndexView.as_view(title=title), name='index'),
|
||||||
|
@ -12,16 +12,16 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
|
|
||||||
from horizon.browsers.views import AngularIndexView
|
from horizon.browsers.views import AngularIndexView
|
||||||
|
|
||||||
from openstack_dashboard.dashboards.identity.groups import panel
|
from openstack_dashboard.dashboards.identity.groups import panel
|
||||||
from openstack_dashboard.dashboards.identity.groups import views
|
from openstack_dashboard.dashboards.identity.groups import views
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
if settings.ANGULAR_FEATURES.get('groups_panel', False):
|
if setting_utils.get_dict_config('ANGULAR_FEATURES', 'groups_panel'):
|
||||||
title = panel.Groups.name
|
title = panel.Groups.name
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', AngularIndexView.as_view(title=title), name='index'),
|
url(r'^$', AngularIndexView.as_view(title=title), name='index'),
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@ -32,6 +31,7 @@ from openstack_dashboard.dashboards.identity.groups \
|
|||||||
from openstack_dashboard.dashboards.identity.groups \
|
from openstack_dashboard.dashboards.identity.groups \
|
||||||
import tables as project_tables
|
import tables as project_tables
|
||||||
from openstack_dashboard.utils import identity
|
from openstack_dashboard.utils import identity
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
class IndexView(tables.DataTableView):
|
class IndexView(tables.DataTableView):
|
||||||
@ -53,8 +53,8 @@ class IndexView(tables.DataTableView):
|
|||||||
# If filter_first is set and if there are not other filters
|
# If filter_first is set and if there are not other filters
|
||||||
# selected, then search criteria must be provided and
|
# selected, then search criteria must be provided and
|
||||||
# return an empty list
|
# return an empty list
|
||||||
filter_first = settings.FILTER_DATA_FIRST
|
if (setting_utils.get_dict_config(
|
||||||
if filter_first['identity.groups'] and not filters:
|
'FILTER_DATA_FIRST', 'identity.groups') and not filters):
|
||||||
self._needs_filter_first = True
|
self._needs_filter_first = True
|
||||||
return groups
|
return groups
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ from openstack_dashboard.dashboards.identity.projects \
|
|||||||
from openstack_dashboard.dashboards.project.overview \
|
from openstack_dashboard.dashboards.project.overview \
|
||||||
import views as project_views
|
import views as project_views
|
||||||
from openstack_dashboard.utils import identity
|
from openstack_dashboard.utils import identity
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
PROJECT_INFO_FIELDS = ("domain_id",
|
PROJECT_INFO_FIELDS = ("domain_id",
|
||||||
"domain_name",
|
"domain_name",
|
||||||
@ -95,8 +96,8 @@ class IndexView(tables.DataTableView):
|
|||||||
# If filter_first is set and if there are not other filters
|
# If filter_first is set and if there are not other filters
|
||||||
# selected, then search criteria must be provided and
|
# selected, then search criteria must be provided and
|
||||||
# return an empty list
|
# return an empty list
|
||||||
filter_first = settings.FILTER_DATA_FIRST
|
if (setting_utils.get_dict_config(
|
||||||
if filter_first['identity.projects'] and not filters:
|
'FILTER_DATA_FIRST', 'identity.projects') and not filters):
|
||||||
self._needs_filter_first = True
|
self._needs_filter_first = True
|
||||||
self._more = False
|
self._more = False
|
||||||
return tenants
|
return tenants
|
||||||
|
@ -12,15 +12,15 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from horizon.browsers.views import AngularIndexView
|
from horizon.browsers.views import AngularIndexView
|
||||||
|
|
||||||
from openstack_dashboard.dashboards.identity.roles import views
|
from openstack_dashboard.dashboards.identity.roles import views
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
if settings.ANGULAR_FEATURES.get('roles_panel', False):
|
if setting_utils.get_dict_config('ANGULAR_FEATURES', 'roles_panel'):
|
||||||
# New angular panel
|
# New angular panel
|
||||||
title = _('Roles')
|
title = _('Roles')
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@ -25,6 +24,7 @@ from horizon.utils import memoized
|
|||||||
|
|
||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
from openstack_dashboard import policy
|
from openstack_dashboard import policy
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
from openstack_dashboard.dashboards.identity.roles \
|
from openstack_dashboard.dashboards.identity.roles \
|
||||||
import forms as project_forms
|
import forms as project_forms
|
||||||
@ -51,8 +51,8 @@ class IndexView(tables.DataTableView):
|
|||||||
# If filter_first is set and if there are not other filters
|
# If filter_first is set and if there are not other filters
|
||||||
# selected, then search criteria must be provided
|
# selected, then search criteria must be provided
|
||||||
# and return an empty list
|
# and return an empty list
|
||||||
filter_first = settings.FILTER_DATA_FIRST
|
if (setting_utils.get_dict_config(
|
||||||
if filter_first['identity.roles'] and not filters:
|
'FILTER_DATA_FIRST', 'identity.roles') and not filters):
|
||||||
self._needs_filter_first = True
|
self._needs_filter_first = True
|
||||||
return roles
|
return roles
|
||||||
|
|
||||||
|
@ -16,16 +16,15 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from horizon.browsers.views import AngularIndexView
|
from horizon.browsers.views import AngularIndexView
|
||||||
from openstack_dashboard.dashboards.identity.users import views
|
from openstack_dashboard.dashboards.identity.users import views
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
if settings.ANGULAR_FEATURES.get('users_panel', False):
|
if setting_utils.get_dict_config('ANGULAR_FEATURES', 'users_panel'):
|
||||||
title = _("Users")
|
title = _("Users")
|
||||||
# new angular panel
|
# new angular panel
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
@ -43,6 +43,7 @@ from openstack_dashboard.dashboards.identity.users \
|
|||||||
from openstack_dashboard.dashboards.identity.users \
|
from openstack_dashboard.dashboards.identity.users \
|
||||||
import tabs as user_tabs
|
import tabs as user_tabs
|
||||||
from openstack_dashboard.utils import identity
|
from openstack_dashboard.utils import identity
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -67,8 +68,8 @@ class IndexView(tables.DataTableView):
|
|||||||
# If filter_first is set and if there are not other filters
|
# If filter_first is set and if there are not other filters
|
||||||
# selected, then search criteria must be provided
|
# selected, then search criteria must be provided
|
||||||
# and return an empty list
|
# and return an empty list
|
||||||
filter_first = settings.FILTER_DATA_FIRST
|
if (setting_utils.get_dict_config(
|
||||||
if filter_first['identity.users'] and not filters:
|
'FILTER_DATA_FIRST', 'identity.users') and not filters):
|
||||||
self._needs_filter_first = True
|
self._needs_filter_first = True
|
||||||
return users
|
return users
|
||||||
|
|
||||||
|
@ -12,11 +12,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import horizon
|
import horizon
|
||||||
|
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
class FloatingIps(horizon.Panel):
|
class FloatingIps(horizon.Panel):
|
||||||
name = _("Floating IPs")
|
name = _("Floating IPs")
|
||||||
@ -25,5 +26,5 @@ class FloatingIps(horizon.Panel):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def can_register():
|
def can_register():
|
||||||
network_config = settings.OPENSTACK_NEUTRON_NETWORK
|
return setting_utils.get_dict_config(
|
||||||
return network_config['enable_router']
|
'OPENSTACK_NEUTRON_NETWORK', 'enable_router')
|
||||||
|
@ -16,15 +16,15 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from horizon.browsers.views import AngularIndexView
|
from horizon.browsers.views import AngularIndexView
|
||||||
from openstack_dashboard.dashboards.project.images.images import views
|
from openstack_dashboard.dashboards.project.images.images import views
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
if settings.ANGULAR_FEATURES['images_panel']:
|
if setting_utils.get_dict_config('ANGULAR_FEATURES', 'images_panel'):
|
||||||
title = _("Images")
|
title = _("Images")
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^(?P<image_id>[^/]+)/$', AngularIndexView.as_view(title=title),
|
url(r'^(?P<image_id>[^/]+)/$', AngularIndexView.as_view(title=title),
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.conf.urls import include
|
from django.conf.urls import include
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@ -27,9 +26,10 @@ from openstack_dashboard.dashboards.project.images.images \
|
|||||||
from openstack_dashboard.dashboards.project.images.snapshots \
|
from openstack_dashboard.dashboards.project.images.snapshots \
|
||||||
import urls as snapshot_urls
|
import urls as snapshot_urls
|
||||||
from openstack_dashboard.dashboards.project.images import views
|
from openstack_dashboard.dashboards.project.images import views
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
if settings.ANGULAR_FEATURES['images_panel']:
|
if setting_utils.get_dict_config('ANGULAR_FEATURES', 'images_panel'):
|
||||||
title = _("Images")
|
title = _("Images")
|
||||||
# New angular images
|
# New angular images
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
@ -40,6 +40,7 @@ from horizon import workflows
|
|||||||
|
|
||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
from openstack_dashboard.utils import filters
|
from openstack_dashboard.utils import filters
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
from openstack_dashboard.dashboards.project.instances \
|
from openstack_dashboard.dashboards.project.instances \
|
||||||
import console as project_console
|
import console as project_console
|
||||||
@ -266,8 +267,8 @@ class LaunchInstanceView(workflows.WorkflowView):
|
|||||||
initial = super(LaunchInstanceView, self).get_initial()
|
initial = super(LaunchInstanceView, self).get_initial()
|
||||||
initial['project_id'] = self.request.user.tenant_id
|
initial['project_id'] = self.request.user.tenant_id
|
||||||
initial['user_id'] = self.request.user.id
|
initial['user_id'] = self.request.user.id
|
||||||
defaults = settings.LAUNCH_INSTANCE_DEFAULTS
|
initial['config_drive'] = setting_utils.get_dict_config(
|
||||||
initial['config_drive'] = defaults['config_drive']
|
'LAUNCH_INSTANCE_DEFAULTS', 'config_drive')
|
||||||
return initial
|
return initial
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,15 +16,15 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from horizon.browsers import views
|
from horizon.browsers import views
|
||||||
from openstack_dashboard.dashboards.project.key_pairs import views as \
|
from openstack_dashboard.dashboards.project.key_pairs import views as \
|
||||||
legacy_views
|
legacy_views
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
if settings.ANGULAR_FEATURES.get('key_pairs_panel'):
|
if setting_utils.get_dict_config('ANGULAR_FEATURES', 'key_pairs_panel'):
|
||||||
title = _("Key Pairs")
|
title = _("Key Pairs")
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url('', views.AngularIndexView.as_view(title=title), name='index'),
|
url('', views.AngularIndexView.as_view(title=title), name='index'),
|
||||||
|
@ -15,6 +15,7 @@ from django.conf import settings
|
|||||||
from openstack_dashboard.api import base
|
from openstack_dashboard.api import base
|
||||||
from openstack_dashboard import policy
|
from openstack_dashboard import policy
|
||||||
from openstack_dashboard.usage import quotas
|
from openstack_dashboard.usage import quotas
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
def _quota_exceeded(request, quota):
|
def _quota_exceeded(request, quota):
|
||||||
@ -28,8 +29,6 @@ def get_context(request, context=None):
|
|||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
|
|
||||||
network_config = settings.OPENSTACK_NEUTRON_NETWORK
|
|
||||||
|
|
||||||
context['launch_instance_allowed'] = policy.check(
|
context['launch_instance_allowed'] = policy.check(
|
||||||
(("compute", "os_compute_api:servers:create"),), request)
|
(("compute", "os_compute_api:servers:create"),), request)
|
||||||
context['instance_quota_exceeded'] = _quota_exceeded(request, 'instances')
|
context['instance_quota_exceeded'] = _quota_exceeded(request, 'instances')
|
||||||
@ -37,7 +36,8 @@ def get_context(request, context=None):
|
|||||||
(("network", "create_network"),), request)
|
(("network", "create_network"),), request)
|
||||||
context['network_quota_exceeded'] = _quota_exceeded(request, 'network')
|
context['network_quota_exceeded'] = _quota_exceeded(request, 'network')
|
||||||
context['create_router_allowed'] = (
|
context['create_router_allowed'] = (
|
||||||
network_config['enable_router'] and
|
setting_utils.get_dict_config('OPENSTACK_NEUTRON_NETWORK',
|
||||||
|
'enable_router') and
|
||||||
policy.check((("network", "create_router"),), request))
|
policy.check((("network", "create_router"),), request))
|
||||||
context['router_quota_exceeded'] = _quota_exceeded(request, 'router')
|
context['router_quota_exceeded'] = _quota_exceeded(request, 'router')
|
||||||
context['console_type'] = settings.CONSOLE_TYPE
|
context['console_type'] = settings.CONSOLE_TYPE
|
||||||
|
@ -76,6 +76,7 @@ from openstack_dashboard.dashboards.project.routers.tables import \
|
|||||||
from openstack_dashboard.dashboards.project.routers import\
|
from openstack_dashboard.dashboards.project.routers import\
|
||||||
views as r_views
|
views as r_views
|
||||||
from openstack_dashboard import policy
|
from openstack_dashboard import policy
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
# List of known server statuses that wont connect to the console
|
# List of known server statuses that wont connect to the console
|
||||||
console_invalid_status = {
|
console_invalid_status = {
|
||||||
@ -214,8 +215,8 @@ class JSONView(View):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def is_router_enabled(self):
|
def is_router_enabled(self):
|
||||||
network_config = settings.OPENSTACK_NEUTRON_NETWORK
|
return setting_utils.get_dict_config('OPENSTACK_NEUTRON_NETWORK',
|
||||||
return network_config['enable_router']
|
'enable_router')
|
||||||
|
|
||||||
def add_resource_url(self, view, resources):
|
def add_resource_url(self, view, resources):
|
||||||
tenant_id = self.request.user.tenant_id
|
tenant_id = self.request.user.tenant_id
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
@ -26,6 +25,7 @@ from horizon import workflows
|
|||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
from openstack_dashboard.dashboards.project.networks.ports import sg_base
|
from openstack_dashboard.dashboards.project.networks.ports import sg_base
|
||||||
from openstack_dashboard.utils import filters
|
from openstack_dashboard.utils import filters
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -160,8 +160,8 @@ class CreatePortInfoAction(workflows.Action):
|
|||||||
return is_supproted
|
return is_supproted
|
||||||
|
|
||||||
def _populate_vnic_type_choices(self, request):
|
def _populate_vnic_type_choices(self, request):
|
||||||
neutron_settings = settings.OPENSTACK_NEUTRON_NETWORK
|
supported_vnic_types = setting_utils.get_dict_config(
|
||||||
supported_vnic_types = neutron_settings['supported_vnic_types']
|
'OPENSTACK_NEUTRON_NETWORK', 'supported_vnic_types')
|
||||||
# When a list of VNIC types is empty, hide the corresponding field.
|
# When a list of VNIC types is empty, hide the corresponding field.
|
||||||
if not supported_vnic_types:
|
if not supported_vnic_types:
|
||||||
del self.fields['binding__vnic_type']
|
del self.fields['binding__vnic_type']
|
||||||
@ -314,8 +314,8 @@ class UpdatePortInfoAction(workflows.Action):
|
|||||||
super(UpdatePortInfoAction, self).__init__(request, *args, **kwargs)
|
super(UpdatePortInfoAction, self).__init__(request, *args, **kwargs)
|
||||||
try:
|
try:
|
||||||
if api.neutron.is_extension_supported(request, 'binding'):
|
if api.neutron.is_extension_supported(request, 'binding'):
|
||||||
neutron_settings = settings.OPENSTACK_NEUTRON_NETWORK
|
supported_vnic_types = setting_utils.get_dict_config(
|
||||||
supported_vnic_types = neutron_settings['supported_vnic_types']
|
'OPENSTACK_NEUTRON_NETWORK', 'supported_vnic_types')
|
||||||
if supported_vnic_types:
|
if supported_vnic_types:
|
||||||
if supported_vnic_types == ['*']:
|
if supported_vnic_types == ['*']:
|
||||||
vnic_type_choices = api.neutron.VNIC_TYPES
|
vnic_type_choices = api.neutron.VNIC_TYPES
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
"""
|
"""
|
||||||
Views for managing Neutron Networks.
|
Views for managing Neutron Networks.
|
||||||
"""
|
"""
|
||||||
from django.conf import settings
|
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
@ -29,6 +28,7 @@ from horizon import workflows
|
|||||||
|
|
||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
from openstack_dashboard.utils import filters
|
from openstack_dashboard.utils import filters
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
from openstack_dashboard.dashboards.project.networks \
|
from openstack_dashboard.dashboards.project.networks \
|
||||||
import forms as project_forms
|
import forms as project_forms
|
||||||
@ -67,9 +67,9 @@ class DefaultSubnetWorkflowMixin(object):
|
|||||||
|
|
||||||
def get_default_dns_servers(self):
|
def get_default_dns_servers(self):
|
||||||
# this returns the default dns servers to be used for new subnets
|
# this returns the default dns servers to be used for new subnets
|
||||||
dns_default = "\n".join(
|
default_dns_nameservers = setting_utils.get_dict_config(
|
||||||
settings.OPENSTACK_NEUTRON_NETWORK['default_dns_nameservers'])
|
'OPENSTACK_NEUTRON_NETWORK', 'default_dns_nameservers')
|
||||||
return dns_default
|
return "\n".join(default_dns_nameservers)
|
||||||
|
|
||||||
|
|
||||||
class CreateView(DefaultSubnetWorkflowMixin, workflows.WorkflowView):
|
class CreateView(DefaultSubnetWorkflowMixin, workflows.WorkflowView):
|
||||||
|
@ -28,6 +28,7 @@ from horizon import workflows
|
|||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
from openstack_dashboard.dashboards.project.networks.subnets import utils
|
from openstack_dashboard.dashboards.project.networks.subnets import utils
|
||||||
from openstack_dashboard import policy
|
from openstack_dashboard import policy
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@ -205,7 +206,8 @@ class CreateSubnetInfoAction(workflows.Action):
|
|||||||
def __init__(self, request, context, *args, **kwargs):
|
def __init__(self, request, context, *args, **kwargs):
|
||||||
super(CreateSubnetInfoAction, self).__init__(request, context, *args,
|
super(CreateSubnetInfoAction, self).__init__(request, context, *args,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
if not settings.OPENSTACK_NEUTRON_NETWORK['enable_ipv6']:
|
if not setting_utils.get_dict_config('OPENSTACK_NEUTRON_NETWORK',
|
||||||
|
'enable_ipv6'):
|
||||||
self.fields['ip_version'].widget = forms.HiddenInput()
|
self.fields['ip_version'].widget = forms.HiddenInput()
|
||||||
self.fields['ip_version'].initial = 4
|
self.fields['ip_version'].initial = 4
|
||||||
|
|
||||||
@ -380,7 +382,8 @@ class CreateSubnetDetailAction(workflows.Action):
|
|||||||
def __init__(self, request, context, *args, **kwargs):
|
def __init__(self, request, context, *args, **kwargs):
|
||||||
super(CreateSubnetDetailAction, self).__init__(request, context,
|
super(CreateSubnetDetailAction, self).__init__(request, context,
|
||||||
*args, **kwargs)
|
*args, **kwargs)
|
||||||
if not settings.OPENSTACK_NEUTRON_NETWORK['enable_ipv6']:
|
if not setting_utils.get_dict_config('OPENSTACK_NEUTRON_NETWORK',
|
||||||
|
'enable_ipv6'):
|
||||||
self.fields['ipv6_modes'].widget = forms.HiddenInput()
|
self.fields['ipv6_modes'].widget = forms.HiddenInput()
|
||||||
|
|
||||||
def populate_ipv6_modes_choices(self, request, context):
|
def populate_ipv6_modes_choices(self, request, context):
|
||||||
|
@ -12,11 +12,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import horizon
|
import horizon
|
||||||
|
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
class Routers(horizon.Panel):
|
class Routers(horizon.Panel):
|
||||||
name = _("Routers")
|
name = _("Routers")
|
||||||
@ -25,5 +26,5 @@ class Routers(horizon.Panel):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def can_register():
|
def can_register():
|
||||||
network_config = settings.OPENSTACK_NEUTRON_NETWORK
|
return setting_utils.get_dict_config('OPENSTACK_NEUTRON_NETWORK',
|
||||||
return network_config['enable_router']
|
'enable_router')
|
||||||
|
@ -32,6 +32,7 @@ from horizon.utils import validators as utils_validators
|
|||||||
|
|
||||||
from openstack_dashboard import api
|
from openstack_dashboard import api
|
||||||
from openstack_dashboard.utils import filters
|
from openstack_dashboard.utils import filters
|
||||||
|
from openstack_dashboard.utils import settings as setting_utils
|
||||||
|
|
||||||
|
|
||||||
class GroupBase(forms.SelfHandlingForm):
|
class GroupBase(forms.SelfHandlingForm):
|
||||||
@ -296,7 +297,8 @@ class AddRule(forms.SelfHandlingForm):
|
|||||||
('all', _('All ports')),
|
('all', _('All ports')),
|
||||||
]
|
]
|
||||||
|
|
||||||
if not settings.OPENSTACK_NEUTRON_NETWORK['enable_ipv6']:
|
if not setting_utils.get_dict_config('OPENSTACK_NEUTRON_NETWORK',
|
||||||
|
'enable_ipv6'):
|
||||||
self.fields['cidr'].version = forms.IPv4
|
self.fields['cidr'].version = forms.IPv4
|
||||||
self.fields['ethertype'].widget = forms.TextInput(
|
self.fields['ethertype'].widget = forms.TextInput(
|
||||||
attrs={'readonly': 'readonly'})
|
attrs={'readonly': 'readonly'})
|
||||||
|
39
openstack_dashboard/test/unit/utils/test_settings.py
Normal file
39
openstack_dashboard/test/unit/utils/test_settings.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# 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.test import utils as test_utils
|
||||||
|
|
||||||
|
from openstack_dashboard.test import helpers as test
|
||||||
|
from openstack_dashboard.utils import settings as utils
|
||||||
|
|
||||||
|
|
||||||
|
class SettingsTests(test.TestCase):
|
||||||
|
def test_get_dict_config_default_value(self):
|
||||||
|
self.assertEqual(
|
||||||
|
True,
|
||||||
|
utils.get_dict_config('OPENSTACK_NEUTRON_NETWORK',
|
||||||
|
'enable_router'))
|
||||||
|
|
||||||
|
@test_utils.override_settings(OPENSTACK_NEUTRON_NETWORK={
|
||||||
|
'enable_router': False})
|
||||||
|
def test_get_dict_config_configured_value(self):
|
||||||
|
self.assertEqual(
|
||||||
|
False,
|
||||||
|
utils.get_dict_config('OPENSTACK_NEUTRON_NETWORK',
|
||||||
|
'enable_router'))
|
||||||
|
|
||||||
|
@test_utils.override_settings(OPENSTACK_NEUTRON_NETWORK={})
|
||||||
|
def test_get_dict_config_missing_key(self):
|
||||||
|
self.assertEqual(
|
||||||
|
True,
|
||||||
|
utils.get_dict_config('OPENSTACK_NEUTRON_NETWORK',
|
||||||
|
'enable_router'))
|
@ -21,9 +21,34 @@ from django.conf import settings
|
|||||||
|
|
||||||
from horizon.utils import file_discovery
|
from horizon.utils import file_discovery
|
||||||
from horizon.utils import functions as utils
|
from horizon.utils import functions as utils
|
||||||
|
from openstack_dashboard import defaults
|
||||||
from openstack_dashboard import theme_settings
|
from openstack_dashboard import theme_settings
|
||||||
|
|
||||||
|
|
||||||
|
def get_dict_config(name, key):
|
||||||
|
"""Get a config value from a dict-type setting.
|
||||||
|
|
||||||
|
If a specified key does not exist in a requested setting,
|
||||||
|
the default value defined in openstack_dashboard.defaults
|
||||||
|
is considered.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
This function should not be used from horizon plugins
|
||||||
|
as it only checks openstack_dashboard.defaults
|
||||||
|
when accessing default values.
|
||||||
|
|
||||||
|
:param name: Name of a dict-type setting
|
||||||
|
:param key: Key name of the dict-type setting
|
||||||
|
:raises KeyError: Raised if no default value is found for a requested key.
|
||||||
|
(This can happen only for horizon plugin codes.)
|
||||||
|
"""
|
||||||
|
config = getattr(settings, name)
|
||||||
|
if key in config:
|
||||||
|
return config[key]
|
||||||
|
return getattr(defaults, name)[key]
|
||||||
|
|
||||||
|
|
||||||
def import_submodules(module):
|
def import_submodules(module):
|
||||||
"""Import all submodules and make them available in a dict."""
|
"""Import all submodules and make them available in a dict."""
|
||||||
submodules = {}
|
submodules = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user