Commit Graph

51 Commits

Author SHA1 Message Date
Zuul dd9e4c82b5 Merge "Address RemovedInDjango40Warning (2)" 2022-03-03 10:14:04 +00:00
Zuul 1503e8d88d Merge "Replace deprecated imp module" 2022-02-09 15:51:37 +00:00
Takashi Kajinami 5d0b2b74d4 Replace deprecated imp module
The imp module is deprecated since Python 3.4[1] in favor of the new
importlib module. This change replaces usage of that deprecated module.

[1] https://docs.python.org/3/library/imp.html

NOTES:
- This change simplifies the logic, assuming the DJANGO_SETTINGS_MODULE
  environment should be a module name. (The previous implementation
  eventually raises an exception if the name is not a module name but
  anything else like a class name.)

- The imp.find_module method raises ImportError when the module is not
  found. This means the previous implementation never returns
  sys.path[0]. If the module is found the value is replaced and if it
  is not found then the method doesn't return any value but raises
  an exception.

Change-Id: I798f345e729ae974917872ba1f2e43205a660c45
2022-02-08 13:15:19 +00:00
Akihiro Motoki cd7c1b5110 Address RemovedInDjango40Warning (2)
django.utils.translation.ugettext(), ugettext_lazy(), ugettext_noop(),
ungettext(), and ungettext_lazy() are deprecated in favor of the
functions that they’re aliases for: django.utils.translation.gettext(),
gettext_lazy(), gettext_noop(), ngettext(), and ngettext_lazy().

https://docs.djangoproject.com/en/4.0/releases/3.0/#id3

Change-Id: I77878f84e9d10cf6a136dada81eabf4e18676250
2022-02-04 16:22:07 +09:00
manchandavishal 6ac31e0ba8 Drop Django based implementation of launch instance
horizon already deprecated launch instance Django based implementation
in the wallaby cycle [1]. This patch remove code for launch instance
Django based implementation as angular based implementation is the
default one from long and all features gaps between angular and Django
implementation is closed.

It also moves SetAdvanced step code to ``resize_instance.py`` as
``workflows/create_instance.py`` file is deleted and remove server_group
option from Advanced Options of resizing instance action because
"server_group" is not required while resizing an instance as per
nova-api reference [2].

Closes-Bug: #1869222

[1] https://review.opendev.org/c/openstack/horizon/+/779125
[2] https://docs.openstack.org/api-ref/compute/?expanded=resize-server-resize-action-detail#resize-server-resize-action

Change-Id: I5e01cd81f309491f1a58ea93911030366a86e3c7
2022-01-24 16:21:18 +05:30
Akihiro Motoki 57380fae71 Deprecate Django launch instance form
As discussed in the horizon meeting, we think that feature gaps
between the two implementations have been closed. Let's mark
the Django version as deprecated and gather more attentions
from operators.

Change-Id: I55379c0897bad46decfabb443afe9439a31a3164
2021-03-09 15:55:35 +09:00
Zuul c756724cda Merge "Support policy-in-code and deprecated policy" 2021-03-04 22:01:52 +00:00
Zuul 425ab2d36a Merge "Drop translation marker from upgrade-check help" 2021-03-04 18:20:07 +00:00
Zuul 03aee256ec Merge "Update upgrade_check to discover dashboard settings automatically" 2021-03-04 18:19:51 +00:00
Zuul 472e15e95b Merge "upgrade_check: Convert KNOWN_SETTINGS into one-per-line style" 2021-03-04 18:19:36 +00:00
Zuul 394423147c Merge "Rename zh-cn and zh-tw translations to zh-hans and zh-hant" 2021-03-04 08:08:14 +00:00
Akihiro Motoki 1c5b39e279 Update upgrade_check to discover dashboard settings automatically
Previously upgrade_check maintain a hard-coded list for known settings,
so we easily miss new horizon settings. Almost all settings are now
defined in openstack_dashboard/defaults.py and we can know dashboard
settings from here. This commit retrieves the known dashboard settings
from openstack_dashboard/defaults.py.

After this change, we still need to maintain Django and related Django
modules. This commit also adds new settings added in Django and Django
compressor recently.

Change-Id: I8b8c6f7ef334c24992b39a848833c05738f8926b
2021-02-18 10:15:21 +09:00
Akihiro Motoki b02d1267ab upgrade_check: Convert KNOWN_SETTINGS into one-per-line style
This is a preparation for the next commit which touches KWNON_SETTINGS.
One entry per line would improve the readability of the next change a lot.

Change-Id: I835a3216f237ca09183206012137f58d2964bbc0
2021-02-18 10:13:03 +09:00
Akihiro Motoki 391a660460 Rename zh-cn and zh-tw translations to zh-hans and zh-hant
See http://lists.openstack.org/pipermail/openstack-discuss/2021-February/020169.html

horizon/management/commands/pull_catalog.py is updated accordingly.
It turns out it does not work with python3, so it is fixed too.

Depends-On: https://review.opendev.org/c/openstack/openstack-zuul-jobs/+/773689
Change-Id: I6575f1f032a06365953dbfe314abfbf9a31817cd
2021-02-18 09:57:27 +09:00
Akihiro Motoki 73a4c36829 Drop translation marker from upgrade-check help
When the translation marker _(..) is used in the "help" attribute of
a Django management command, --help option fails. It seems translation
marker is not evaluated and directly passed to argparse library.
We don't translate Django management commands, so we can safely drop it.

Change-Id: Iaacb86e5451ee7271de797a0184a6456f5b37eb6
2021-02-18 07:18:31 +09:00
Zuul 5c8e2d6ab0 Merge "Add openstack_auth to translation-related commands" 2021-02-17 14:59:38 +00:00
YuehuiLei 87f498bee5 Drop the usage of unicode prefix from unicode strings
All strings are considered as unicode strings in python 3,
so we no longer need "u" prefix (u'...').

Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: I796d2fcdca066475bbf29d25cbf2aa67b2b2178b
2021-02-12 13:05:27 -06:00
Akihiro Motoki be3d27c029 Add openstack_auth to translation-related commands
openstack_auth was missing in pull_catalog and extract_messages
commands in manage.py. It is just because we forgot add it when
openstack_auth was merged from django-openstack-auth into horizon.

update_catalog did not run with python3 as write_po assumes fileobj is
opened as binary mode. We need to open a POT file with binary mode.

Change-Id: Ifa1c07c46d1081a299b030e523713e73b41faf19
2021-02-12 16:21:23 +09:00
Akihiro Motoki b7bb76eb20 Support policy-in-code and deprecated policy
This commit allows horizon to handle deprecated policy rules.
The approach is explained in the document updated by this change.

oslo.policy requirement is updated. oslo.policy 3.2.0 is chosen
just because it is the first release in Victoria cycle.
requirements.txt and lower-constraints.txt are updated accordingly
including oslo.policy dependencies.

Change-Id: If5059d03f6bd7e94796065aa1b51c0c23ac85f5e
2021-01-27 14:02:27 +00:00
Akihiro Motoki e5d09edc20 Use python3-style super()
In python3, super() does not always require a class and self reference.
In other words, super() is enough for most cases.
This is much simpler and it is time to switch it to the newer style.

pylint provides a check for this.
Let's enable 'super-with-arguments' check.

NOTE: _prepare_mappings() method of FormRegion in
openstack_dashboard/test/integration_tests/regions/forms.py is refactored.
super() (without explicit class and self referece) does not work when
a subclass method calls a same method in a parent class multiple times.
It looks better to prepare a separate method to provide a common logic.

Change-Id: Id9512a14be9f20dbd5ebd63d446570c7b7c825ff
2020-10-15 14:37:20 +09:00
Akihiro Motoki 692778f8cf pylint: Address no-else-return warning
This pylint check 'no-else-return' might be debatable.
but as far as I checked it works in most cases.

Change-Id: Ie8574d4a529454c6e050fa62a7a17ea097d00240
2020-09-27 12:44:16 +09:00
Zuul b3832334af Merge "Fix django-compress caching issues" 2020-06-25 12:24:55 +00:00
Ivan Kolodyazhny 0d290b9184 Fix django-compress caching issues
django-compress doesn't work well with cache. If horizon is
deployed in a containarized environment with pre-built static
in images, django-compress tries to load old templates from cache.

This patch introduces following changes:

* update_angular_template_hash uses the correct Django cache backend now
* fixed cache cleanup for memcached backend
* added clean_angular_template_cache management command to clean cache
  manually without executing heavy 'compress' command.

Closes-Bug: #1874657
Change-Id: If1fd61fa2e4b36e22797b0f54ac067a2a937f369
2020-06-15 17:33:16 +03:00
Hervé Beraud 17d8ab6103 Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: Ic03754dcaaa4f1c0018294aa52bb05d956aa5d10
2020-06-03 10:45:18 +02:00
Ivan Kolodyazhny d870b40583 Remove six usage from openstack_dashboard package
We don't support Python 2 anymore so we don't need this
compatibility library.

six.reraise usages are left as is until it'll be moved to some
base lib like oslo.utils to not re-implenent this method in
Horizon.

This patch also removes Python2-specific base test case methods
assertItemsEqual and assertNotRegexpMatches in flavor of new
Python 3 analogues.

Change-Id: I26a59176be9e9f213128e4945a58b9459334b626
2020-01-15 12:47:48 +02:00
Yves-Gwenael Bourhis 66144165ff Use the python real executable
Use the real python executable as shebang
Use exec instead of execfile if using python 3

Change-Id: I8acea40851c7e9dc248751be967859b2b9430af7
Closes-Bug: #1836580
2019-07-17 16:23:33 +02: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
Ivan Kolodyazhny 0e518521c8 Remove ENABLE_FLAVOR_EDIT config option
ENABLE_FLAVOR_EDIT is deprecated since Pike release and is not used
anywhere.

Change-Id: I06d5252c8f7bd955025587393f5d8ff00fe01c3b
2019-05-04 15:36:49 +00:00
Radomir Dopieralski d7d6c0577c Add a upgrade_check management command
This command checks the configuration for invalid and deprecated
settings, as described in
https://governance.openstack.org/tc/goals/stein/upgrade-checkers.html

There is also a script in tools/find_settings.py that scans all python
files for the potential new settings, which is supposed to make it
easier to update the lists that the checks use.

Change-Id: Ie85cf4be3da1ab446c10883a4580e20ea154b67c
Story: 2003657
Task: 26132
2019-03-01 15:43:13 +01:00
Akihiro Motoki 3143edef01 pylint: fix import-error
It seems pylint cannot handle distutils imports
and shows "import-error" error. I believe it sounds
reasonable to ignore this case.

Change-Id: Ia08b4fbf8c3270aa37cd88967add8258f6b26377
2019-01-16 00:00:58 +09:00
Akihiro Motoki cebe212d00 Bump hacking to 1.1.0
Fix the following new errors:
* E305 expected 2 blank lines after class or function definition, found 1
* E126 continuation line over-indented for hanging indent

max_line_length is set to 80 as the default value in pycodestyle is 79
but horizon uses 80 as max_line_length.

Ignore W504 and F405 by configurations.
Reasons of disabling them are explained as comments in tox.ini.

Change-Id: Iee8bcd60c30883fc8c74f08cf20af853cbb5e271
2018-11-10 16:44:25 +09:00
Adrian Turjak 0ca736e5da Create new wsgi.py file and deprecate old file
Django 1.4 stopped creating django.wsgi files and the common
practice now for a while has been a wsgi.py since it is actually
python code, and should actually be importable.

Right now someone has to copy and rename the existing file if they
want to use it with a server like gunicorn.

This patch adds a new file in location that is importable via python
and adds a deprecation log to the old one.

This also updates the wsgi generation commands to instead  create
'horizon_wsgi.py' and have the apache conf generation also use that
or the default wsgi file.

Change-Id: I0f8bd16c8973ad23bcd8f73b54584dc69e5aed0c
Closes-Bug: #1763204
2018-05-15 01:41:01 +00:00
Akihiro Motoki 4dd60373dc Fix python 3 related test failures
In Python 3.5 with Django 2.0 env, some tests fail.
This commit fixes them.

blueprint django2-support
Change-Id: Ib5ba46d501956ebc7d4f69f17ee86f44319418d2
2018-03-03 07:33:23 +09:00
Akihiro Motoki f3e9ef5851 extract_messages, update_catalog: Simplify help message
Previously the help message of update_catalog shows all available
languages in the command example. It is difficult to understand
what an exact command line is expected.
This commit uses metavar to simplify the brief command line
and shows available languages in the help text.

Similar change is made to 'domain' argument of update_catalog
and of extract_messages.

Also the default values are added in the help message.

Change-Id: I63efea7e368eb1dfaf203ca4c515eb57173b571e
2017-08-29 12:35:30 +00:00
Jenkins c8c31e9f54 Merge "Fix pofile for pseudo translations" 2017-08-21 10:10:02 +00:00
Nick Timkovich 846fc19d71 Fix pofile for pseudo translations
The pofile name in the pseudo translation logic appears to expect the
babel.messages object, not the string holding the location of the pofile.

Trimmed a string that gettext reacts poorly with when creating pseudo-
translations.

Change-Id: I811711412d85a989826a946d1d57ed39790e34ed
Closes-Bug: 1710003
2017-08-15 13:14:15 -05:00
Akihiro Motoki 19a4012b91 extract_messages: Specify input directory
Currently horizon/locale/{django,djangojs}.js contain strings from
openstack_dashboard and vice versa. To avoid this, --input-dirs
option needs to be passed to python setup.py extract_messages.

Change-Id: Iee874616f4c037cc68bc3b0c7d8586d86f7153f4
Closes-Bug: #1710396
2017-08-12 17:52:31 +00:00
Radomir Dopieralski d9e4b6ae68 Use WSGIApplicationGroup %{GLOBAL} in mod_wsgi configuration
Change-Id: I0633703cef5a225fe8b689017d21aa4f45ecc7cf
Closes-bug: #1708655
2017-08-04 14:52:43 +02:00
Akihiro Motoki e6b78f92f2 Use flake8-import-order plugin
In reviews we usually check import grouping but it is boring.
By using flake8-import-order plugin, we can avoid this.
This flake8 plugin is already used in tempest.
It enforces loose checking so it sounds good to use.

Note that flake8-import-order version is pinned to avoid unexpected
breakage of pep8 job.

Change-Id: I8ccd05eb70350a2441cc2a4d1eafc09ee690b83b
2017-07-03 08:02:23 +00:00
Akihiro Motoki baa4ca8dce hacking: noqa cleanup in openstack_dashboard
attribute-level imports are not checked by hacking module now.
most noqa is used to disable warnings on attribute-level imports.
This commit drops noqa for this purpose.

After this, there are only 3 noqa under openstack_dashboard/ :)

Change-Id: I4a449802f5dbd6e44e4b8b5c378a555d47d9a99f
2017-03-17 19:38:47 +00:00
Radomir Dopieralski c3b6fc761e Make extract_messages quiet in pep8 test
The additional extract_messages call in the pep8 tox environment
generates a lot of meaningless output, that then makes it difficult
to spot actual failures and warnings. This patch makes the Django
command respect the verbosity setting and call the setup.py command
with a quiet flag if low verbosity is requested, considerably decreasing
the amount of useless output. It then sets that verbosity to low in the
corresponding tox environment.

Change-Id: I2976250a23e800fbb582726299670b57199b58a7
2017-03-17 16:55:18 +01:00
Yves-Gwenael Bourhis 600620a8d5 Configuring number of apache processes
By default apache spawns only one process for the wsgi app if not specified.
This patch detects the number of CPUS to configure n CPUs +1 processes by
default and allows to specify the number of processes explicitly.

Change-Id: I684ecd15193cef169d7a86f66a47b7d1d76c1c24
Closes-Bug: #1658048
2017-01-20 11:49:34 +01:00
Cao Xuan Hoang f0dc5c3614 Removes unnecessary utf-8 encoding
trivialfix

Change-Id: Ia9b35ab6c39cc35c0c3e2b0ebb95930314df43b6
2016-12-13 15:22:09 +07:00
Rob Cresswell 36d1d1ac68 Refactor tox & update docs
- Updated tox envlist, so just running `tox` from the CLI will now run all
voting gate tests

- Reduce duplicated definitions and commands

- Remove any reliance on run_tests within tox

- Removes all doc references to run_tests.sh, and replaces them
with their tox equivalent. Where necessary, language around the tox
commands has been altered or extended so that it makes sense and is
consistent with other parts of the docs. Also adds a new "Test Environment"
list to the docs, so that newcomers do not have to piece together CLI
commands and their cryptic extensions from tox.ini

- Move the inline shell scripting to its own file. Also fixes a bug when
passing args, since the logic assumed you were attempting a subset test
run (try `tox -e py27 -- --pdb` on master to compare)

- Moved translation tooling from run_tests to manage.py, w/ help text
and arg restrictions. This is much more flexible so that plugins can use
it without having to copy commands, but still defaults to exactly the
same parameters/behaviour from run_tests. Docs updated appropriately.

- Removed npm/karma strange reliance on either .venv or tox/py27. Now
it only uses tox/npm.

Change-Id: I883f885bd424955d39ddcfde5ba396a88cfc041e
Implements: blueprint enhance-tox
Closes-Bug: 1638672
2016-11-30 20:38:59 +00:00
Ivan Udovichenko 374e60307d Use argparse instead of optparse
Use of optparse module is deprecated [1] in Django 1.8 and 1.9 versions and
its support has been removed in currently developed version 1.10 [2]

[1] https://docs.djangoproject.com/en/1.9/howto/custom-management-commands/#django.core.management.BaseCommand.option_list
[2] 6a70cb5397 (diff-dfc45ab8548a0777543d12d6e77c9173)

Change-Id: I0c7622fce0d5fabce45366d002b5e72e4c170344
2016-08-09 09:00:21 +03:00
Yves-Gwenael Bourhis f9e864c9fc Update WSGI app creation to be compatible with Django 1.7 or greater
This resolves the following error when trying to run Horizon if it has
been installed via "django-admin make_web_conf --wgi":

AppRegistryNotReady: The translation infrastructure cannot be
initialized before the apps registry is ready. Check that you don't
make non-lazy gettext calls at import time.

and is backwards-compatible with our currently supported versions.

Closes-Bug: #1497986
Change-Id: I643058bb82f8e0f11b38ce0dd046773e91e053c3
2015-09-21 15:36:19 +02:00
Yves-Gwenael Bourhis 42bc31b386 Detect apache version
We try to detect apache's version.
Some distributions do not allow launching apache commands (even for detection)
if not root, so we gracefully fall back on 2.4 version configuration file
We alse add an --apache-version option to force the version in case
detection would be wrong.

Closes Bug: #1438773

Change-Id: I7d28c319601cf3919068be4ac52dd10f58a82557
2015-04-03 09:51:05 +02:00
Diego Garcia del Rio df8ffbd357 spelling mistakes on display outputs and docsstrings
Change-Id: Ic594db332c89e44293f4018e31d3fb47f69e7029
2015-02-24 20:00:03 -08:00
Yves-Gwenael Bourhis 9610f0bed0 Added a migrate_settings command
This command allows to easily save a diff between local_settings.py and
local_settings.py.example to reapply the change when local_settings.py.example
changes (per branch switch or updates).

implements bp settings-migration-script

Change-Id: I2668bbf248434a5d437a5fc46ad07c1a1f29b793
2015-02-05 12:24:18 +01:00
Akihiro Motoki 832a741c88 Fix E128 errors in remaining openstack_dashboard/
E128 continuation line under-indented for visual indent

Closes-Bug: #1375929
Change-Id: I2a72313d359bdfe2e2667eba5d3bf9744ec8f60a
2014-10-16 16:53:52 +09:00