diff --git a/openstack_dashboard/dashboards/admin/flavors/tests.py b/openstack_dashboard/dashboards/admin/flavors/tests.py index fee42c6b40..c72a59058e 100644 --- a/openstack_dashboard/dashboards/admin/flavors/tests.py +++ b/openstack_dashboard/dashboards/admin/flavors/tests.py @@ -161,7 +161,7 @@ class FlavorsViewTests(test.BaseAdminViewTests): @test.create_mocks({api.nova: ('flavor_list_paged',), flavors.Flavor: ('get_keys',), }) def test_index_form_action_with_pagination(self): - page_size = getattr(settings, 'API_RESULT_PAGE_SIZE', 1) + page_size = settings.API_RESULT_PAGE_SIZE flavors_list = self.flavors.list()[:2] self.mock_flavor_list_paged.side_effect = [ (flavors_list[:page_size], False, False), diff --git a/openstack_dashboard/dashboards/admin/floating_ips/panel.py b/openstack_dashboard/dashboards/admin/floating_ips/panel.py index 589457ca07..96405c97df 100644 --- a/openstack_dashboard/dashboards/admin/floating_ips/panel.py +++ b/openstack_dashboard/dashboards/admin/floating_ips/panel.py @@ -27,5 +27,5 @@ class AdminFloatingIps(horizon.Panel): @staticmethod def can_register(): - network_config = getattr(settings, 'OPENSTACK_NEUTRON_NETWORK', {}) - return network_config.get('enable_router', True) + network_config = settings.OPENSTACK_NEUTRON_NETWORK + return network_config['enable_router'] diff --git a/openstack_dashboard/dashboards/admin/images/views.py b/openstack_dashboard/dashboards/admin/images/views.py index ba39744602..d3aa16f71d 100644 --- a/openstack_dashboard/dashboards/admin/images/views.py +++ b/openstack_dashboard/dashboards/admin/images/views.py @@ -65,9 +65,9 @@ class IndexView(tables.DataTableView): return images filters = self.get_filters() - filter_first = getattr(settings, 'FILTER_DATA_FIRST', {}) - if filter_first.get('admin.images', False) and \ - len(filters) == len(self.DEFAULT_FILTERS): + filter_first = settings.FILTER_DATA_FIRST + if (filter_first['admin.images'] and + len(filters) == len(self.DEFAULT_FILTERS)): self._prev = False self._more = False self._needs_filter_first = True diff --git a/openstack_dashboard/dashboards/admin/info/tables.py b/openstack_dashboard/dashboards/admin/info/tables.py index 99a7ece182..eeb42da695 100644 --- a/openstack_dashboard/dashboards/admin/info/tables.py +++ b/openstack_dashboard/dashboards/admin/info/tables.py @@ -187,8 +187,8 @@ class NetworkL3AgentRoutersLinkAction(tables.LinkAction): verbose_name = _("View Routers") def allowed(self, request, datum): - network_config = getattr(settings, 'OPENSTACK_NEUTRON_NETWORK', {}) - if not network_config.get('enable_router', True): + network_config = settings.OPENSTACK_NEUTRON_NETWORK + if not network_config['enable_router']: return False # Determine whether this action is allowed for the current request. return datum.agent_type == "L3 agent" diff --git a/openstack_dashboard/dashboards/admin/instances/views.py b/openstack_dashboard/dashboards/admin/instances/views.py index 006185bf85..f40a8e2177 100644 --- a/openstack_dashboard/dashboards/admin/instances/views.py +++ b/openstack_dashboard/dashboards/admin/instances/views.py @@ -142,8 +142,8 @@ class AdminIndexView(tables.PagedTableMixin, tables.DataTableView): # If filter_first is set and if there are not other filters # selected, then search criteria must be provided and return an empty # list - filter_first = getattr(settings, 'FILTER_DATA_FIRST', {}) - if (filter_first.get('admin.instances', False) and + filter_first = settings.FILTER_DATA_FIRST + if (filter_first['admin.instances'] and len(search_opts) == len(default_search_opts)): self._needs_filter_first = True self._more = False diff --git a/openstack_dashboard/dashboards/admin/networks/forms.py b/openstack_dashboard/dashboards/admin/networks/forms.py index 341f882d41..05d997b868 100644 --- a/openstack_dashboard/dashboards/admin/networks/forms.py +++ b/openstack_dashboard/dashboards/admin/networks/forms.py @@ -169,15 +169,14 @@ class CreateNetwork(forms.SelfHandlingForm): is_extension_supported = False if is_extension_supported: - neutron_settings = getattr(settings, - 'OPENSTACK_NEUTRON_NETWORK', {}) + neutron_settings = settings.OPENSTACK_NEUTRON_NETWORK self.seg_id_range = SEGMENTATION_ID_RANGE.copy() - seg_id_range = neutron_settings.get('segmentation_id_range') + seg_id_range = neutron_settings['segmentation_id_range'] if seg_id_range: self.seg_id_range.update(seg_id_range) self.provider_types = PROVIDER_TYPES.copy() - extra_provider_types = neutron_settings.get('extra_provider_types') + extra_provider_types = neutron_settings['extra_provider_types'] if extra_provider_types: self.provider_types.update(extra_provider_types) @@ -188,8 +187,8 @@ class CreateNetwork(forms.SelfHandlingForm): net_type for net_type in self.provider_types if self.provider_types[net_type]['require_physical_network']] - supported_provider_types = neutron_settings.get( - 'supported_provider_types', DEFAULT_PROVIDER_TYPES) + supported_provider_types = neutron_settings[ + 'supported_provider_types'] if supported_provider_types == ['*']: supported_provider_types = DEFAULT_PROVIDER_TYPES @@ -214,9 +213,8 @@ class CreateNetwork(forms.SelfHandlingForm): for network_type in self.nettypes_with_seg_id) self.fields['segmentation_id'].widget.attrs.update(attrs) - physical_networks = getattr(settings, - 'OPENSTACK_NEUTRON_NETWORK', {} - ).get('physical_networks', []) + physical_networks = settings.OPENSTACK_NEUTRON_NETWORK[ + 'physical_networks'] if physical_networks: self.fields['physical_network'] = forms.ThemableChoiceField( diff --git a/openstack_dashboard/dashboards/admin/networks/views.py b/openstack_dashboard/dashboards/admin/networks/views.py index 61b9223a46..03410a2a07 100644 --- a/openstack_dashboard/dashboards/admin/networks/views.py +++ b/openstack_dashboard/dashboards/admin/networks/views.py @@ -95,9 +95,8 @@ class IndexView(tables.DataTableView): # If filter_first is set and if there are not other filters # selected, then search criteria must be provided and return an # empty list - filter_first = getattr(settings, 'FILTER_DATA_FIRST', {}) - if filter_first.get('admin.networks', False) and \ - not search_opts: + filter_first = settings.FILTER_DATA_FIRST + if filter_first['admin.networks'] and not search_opts: self._needs_filter_first = True return [] self._needs_filter_first = False diff --git a/openstack_dashboard/dashboards/admin/overview/views.py b/openstack_dashboard/dashboards/admin/overview/views.py index cc258aad4e..a79892882b 100644 --- a/openstack_dashboard/dashboards/admin/overview/views.py +++ b/openstack_dashboard/dashboards/admin/overview/views.py @@ -51,7 +51,7 @@ class GlobalOverview(usage.UsageView): def get_context_data(self, **kwargs): context = super(GlobalOverview, self).get_context_data(**kwargs) - context['monitoring'] = getattr(settings, 'EXTERNAL_MONITORING', []) + context['monitoring'] = settings.EXTERNAL_MONITORING return context def get_data(self): diff --git a/openstack_dashboard/dashboards/admin/rbac_policies/panel.py b/openstack_dashboard/dashboards/admin/rbac_policies/panel.py index 72e78f7611..c9429fbf89 100644 --- a/openstack_dashboard/dashboards/admin/rbac_policies/panel.py +++ b/openstack_dashboard/dashboards/admin/rbac_policies/panel.py @@ -30,10 +30,10 @@ class RBACPolicies(horizon.Panel): def allowed(self, context): request = context['request'] - network_config = getattr(settings, 'OPENSTACK_NEUTRON_NETWORK', {}) + network_config = settings.OPENSTACK_NEUTRON_NETWORK try: return ( - network_config.get('enable_rbac_policy', True) and + network_config['enable_rbac_policy'] and neutron.is_extension_supported(request, extension_alias='rbac-policies') ) diff --git a/openstack_dashboard/dashboards/admin/routers/panel.py b/openstack_dashboard/dashboards/admin/routers/panel.py index a525d2ab4f..f11856e95a 100644 --- a/openstack_dashboard/dashboards/admin/routers/panel.py +++ b/openstack_dashboard/dashboards/admin/routers/panel.py @@ -26,5 +26,5 @@ class Routers(horizon.Panel): @staticmethod def can_register(): - network_config = getattr(settings, 'OPENSTACK_NEUTRON_NETWORK', {}) - return network_config.get('enable_router', True) + network_config = settings.OPENSTACK_NEUTRON_NETWORK + return network_config['enable_router'] diff --git a/openstack_dashboard/dashboards/admin/routers/views.py b/openstack_dashboard/dashboards/admin/routers/views.py index 2e74e99728..78e65fd8de 100644 --- a/openstack_dashboard/dashboards/admin/routers/views.py +++ b/openstack_dashboard/dashboards/admin/routers/views.py @@ -50,8 +50,8 @@ class IndexView(r_views.IndexView, n_views.IndexView): # If admin_filter_first is set and if there are not other filters # selected, then search criteria must be provided and return an # empty list - filter_first = getattr(settings, 'FILTER_DATA_FIRST', {}) - if filter_first.get('admin.routers', False) and not filters: + filter_first = settings.FILTER_DATA_FIRST + if filter_first['admin.routers'] and not filters: self._needs_filter_first = True return [] self._needs_filter_first = False diff --git a/openstack_dashboard/dashboards/admin/volumes/views.py b/openstack_dashboard/dashboards/admin/volumes/views.py index 6b4ff822d9..f9571bd11d 100644 --- a/openstack_dashboard/dashboards/admin/volumes/views.py +++ b/openstack_dashboard/dashboards/admin/volumes/views.py @@ -51,13 +51,13 @@ class VolumesView(tables.PagedTableMixin, volumes_views.VolumeTableMixIn, default_filters = {'all_tenants': True} filters = self.get_filters(default_filters.copy()) - filter_first = getattr(settings, 'FILTER_DATA_FIRST', {}) + filter_first = settings.FILTER_DATA_FIRST volumes = [] self.table.needs_filter_first = False - if filter_first.get('admin.volumes', False) and \ - len(filters) == len(default_filters): + if (filter_first['admin.volumes'] and + len(filters) == len(default_filters)): self.table.needs_filter_first = True return volumes diff --git a/openstack_dashboard/dashboards/identity/application_credentials/views.py b/openstack_dashboard/dashboards/identity/application_credentials/views.py index 3475158cfc..b5e61f7fc8 100644 --- a/openstack_dashboard/dashboards/identity/application_credentials/views.py +++ b/openstack_dashboard/dashboards/identity/application_credentials/views.py @@ -54,9 +54,8 @@ class IndexView(tables.DataTableView): # If filter_first is set and if there are not other filters # selected, then search criteria must be provided # and return an empty list - filter_first = getattr(settings, 'FILTER_DATA_FIRST', {}) - if (filter_first.get('identity.application_credentials', False) and - not filters): + filter_first = settings.FILTER_DATA_FIRST + if filter_first['identity.application_credentials'] and not filters: self._needs_filter_first = True return app_creds diff --git a/openstack_dashboard/dashboards/identity/groups/views.py b/openstack_dashboard/dashboards/identity/groups/views.py index ba461f8e0b..8eb96d60e5 100644 --- a/openstack_dashboard/dashboards/identity/groups/views.py +++ b/openstack_dashboard/dashboards/identity/groups/views.py @@ -53,8 +53,8 @@ class IndexView(tables.DataTableView): # If filter_first is set and if there are not other filters # selected, then search criteria must be provided and # return an empty list - filter_first = getattr(settings, 'FILTER_DATA_FIRST', {}) - if filter_first.get('identity.groups', False) and not filters: + filter_first = settings.FILTER_DATA_FIRST + if filter_first['identity.groups'] and not filters: self._needs_filter_first = True return groups diff --git a/openstack_dashboard/dashboards/identity/projects/views.py b/openstack_dashboard/dashboards/identity/projects/views.py index 6d3e842e66..7c0ff4c515 100644 --- a/openstack_dashboard/dashboards/identity/projects/views.py +++ b/openstack_dashboard/dashboards/identity/projects/views.py @@ -95,8 +95,8 @@ class IndexView(tables.DataTableView): # If filter_first is set and if there are not other filters # selected, then search criteria must be provided and # return an empty list - filter_first = getattr(settings, 'FILTER_DATA_FIRST', {}) - if filter_first.get('identity.projects', False) and not filters: + filter_first = settings.FILTER_DATA_FIRST + if filter_first['identity.projects'] and not filters: self._needs_filter_first = True self._more = False return tenants diff --git a/openstack_dashboard/dashboards/identity/roles/views.py b/openstack_dashboard/dashboards/identity/roles/views.py index c829dcfb5b..b2335b406d 100644 --- a/openstack_dashboard/dashboards/identity/roles/views.py +++ b/openstack_dashboard/dashboards/identity/roles/views.py @@ -51,8 +51,8 @@ class IndexView(tables.DataTableView): # If filter_first is set and if there are not other filters # selected, then search criteria must be provided # and return an empty list - filter_first = getattr(settings, 'FILTER_DATA_FIRST', {}) - if filter_first.get('identity.roles', False) and not filters: + filter_first = settings.FILTER_DATA_FIRST + if filter_first['identity.roles'] and not filters: self._needs_filter_first = True return roles diff --git a/openstack_dashboard/dashboards/identity/users/views.py b/openstack_dashboard/dashboards/identity/users/views.py index 93a4484d7c..325712bc9b 100644 --- a/openstack_dashboard/dashboards/identity/users/views.py +++ b/openstack_dashboard/dashboards/identity/users/views.py @@ -67,8 +67,8 @@ class IndexView(tables.DataTableView): # If filter_first is set and if there are not other filters # selected, then search criteria must be provided # and return an empty list - filter_first = getattr(settings, 'FILTER_DATA_FIRST', {}) - if filter_first.get('identity.users', False) and not filters: + filter_first = settings.FILTER_DATA_FIRST + if filter_first['identity.users'] and not filters: self._needs_filter_first = True return users diff --git a/openstack_dashboard/defaults.py b/openstack_dashboard/defaults.py index a8398014be..8e22f1a8c4 100644 --- a/openstack_dashboard/defaults.py +++ b/openstack_dashboard/defaults.py @@ -26,6 +26,26 @@ ENABLE_CLIENT_TOKEN = True # form to verify that it is indeed the admin logged-in who wants to change # the password. ENFORCE_PASSWORD_CHECK = False + +EXTERNAL_MONITORING = [] + +# To allow operators to require users provide a search criteria first +# before loading any data into the views, set the following dict +# attributes to True in each one of the panels you want to enable this feature. +# Follow the convention . +FILTER_DATA_FIRST = { + 'admin.instances': False, + 'admin.images': False, + 'admin.networks': False, + 'admin.routers': False, + 'admin.volumes': False, + 'identity.application_credentials': False, + 'identity.groups': False, + 'identity.projects': False, + 'identity.roles': False, + 'identity.users': False, +} + # Set to 'legacy' or 'direct' to allow users to upload images to glance via # Horizon server. When enabled, a file form field will appear on the create # image form. If set to 'off', there will be no file form field on the create @@ -117,6 +137,7 @@ OPENSTACK_NEUTRON_NETWORK = { 'enable_ipv6': True, # TODO(amotoki): Change the default value to True? See local_settings.py 'enable_quotas': False, + 'enable_rbac_policy': True, 'enable_router': True, # Default dns servers you would like to use when a subnet is @@ -129,7 +150,7 @@ OPENSTACK_NEUTRON_NETWORK = { # Set which provider network types are supported. Only the network types # in this list will be available to choose from when creating a network. # Network types include local, flat, vlan, gre, vxlan and geneve. - # 'supported_provider_types': ['*'], + 'supported_provider_types': ['*'], # You can configure available segmentation ID range per network type # in your deployment. @@ -137,6 +158,7 @@ OPENSTACK_NEUTRON_NETWORK = { # 'vlan': [1024, 2048], # 'vxlan': [4094, 65536], # }, + 'segmentation_id_range': {}, # You can define additional provider network types here. # 'extra_provider_types': { @@ -146,6 +168,7 @@ OPENSTACK_NEUTRON_NETWORK = { # 'require_segmentation_id': True, # } # }, + 'extra_provider_types': {}, # Set which VNIC types are supported for port binding. Only the VNIC # types in this list will be available to choose from when creating a diff --git a/openstack_dashboard/local/local_settings.py.example b/openstack_dashboard/local/local_settings.py.example index deb1d419ac..cd5e8d0547 100644 --- a/openstack_dashboard/local/local_settings.py.example +++ b/openstack_dashboard/local/local_settings.py.example @@ -277,14 +277,21 @@ OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST # services provided by neutron. Options currently available are load # balancer service, security groups, quotas, VPN service. OPENSTACK_NEUTRON_NETWORK = { - 'enable_router': True, + 'enable_auto_allocated_network': False, + 'enable_distributed_router': False, + 'enable_fip_topology_check': True, + 'enable_ha_router': False, + 'enable_ipv6': True, # TODO(amotoki): Drop OPENSTACK_NEUTRON_NETWORK completely from here. # enable_quotas has the different default value here. 'enable_quotas': True, - 'enable_ipv6': True, - 'enable_distributed_router': False, - 'enable_ha_router': False, - 'enable_fip_topology_check': True, + 'enable_rbac_policy': True, + 'enable_router': True, + + 'default_dns_nameservers': [], + 'supported_provider_types': ['*'], + 'segmentation_id_range': {}, + 'extra_provider_types': {}, 'supported_vnic_types': ['*'], 'physical_networks': [], @@ -694,22 +701,6 @@ SECURITY_GROUP_RULES = { # of data fetched by default when rendering the Overview panel. #OVERVIEW_DAYS_RANGE = 1 -# To allow operators to require users provide a search criteria first -# before loading any data into the views, set the following dict -# attributes to True in each one of the panels you want to enable this feature. -# Follow the convention . -#FILTER_DATA_FIRST = { -# 'admin.instances': False, -# 'admin.images': False, -# 'admin.networks': False, -# 'admin.routers': False, -# 'admin.volumes': False, -# 'identity.users': False, -# 'identity.projects': False, -# 'identity.groups': False, -# 'identity.roles': False -#} - # Dict used to restrict user private subnet cidr range. # An empty list means that user input will not be restricted # for a corresponding IP version. By default, there is