Commit Graph

276 Commits

Author SHA1 Message Date
Akihiro Motoki
a0a85dd176 Fix tempest and pep8 tests
Fix tempest jobs to properly use tempest-horizon as tempest-plugin in
job configuration.

Flake8 3.8.0 fixed a few bugs so that additional issues are marked, fix
these.

Co-Authored-By: Andreas Jaeger <aj@suse.com>
Change-Id: I2aca3286ea2cc1ade567087786781952489d6efa
2020-05-12 18:49:34 +02:00
Akihiro Motoki
6ce40aee83 Deprecate legacy way to retrieve neutron usage
neutron 'quota_details' extension was added in Pike to provide
a convenient way to retrieve resource usage in neutron without listing
individual resources. It was added in Pike release and we will have
six releases since then once Ussuri release is shipped. Enough time has
passed to migrate it to the new mechanism, so it is time to deprecate
the legacy way for future cleanup.

Change-Id: Ie0b4613bf9fdcd96481b3bb1139b4fb153bfef83
2020-03-23 14:21:04 +00:00
Zuul
53ba000466 Merge "Drop custom formatwarning from settings.py" 2020-03-05 16:27:24 +00:00
Akihiro Motoki
22c6409c63 Drop custom formatwarning from settings.py
openstack_dashboard/settings.py defines a custom formatwarning function,
but it looks unnecessary. When using the custom function, there are
downsides: locations which cause warnings are not shown, and
no newline is added at the end of warning messages.

Change-Id: Ibd331dc77026ed8ca812822b08253650bcb140bc
2020-02-21 09:10:04 +09:00
Ivan Kolodyazhny
12cd2090b6 Revert "Explicitly set LOCALE_PATHS for Horizon apps"
This reverts commit 4e911e2889.

We don't need this change on the latest master. I'm unable to reproduce
an original bug without this patch.

Closes-Bug: #1834167
Change-Id: Iaffdb64fb0bc58525554ac9d40d2aeadb0876ffd
2020-02-19 11:04:14 +00:00
Zuul
954ad0fdfc Merge "Fix pep8 failures with hacking 2.0.0" 2020-01-06 16:14:49 +00:00
Dmitriy Rabotyagov
04a3535e18 Add support to get disk_formats from glance
This patch allows administrators to set disk_formats only for glance,
while horizon will retrieve list of supported formats from glance API.
IMAGE_BACKEND_SETTINGS still may be used to redefine display name
of the format or additionally limit list of availble ones.

Change-Id: Ia4ea513023895f4ad2a87f91e3d2837c7668d9ae
Closes-Bug: 1853822
2019-12-17 14:56:44 +02:00
Akihiro Motoki
a7b25f0cc4 Fix pep8 failures with hacking 2.0.0
It seems hacking 2.0.0 was shipped with incompatible changes
(which is not surprising as this is a new major version).
Let's fix these errors and use a newer hacking.

Change-Id: I8da9dca5d8d74f6dfc2340dabc8d50e6253358e2
2019-12-17 04:55:05 +00:00
Akihiro Motoki
7e95e1601f Move default values defined in settings.py to defaults.py
Some remaining default values of openstack_dashboard are still defined
in settings.py. This commit moves them to openstack_dashboard/defaults.py.
If the default values are same as those defined in horizon,
they are just dropped.

Part of blueprint ini-based-configuration
Change-Id: I723a8f9064450972d4510ac9e8b423f3041d1cac
2019-09-12 15:05:56 +09:00
Akihiro Motoki
9b99f17100 Define default settings explicitly (horizon)
test_parse_isotime_filter in test_filters is updated to match
TIME_ZONE=UTC. Previously TIME_ZONE was not set in horizon.test.settings
and the default value America/Chicago was used. Horizon uses UTC as the
default value of TIME_ZONE, so it is better to use UTC for testing too.

horizon settings in openstack_dashboard.settings are moved to
under horizon.

Part of blueprint ini-based-configuration
Change-Id: I9abdbbe0dcefc08ffea61143e3c0a87ed87b2e2a
2019-09-12 15:05:56 +09:00
Akihiro Motoki
e56e076ea8 Define default settings explicitly (openstack_auth)
This commit also moves descriptions of settings defined in openstack_auth
from openstack_dashboard/settings.py and local_settings.py(.example)
to openstack_auth/settings.py.

Note that if openstack_dashboard has different default settings
from openstack_auth defaults, they are now moved to
openstack_dashboard/defaults.py.

Part of blueprint ini-based-configuration
Change-Id: I59eebc388de0bcbd4d1fe35c6138efbd3e04c5b8
2019-09-12 15:05:56 +09:00
Akihiro Motoki
2f1e1899d3 Define default settings explicitly (openstack_dashboard 5/5)
This commit mainly covers settings in the remaining files
under openstack_dashboard.

Note that HORIZON_CONFIG, horizon and openstack_auth are not covered.
They will be covered by follow-up patches.

Part of blueprint ini-based-configuration
Change-Id: Ibd70e030445a073d9a62da9867850f4893135a89
2019-07-08 18:20:32 +09:00
Akihiro Motoki
fcdc67b819 Define default settings explicitly (openstack_dashboard 3/5)
This commit mainly covers settings
in openstack_dashboard/dashboards/project/.

Part of blueprint ini-based-configuration
Change-Id: I22413d2fe20576a507634dc4e2d0354c7db8800a
2019-07-03 14:54:16 +09:00
Ivan Kolodyazhny
4e911e2889 Explicitly set LOCALE_PATHS for Horizon apps
Set absolute paths in the LOCALE_PATHS configuration param to allow
Django work with current supported locales.

Change-Id: I62fffe04860b7b4b63f227ad99729ab4e8384d8f
Related-Bug: #1818639
Closes-Bug: #1830886
2019-06-21 08:58:44 +00:00
Zuul
acc36f4958 Merge "Define default settings explicitly (openstack_dashboard 1/5)" 2019-05-29 17:38:13 +00:00
Ivan Kolodyazhny
2e52e4a4e0 Remove deprecated SHOW_KEYSTONE_V2_RC config option
SHOW_KEYSTONE_V2_RC is deprecated since Stein release and it's safe
to remove it now.

Keystone v2 support removal will be implemented in a follow up patch.

Change-Id: Ib3098789a3aef47f4f4b84fd56f03376ce2ea96f
2019-05-14 11:55:53 +00:00
Akihiro Motoki
431fd6c16b Drop cinder consistency group support
Cinder consistency group has been replaced by the generic group feature.
Horizon support of the generic group (in the project dashboard) is
available since Rocky release and it covers all existing support
for consistency group in horizon.

The consistency group support is horizon was marked as deprecated
in Stein release [1].

This commit drops the consistency group support.

[1] https://review.openstack.org/#/c/626846/

Change-Id: I11187d2b03b7e0033a6c6ba3f8be25b8b5e4dd74
2019-05-03 18:16:23 +00:00
Akihiro Motoki
9c19b07a26 Define default settings explicitly (openstack_dashboard 1/5)
Currently horizon defines default values of settings in the logic
using getattr(settings, <setting name>, <default value>) and
it is not easy to handle the default values of available settings.

This commit starts the effort to define default settings explicitly.
This is a preparation for ini-based-configurations.

It covers settings in openstack_dashboard/api.

Part of blueprint ini-based-configuration
Change-Id: Id4c3287f0a572fd14ea93b54bcab8fabda39e583
2019-04-24 02:32:47 +09:00
Zuul
c3d3d28853 Merge "Change the default SESSION_ENGINE to use cached sessions" 2019-02-12 21:50:31 +00:00
Zuul
4a8d00d463 Merge "Allow to specify custom templates for clouds.yaml and openrc" 2019-01-23 14:32:58 +00:00
Akihiro Motoki
ac7ac272b3 pylint: fix several coding convention violations
openstack_dashboard/context_processors.py:94:15: C0122: Comparison should be link['url'] != 'horizon:project:api_access:openrcv2' (misplaced-comparison-constant)
openstack_dashboard/settings.py:467:4: C0412: Imports from package horizon are not grouped (ungrouped-imports)
openstack_dashboard/enabled/_1370_project_vg_snapshots.py:9:0: C0301: Line too long (86/80) (line-too-long)
openstack_dashboard/enabled/_1360_project_volume_groups.py:9:0: C0301: Line too long (85/80) (line-too-long)
openstack_dashboard/usage/base.py:62:8: W0106: Expression "[instance_list.extend(u.server_usages) for u in self.usage_list]" is assigned to nothing (expression-not-assigned)
openstack_dashboard/dashboards/project/images/utils.py:43:12: W0106: Expression "[public_images.append(image) for image in images]" is assigned to nothing (expression-not-assigned)
openstack_dashboard/dashboards/project/images/utils.py:75:12: W0106: Expression "[community_images.append(image) for image in images]" is assigned to nothing (expression-not-assigned)
openstack_dashboard/api/glance.py:47:4: C0412: Imports from package glanceclient are not grouped (ungrouped-imports)
openstack_dashboard/api/cinder.py:60:4: C0412: Imports from package cinderclient are not grouped (ungrouped-imports)
openstack_auth/user.py:358:4: E0211: Method has no argument (no-method-argument)
openstack_auth/user.py:362:4: E0211: Method has no argument (no-method-argument)
openstack_dashboard/api/keystone.py:75:4: C0412: Imports from package keystoneclient are not grouped (ungrouped-imports)
horizon/loaders.py:43:16: W0706: The except handler raises immediately (try-except-raise)
horizon/themes.py:174:8: W0706: The except handler raises immediately (try-except-raise)

Change-Id: I40cf3ffbc4519657e11180d2e2fe7401387c5556
2019-01-17 00:05:27 +09:00
Akihiro Motoki
a98468bef6 Change the default SESSION_ENGINE to use cached sessions
This commit changes the default SESSION_ENGINE to the cached
sessions and the default cached backend to memcached.

The cached sessions with memcahced is our current recommendation, but
we do not use it in our default settings and do not test it in our CI
(horizon-dsvm-tempest-plugin). It is better to use the recommended
configurations in our CI.
The previous default SESSION_ENGINE, the signed cookies, has
a limitation on the length o cookies and using keystone3 can hit this
easily. It is not ready for production for most cases.

For a cache backend, considering multi-process web server deployments,
memcahced is recommended rather than a local memory backend.

Note for developers: If you use "tox -e runserver" for developments,
SESSION_ENGINE = 'django.contrib.sessions.backends.cache' might not
work expectedly. From my testing, I was forced to log-in frequently
when moving pages. If you hit this, my suggestion is to configure
SESSION_ENGINE to django.contrib.sessions.backends.signed_cookies.

Change-Id: I1c4578ec5a7f70a59c6348d76ad0c12956a18573
Closes-Bug: #1736021
2019-01-15 08:07:54 +09:00
Akihiro Motoki
6e1348d05f pylint: fix several warnings
openstack_dashboard/theme_settings.py:63:8: W1201: Specify string format arguments as logging function parameters (logging-not-lazy)
openstack_dashboard/settings.py:412:24: W0122: Use of exec (exec-used)
openstack_dashboard/dashboards/identity/domains/workflows.py:476:44: W0640: Cell variable group_id defined in loop (cell-var-from-loop)
openstack_dashboard/dashboards/identity/projects/workflows.py:906:49: W0640: Cell variable group_id defined in loop (cell-var-from-loop)
openstack_dashboard/dashboards/admin/networks/views.py:42:0: W0404: Reimport 'views' (imported line 28) (reimported)
openstack_dashboard/api/swift.py:204:0: W0102: Dangerous default value {} as argument (dangerous-default-value)
openstack_dashboard/api/swift.py:214:0: W0102: Dangerous default value {} as argument (dangerous-default-value)
openstack_dashboard/api/cinder.py:248:30: W0631: Using possibly undefined loop variable 'cinder_url' (undefined-loop-variable)
openstack_auth/backend.py:123:28: W0631: Using possibly undefined loop variable 'plugin' (undefined-loop-variable)
openstack_auth/backend.py:129:39: W0631: Using possibly undefined loop variable 'plugin' (undefined-loop-variable)
openstack_auth/backend.py:131:39: W0631: Using possibly undefined loop variable 'plugin' (undefined-loop-variable)
openstack_auth/views.py:39:0: W0611: Unused Login imported from openstack_auth.forms (unused-import)
horizon/exceptions.py:348:8: W0125: Using a conditional statement with a constant value (using-constant-test)
horizon/tables/base.py:353:12: W0715: Exception arguments suggest string formatting might be intended (raising-format-tuple)

Change-Id: Icf4f22abda77c9dbf98c780de876b7836c31d669
2019-01-15 00:22:27 +09:00
Zuul
7068f286b2 Merge "Drop unnecessary LOCALE_PATHS from settings.py" 2019-01-13 16:43:54 +00:00
Zuul
a1ffa9620e Merge "Allow to hide openrc and clouds.yaml download links" 2019-01-13 16:43:53 +00:00
Akihiro Motoki
e832c8549b Allow to specify custom templates for clouds.yaml and openrc
Change-Id: I1ef6899f4d14c660eba50f16e813c280657475fc
Closes-Bug: #1795851
2019-01-13 01:53:18 +09:00
Zuul
4391453c21 Merge "SHOW_KEYSTONE_V2_RC defaults to False" 2019-01-03 11:47:40 +00:00
Adrian Turjak
dc0ffaf2d8 Change session timeout to an idle timeout value
Add a new config SESSION_REFRESH (default True) which
turns SESSION_TIMEOUT into an idle timeout rather than
a hard timeout.

The existing hard timeout is awful UX, and while
SESSION_TIMEOUT could be set to a higher value, it
still makes for a somewhat unpleasant experience.

Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: Icc6942e62c4e8d2fac57988b0a2233a8073b1944
2018-12-23 09:33:49 +09:00
Akihiro Motoki
c6baf00734 Allow to hide openrc and clouds.yaml download links
Operators now can control whether the links of "Download OpenRC" and
"Download clouds.yaml" are displayed or not via new settings
SHOW_OPENRC_FILE and SHOW_OPENSTACK_CLOUDS_YAML.
openrc and clouds.yaml files provided by horizon now assume
the basic simple deployment and do not cover keystone authentication
like saml2, openid and so on. The default openrc and clouds.yaml
from horizon do not make sense for such environments.

Change-Id: I1407a24387c7d7bd2c20c995cebf1350f8090e72
Partial-Bug: #1795851
2018-12-23 05:58:51 +09:00
Akihiro Motoki
d32359e011 SHOW_KEYSTONE_V2_RC defaults to False
In favor of keystone v2 support, SHOW_KEYSTONE_V2_RC now defaults
to False. SHOW_KEYSTONE_V2_RC setting is also deprecated.

Along with this change, "v3" part of "OpenStack RC File (Identity API v3)"
is now unnecessary, so "v3" information is dropped.

Change-Id: If0359e2dc1f2c8fb5f3c87046fd23043f94abc21
2018-12-23 04:02:22 +09:00
Akihiro Motoki
1028a65804 Drop unnecessary LOCALE_PATHS from settings.py
Django looks for and uses if it exists a locale directory in each of
the installed apps listed in INSTALLED_APPS [1]. horizon and
openstack_dashboard are specified in INSTALLED_APPS, so there is no need
to specify horizon/locale and openstack_dashboard/locale explicitly.
We can drop them without any side-effect.

[1] https://docs.djangoproject.com/en/1.11/topics/i18n/translation/#javascript-catalog-view

Change-Id: Ibe364b2a16894a51fe17411f29a326aef621472c
Related-Bug: #1804289
2018-11-29 03:27:34 +09:00
Zuul
641a3ce2ab Merge "Fix django.contrib.auth.middleware monkey patching" 2018-11-08 17:38:34 +00:00
Mathieu Gagné
0d16361326 Fix django.contrib.auth.middleware monkey patching
The "request" attribute is not available in
openstack_auth.backend.KeystoneBackend.get_user when session data is restored
and it's the first request to happen after a server restart.

As stated by the function document, the "request" attribute needs to be
monkey-patched by openstack_auth.utils.patch_middleware_get_user
for this function to work properly.

This should happen in openstack_auth.urls at import time. But there is nowhere
in Horizon where this module is imported at startup. It's only introspected
by openstack_dashboard.urls due to AUTHENTICATION_URLS setting.

Without this monkey-patching, the whole authentication mechanism falls back
to "AnonymousUser" and you will get redirected to the login page due
to horizon.exceptions.NotAuthenticated being raised by
horizon.decorators.require_auth as request.user.is_authenticated will be False.

But if a user requests a page under auth/, it will have the side-effect of
monkey-patching django.contrib.auth.middleware as expected. This means that
once this request is completed, all following requests to pages other than
the ones under auth/ will have there sessions properly restored and
you will be properly authenticated.

Therefore this change introduces a dummy middleware which sole purpose is
to perform this monkey-patching as early as possible.

There is also some cleanup to get rid of the previous attempts at
monkeypatching.

Closes-bug: #1764622
Change-Id: Ib9912090a87b716e7f5710f6f360b0df168ec2e3
2018-11-06 21:36:45 +00:00
Adrian Turjak
f3094e6f83 rework memoized as a LRU cache with expiry
memoized now operates as a LRU cache that additionally uses
weakrefs to clear keys.

The max_size of the LRU cache can be set per decorated
function when defined, but a global default can be set too.

Change-Id: I431d61283cd613f09664f8f370dd3fd126fc724f
2018-11-02 13:38:12 +13:00
Zuul
62d90a49ad Merge "Revert "ROOT_PATH should not be appended to "sys.path""" 2018-09-10 15:31:24 +00:00
Akihiro Motoki
cccf477c59 Revert "ROOT_PATH should not be appended to "sys.path""
This reverts commit e681bc2e2f.

Change-Id: Ib291c1dc04c92173a7a165a8fb0eec2b2165884b
Closes-Bug: #1791451
2018-09-08 17:22:03 +00:00
Zuul
e03b8d9a41 Merge "ROOT_PATH should not be appended to "sys.path"" 2018-09-06 02:21:54 +00:00
chao liu
e681bc2e2f ROOT_PATH should not be appended to "sys.path"
there's no need to append ROOT_PATH to "sys.path" in the settings

Change-Id: Ib50031c468ce0cbc9758bb04b4d6f459bcacac28
2018-08-28 01:38:32 +00:00
Nishant Kumar
ccdf8c55e6 Add django-debreach to horizon
BREACH is a category of vulnerabilities and not a specific
instance affecting a specific piece of software. To be vulnerable,
a web application must:

  * Be served from a server that uses HTTP-level compression
  * Reflect user-input in HTTP response bodies
  * Reflect a secret (such as a CSRF token) in HTTP response bodies

More details on breach attack - http://breachattack.com/

Since horizon falls under this category, we can include django-debreach
module within horizon as a requirement which provides mitigation against the breach attacks.

https://github.com/lpomfrey/django-debreach

CSRF token masking is a built-in feature within Django 1.10+,
therefore only content-length modification feature provided by django-debreach
can be enabled.

Depends-On: I32f11e089fc794444ef267b463c7fb2ad8cfa96a

Change-Id: I2b4999ca7b0e1762c5273c4fe96f5ee768f44339
Blueprint: mitigate-breach-attacks
2018-08-25 07:49:32 +05:30
chao liu
cf959d1a5b Remove the unused settings
The "BIN_DIR" appears unused by the dashboard

Change-Id: I41d643bd9e14562e0a71ca9a631dba32259446a5
2018-08-18 06:34:12 +08:00
Jose Castro Leon
7fc8018956 Allow to specify redirections on single IdP scenarios
In scenarios where the cloud operators have only a single Identity Provider,
we can have a default redirection to remove unnecessary user clicks and
improve user experience.

Closes-bug: #1784368

Change-Id: I251703dcaeac43174fbcba7e0658c6f92098b2e0
2018-08-13 12:11:45 +02:00
Ivan Kolodyazhny
1f80d94459 Use default Django test runner instead of nose
Nose has been in maintenance mode for the past several years. It has
issue with exit code [1] which leads to false positive results for our
seleniun-headless job.

This patch changes test runner for Horizon tests and does the following
things:

* Django test runner  executes test in a different order than Nose does.
  That's why we've got an issue with side-effect in
  horizon.tests.unit.tables.test_tables.MyToggleAction class. This patch
  adds workaround to it.
* Rename filename of test files to names starting with 'test_'
  so that the django test runner can find tests expectedly.
* '--with-html-output' option is temporary dropped and will be added in
  a following patch.
* Integraion tests is marked via django.test.tag mechanism which is
  introduced in Django 1.10
* 'selenium-headless' is broken now because we don't have geckodriver on
  gates, this patch makes it non-voting.
* 'tox -e cover' is fixed
* Remove @memorized decorator from
  dashboards.project.images.images.tables.filter_tenant_ids function.

[1] https://github.com/nose-devs/nose/issues/984

Depends-On: https://review.openstack.org/572095
Depends-On: https://review.openstack.org/572124
Depends-On: https://review.openstack.org/572390
Depends-On: https://review.openstack.org/572391

Related blueprint: improve-horizon-testing
Change-Id: I7fb2fd7dd40f301ea822154b9809a9a07610c507
2018-06-08 15:21:12 +03:00
Akihiro Motoki
f0f028ca35 Fix E402 warnings
E402 module level import not at top of file

Change-Id: Ia8425ffe5b1325d00ae482d99b6764fd0fcbf822
2018-04-11 18:57:28 +09:00
Akihiro Motoki
71993e3c98 Drop deprecated settings
- HORIZON_IMAGES_ALLOW_UPLOAD (deprecated in Newton)
- CUSTOM_THEME_PATH (deprecated in Mitaka)
- DEFAULT_THEME_PATH (deprecated in Mitaka)
- OPENSTACK_TOKEN_HASH_ENABLED (deprecated in Mitaka)
- TOKEN_DELETION_DISABLED
  (not documented but it was marked as deprecated in Ocata
   in django-openstack-auth commit 5810f9c6)

The related logics related to dropped deprecated settings
have been dropped too.

- custom_path and default_path of get_available_themes() were
  dropped as they are no longer needed in favor of
  the removal of CUSTOM_THEME_PATH and DEFAULT_THEME_PATH.
- Unused remove_project_cache(), is_token_deletion_disabled()
  and delete_token() have been dropped.

Change-Id: Ic9406623cc092884c4136f78fb967b129bfda487
2018-03-23 18:37:02 +09:00
Zuul
1cdafd8895 Merge "Add plugin xstatic modules support" 2018-03-20 17:25:56 +00:00
Akihiro Motoki
64b67ac9e9 Update the doc links to the newest ones
The docstring of getExtensions service in cinder.service.js
was a copy from nova service and not correct. The docstring was
updated based on the current cinder v2 API.

Thanks to a recent improvement in reno, touching release notes
in older releases in the master branch no longer polute the rendered
release notes. Changing URLs (or other things) in the master branch
does not affect the rendered release notes, but updating URLs to the
latest would help avoiding mechanical patches of updating links :)

Change-Id: I2aec3adeb400323d42a3a5083f8bc0798eeff917
2018-03-20 16:22:05 +09:00
irisayame
1f93e64a3d Add plugin xstatic modules support
This patch allows Horizon to accept additional xstatic modules
 in plugin dashboards. Related static files would be collected
 and included in every page.

Change-Id: Ie49a522b28aaf6e028c5b218968d68189dd7eef1
Closes-Bug: #1755339
2018-03-20 11:37:29 +09:00
Zuul
ab7e989d40 Merge "django2: adopt New-style middleware" 2018-03-09 16:49:28 +00:00
Zuul
f921c6de17 Merge "django2: Drop SessionAuthenticationMiddleware" 2018-03-09 15:46:27 +00:00
Akihiro Motoki
3ecda5ac67 django2: adopt New-style middleware
Django 1.10 introduces a new style of middleware and
the old style was removed in Django 2.0.

https://docs.djangoproject.com/en/2.0/releases/1.10/#new-style-middleware

blueprint django2-support
Change-Id: I2fba2b1b2b528096422df3ed558ad75a1b80bbb9
2018-03-03 07:22:35 +09:00