Commit Graph

81 Commits

Author SHA1 Message Date
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
Vadym Markov 4a2a1db145 Show image names at Admin-Instances dashboard
Admin-Compute-Instances dashboard shows "-" as image name for every
instance. Despite, Project-Compute-Instances dashboard displays image
name correctly. Admin dashboard just lacks code to resolve image name

Also, reverted commit deb55b8 which functionality is not needed anymore

Closes-Bug: #1932341
Change-Id: Ieb19e66dc51165d9935424b2e9ab5cdae757b07f
2021-08-11 18:12:09 +03: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
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
Radomir Dopieralski 2b55e3f7a7 Catch AttributeError when deleting temp file on image upload
When the image upload finishes, we try to delete the temporary
file that was used for the upload. However, depending on how
Horizon is deployed, instead of a file it can be a BytesIO
instance, which leads to an AttributeError. This happens in
a separate thread, so Horizon itself doesn't crash, but it's
better to catch that exception.

Change-Id: Iaa66d9c87060c1e001f3f6e31f630d6092df55d3
Closes-Bug: #1866632
2020-03-09 14:09:05 +00:00
Zuul 7c54e7db93 Merge "Remove six usage from openstack_dashboard package" 2020-01-17 10:27:49 +00: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
zhufl e6ce38822b Fix dupliated words issue like " by by which"
This is to fix the duplicated words issue like
"The name of key by by which".

Change-Id: I7b0897eb40c6b587521d727d4fd2f60e4058040b
2020-01-06 11:30:05 +08: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
Ivan Kolodyazhny 6037a58c6e Drop deprecated Glance V1 API support
Glance V1 API was deprecated in Stein release in Horizon and
deprecated in Glance since Newton release.

Change-Id: I18f6fd03dd3e07fa4f2ccfdccfdc3ca766c91c16
2019-10-08 13:18:22 +03:00
白子玉 ba75bafc69 Specify proper container_format for 'vhd' disk_format
When editing an image, if the disk_fomrat is 'vhd',
the container_format was wrongly set to 'bare' before.
'ovf' is the correct container_format for 'vhd' disk images.

Closes-Bug: #1539722
Change-Id: Ic6b0c66af0d5c8db2d802d6eea2b97721d92b7eb
2019-09-18 06:20:54 +00:00
Akihiro Motoki 7c897b677c Move openstack_dashboard specific settings from horizon
Cookie-based settings related to openstack_dashboard are located
under horizon directory,, but they are not related to "horizon".
This commit moves them to "openstack_dashboard" directory.

Part of blueprint ini-based-configuration
Change-Id: Id48ececdbe819a95485e9a91dc5a1a163a5568c3
2019-09-12 15:05:56 +09:00
Stephen Finucane 4ece14b28a Handle move of ABCs to collections.abc
Resolves the following warning:

  DeprecationWarning: Using or importing the ABCs from 'collections'
  instead of from 'collections.abc' is deprecated, and in 3.8 it will
  stop working

Change-Id: Ib2214e7560cda1ef510c08859d5ee0726eb66b7b
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-09-10 19:21:20 +09: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
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
Zuul 32f5338a4f Merge "pylint: fix useless-super-delegation warning" 2019-01-16 14:25:24 +00:00
Akihiro Motoki a8edb5059d pylint: fix simplifiable-if-statement/expression
Change-Id: I9af66f886c47d3d2be61cba22b6c84460a178b8e
2019-01-16 13:08:08 +09:00
Akihiro Motoki e9f75a7bcb pylint: fix useless-super-delegation warning
Change-Id: Iddea27e720dc7184fa3d524a2a465732f18d4dee
2019-01-16 13:05:09 +09:00
Andy Botting d641e6d105 Better support for community images
This commit updates several places where image information is processed
and extends support for the 'community' image visibility value.

Some support did exist already, which was mostly just the main Images
tab of the dashboard, but this commit also includes support for:
  - image name in the instances list/details
  - 'Community' visibility label in the Images tab
  - Listing of community images in launch instance wizard

Closes-Bug: #1779250

Change-Id: Iedea0b7d20313837a72a2759511251a7bb324869
2018-12-27 09:04:53 +09:00
Yves-Gwenael Bourhis 65b21e7f9d Fix images minimum ram and disk default values
When uploading an image, if we do not set a minimum ram and disk size we
try to send "None" to glance.
We should instead send "0" and glance will calculate the size from the
provided image.

Change-Id: Ia1aeabcdcf021943ebb7a4e35939c383ac820b19
Closes-Bug: #1809121
2018-12-19 15:11:20 +01:00
BubaVV deb55b8411 Call Glance list with certain image ids
This patch uses glance list filtering, which allow to query images
for the list of required ids. See [1] for details.

Patch rebased to master. Added test for proposed Glance API request

[1] https://developer.openstack.org/api-ref/image/v2/#show-images

Related-Bug: #1508554
Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Co-Authored-By: Vadym Markov <markov.vadim@gmail.com>
Change-Id: Iac485c1b448011fec97ba5bfaa83851914b294d9
2018-11-06 12:30:57 +02:00
Michal Arbet b84da5e84e Fix issue with uploading image to glance on Python3
It was unable to upload image when horizon was running on python3,
there was a problem with closed file in new thread. This commit is
fixing this issue with added if clause whether horizon running on
python2 or python3 and correctly call close_called on file when
running on python3.

Change-Id: Ice178f6269ac527ba62b26d86976b5336987c922
Closes-Bug: #1773935
2018-05-30 10:56:47 +00:00
Guillaume Le Blanc e362626031 Allow OVA upload for images
Bug #1641383 was not fixed for REST API call.
The two implementation of create_image_metadata are merged
into api/glance.py.

There were minor differences in field naming and handling
(min_ vs minimum_, is_public vs public vs visibility).
This commit normalizes them to simplify the logic.

Closes-Bug: #1757136
Change-Id: I41e9d94345151bc4473d704cdc040ed77870ce45
2018-04-16 16:49:35 +02: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
jimmygc 4214fc2d75 Clean /tmp after upload when using glance v2 client
When using glance v2 client, it will leave an upload
tmp file in /tmp folder, which will cause upload error
if its filesystem (in memory) is full.

Change-Id: I0a7267db894e7be4216a346752d299132df9a29a
Closes-Bug: #1689694
2017-08-04 10:54:51 +08:00
Akihiro Motoki b9d0243c33 Fix H405 (multi line docstring) warnings (openstack_dashboard)
H405: multi line docstring summary not separated with an empty line

Closes-Bug: #1696996

Change-Id: Id895695663b19522d9cdc22f8b012e49680d708b
2017-06-09 16:05:31 +00:00
Jenkins 4b32a7051a Merge "Image list function should normalize owner filter" 2017-05-05 14:50:16 +00:00
Mark Mielke 445117eb1f Image list function should normalize owner filter
The api.glance.image_list_detailed() function accepts a list of
filters which it then translates into a form that is acceptable for
Glance v1 or Glance v2. These translations included support for
mapping 'is_public' to 'visibility', but did not include support for
mapping 'property-owner_id' to 'owner'.

This changes adds support for mapping 'property-owner_id' to 'owner'
for Glance v2, and mapping 'owner' to 'property-owner_id' for Glance
v1.

Before this fix, "rebuild instance" from the instances page did not
properly list project-specific images as options.  After this fix,
"rebuild instance" is working as expected.

Change-Id: Ica750f8b36bdbadd02a81aed41fd250864a49a66
Closes-Bug: 1671693
2017-04-12 09:50:11 +00:00
Gábor Antal 34a3aa0ba8 Handle log message interpolation by the logger
According to OpenStack Guideline[1], logged string message should be
interpolated by the logger.

[1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages
Change-Id: I51f50935f1eeffe4960562d6309dfdf05814e595
Closes-Bug: #1596829
2017-03-31 20:59:16 +09: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
Paulo Matias 446e5aefb4 Always pass the public endpoint to the client
Even if Horizon is configured to use internal endpoints for requests
made by its server side to other OpenStack services, the client side
should not be restricted to run only in networks which have access to
the internal endpoints.

Change-Id: Ibdc663a133670e8f07530c0d7c5ed7df2d92b99b
Closes-Bug: #1639080
2017-03-02 14:57:16 -03:00
Paul Karikh 97945b5f6a Wrap api calls with tracing decorators
Since Horizon is going to be the first (or, one of the first)
OpenStack component using the new MongoDB driver, it won't be able to
retrieve traces made by other components using MongoDB driver (which
it should use because Ceilometer driver was too slow) for a
while. This means that Horizon itself is responsible for tracing the
rendering of its pages down to the layer where the flow of control
leaves Horizon domain. So, a lot of api wrappers in
openstack_dashboard.api are augmented with tracing decorator to
achieve this goal.

Co-Authored-By: Timur Sufiev <tsufiev@mirantis.com>
Implements-blueprint: openstack-profiler-at-developer-dashboard
Change-Id: Ib36692f0e9e68ed7fa0cd47919ba6581c9c8ab57
2016-12-01 19:31:10 +00:00
Akihiro Motoki 35d2becdd6 Fix docstring warnings
Partial-Bug: #1411719
Partial-Bug: #1486222

Change-Id: I2d649295e7425ab73f09f3a5d91076350bf7ed7a
2016-09-24 20:44:48 +09:00
Julie Pichon cf0aac9400 Support for Glance v2
Implements wrappers necessary for Horizon to work with either Glance
v1 or v2 and removes the dependency on the Glance v1 endpoint.
Handles the differences between setting properties with v1 and v2 and
restricts some Glance functions that aren't supported in v2.

Implements blueprint: horizon-glance-v2
Co-Authored-By: Travis Tripp <travis.tripp@hp.com>
Co-Authored-By: Brad Pokorny <Brad_Pokorny@symantec.com>
Co-Authored-By: Timur Sufiev <tsufiev@mirantis.com>
Co-Authored-By: Liuqing Jing <jing.liuqing@99cloud.net>

Change-Id: Icca91c53eabf18c3109b3931ed53f70eaaaa0e56
2016-09-12 11:16:33 -07:00
Timur Sufiev 7e65af5f13 Embed support for external data sinks into api.glance
In case 'data' image attribute is a base string (instead of in-memory
or on-disk file), api.glance sends back an image wrapper with a redirect
url and a token to its caller, so the caller could upload the file to
that url directly.

Provide a unit test for api.glance behavior when an external upload
location is used. That also requires to fix glance stub endpoint data
in keystone_data.py since it didn't reflect the reality.

Also document the new HORIZON_IMAGES_UPLOAD_MODE setting that will
govern direct images upload and the define approach to deprecating the
old HORIZON_IMAGES_ALLOW_UPLOAD setting. The old setting is deprecated
as of Newton release and planned to be removed in P. 'Removing' means
that it will no longer be used / referenced at all in code, not the
actual presence in settings.py (it is removed from settings.py in this
commit). What really matters is if the customized value of
HORIZON_IMAGES_ALLOW_UPLOAD in local_settings.py will be still
considered during the deprecation period.

Help text in Django Create Image form in case if local file upload was
enabled was wrong, fixed that.

Related-Bug: #1403129
Partially implements blueprint: horizon-glance-large-image-upload

Change-Id: I24ff55e0135514fae89c20175cf9c764e871969b
2016-07-26 13:38:58 +00:00
Jenkins ba2bc3503e Merge "Support properties_target when fetching namespaces" 2016-02-05 06:21:42 +00:00
Timur Sufiev f8e595b0fa Sort images list in ascending alphabetical order
Move most of the pagination-logic to `api.glance.image_list_detailed`,
thus making code in Admin/Project->Images->get_data() less confusing
(and remove hard-coded 'asc'|'desc' values).

Also prepare to get images both from glanceclient.v1 and
glanceclient.v2 (which doesn't set `is_public` attr on images using
`visibility` attr instead).

Change-Id: Ibe6d3dd1e94a1d1fbf95382599a5f53c3559ce5a
Closes-Bug: #1534670
Closes-Bug: #1336317
2016-01-30 12:00:03 +00:00
Justin Pomeroy e55240d882 Support properties_target when fetching namespaces
This allows specifying a properties target when fetching metadata
definitions namespaces from glance, and updates the instance
metadata widget to show only "metadata" properties (as opposed to
"scheduler_hints") when creating an instance or updating the
metadata.

Closes-Bug: #1537842
Change-Id: I64dd279139eca2cbd0c0a6e808ade4cbcba8df95
2016-01-29 15:47:28 -06:00
Rajat Vig 0cd8c89731 API for Metadata Definitions
Adding REST API calls for use in the new angularized
panels for Metadata definitions.

Set DISABLED = False in
openstack_dashboard/enabled/_2131_admin_metadata_defs_panel.py

Change-Id: I08c9c05a7b0870160ede7eb7645fc9daa83e2dd5
Partially-Implements: blueprint ng-metadata-defs-panel
2016-01-13 10:01:53 -08:00
LiuNanke a566ba7713 Python 3 deprecated the logger.warn method in favor of warning
Python 3 deprecated the logger.warn method, see:
https://docs.python.org/3/library/logging.html#logging.warning, so we
prefer to use warning to avoid DeprecationWarning.

Closes-Bug: #1529913

Change-Id: Ief1ebbbc8198d2d7a01a5ec41b61d8b6d466da1f
2015-12-30 19:16:32 +00:00
Jenkins 22b87e180e Merge "Eliminate mutable default arguments" 2015-12-28 08:12:06 +00:00
hgangwx f89247d436 Misspelling in message
Misspelling in the message:
"some time and is handed off to a seperate thread."
Should be "some time and is handed off to a separate thread."
Totally 1 occasion in horizon base code.

Change-Id: I7a67c050c503c6fc7211f5191ea56bc0e8f6cb98
2015-12-23 17:53:57 +08:00
Timur Sufiev 7023050edd Eliminate mutable default arguments
The best practice in Python is not to use mutable object (i.e. list,
dictionary, or instances of most classes) as value of default
argument (see https://goo.gl/Kwhg0T). A hacking rule to enforce this 
practice is added as well.

The patch was inspired by CR https://review.openstack.org/#/c/198465/ 
and took most of its code from it as well. That's why original 
copyrights are kept.

Closes-Bug: #1471349
Change-Id: Ia77b1736dbc3d4e28ff2d2c3424e9cfcaefa5077
2015-12-17 09:58:46 +00:00
Bo Wang 7e02c996e8 Remove arguments "{}" in function definitions
remove mutable default arguments "{}" in function definitions
refer to:http://docs.python-guide.org/en/latest/writing/gotchas/

Close-Bug: #1526140

Change-Id: Ib85bd0238beaac95c53d9ae1779a5d566db9eb16
2015-12-15 14:30:22 +00:00
Justin Pomeroy 0578023d88 Add version check for listing namespaces
Listing metadata definitions namespaces requires glance API version
2. This adds a check that makes sure an empty array is returned if
any version less than 2 is being used.

Closes-Bug: #1516711
Partially-Implements: blueprint horizon-glance-v2
Change-Id: Ifc0a091318296da06168f9701a280eb7357632c7
2015-11-18 03:14:46 +00:00
Rajat Vig 7d004a34f1 Add REST API to get Glance API Version
This is needed to check if Image Metadata can be
updated.

Change-Id: I23f8b84f5f72a6423b0c453413faef25f2e139d2
Partially-Implements: blueprint angularize-images-table
2015-10-29 14:22:58 -07:00
David Lyle efafd2ba96 Fixing docstring formatting errors and warnings
Correcting numerous errors and warnings for doc generation.

Partial-Bug: #1486222
Change-Id: I6d6b20a433aa9965a1bafbd098e64b19886e5fca
2015-08-18 17:14:22 -06:00
Jenkins f08f3fa370 Merge "Create image directly in 'copy_from' and 'location' case" 2015-07-28 10:00:34 +00:00
Kirill Zaitsev 7eb4e3595c Handle errors during glance image updates correctly
Before an UnboundLocalError would occur in case an error would happen
during image updates, because of incorrect referencing of a variable.
Moreover the error was muted by exceptions.handle with ignore=True,
and could result in an incorrect success message.
This change removes references to unused image variable and allows
exceptions to be handled by the function, that calls image_update.

Change-Id: I35ea98a146690565582dd9beea62941f97d32474
Closes-Bug: #1464991
2015-06-15 23:48:46 +00:00