Commit Graph

169 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
Pedro Kostelec ae7896cea5 Consisent abbreviation of size units
Most units (KB, MB, GB, TB, PB) are shown in an abbreviated format.
The exception were bytes, which where shown as "Bytes". This commit
resolves this inconsistency by showing "B" for byte units.

Change-Id: Ied94c777a70bf8955f5a328ffcb63d98a7a2befd
Closes-Bug: 1411595
Signed-off-by: Iago Estrela <hiagoestrelas@gmail.com>
2021-05-04 11:50:17 -03:00
manchandavishal 982e772a61 Add try/except block for some nova and neutron api calls
This patch add try/except block for nova and neutron api calls
which are missing in 'openstack_dashboard/usage/quotas.py' file.

Change-Id: I6b880c69083154c77a14582d6fe23b42f988355e
Closes-Bug: #1383580
2020-12-02 14:12:02 +00:00
Zuul d6ab5431ba Merge "Drop the legacy way to retrieve neutron quotas and usages" 2020-11-18 18:08:06 +00:00
Akihiro Motoki c45cc6b1c5 Drop the usage of nova extensions in python code
Part of the removal of OPENSTACK_NOVA_EXTENSIONS_BLACKLIST (1/3)

All references of nova extensions in the python code are cleaned up.
Note that the API layer is not touched yet as it is used by the
JavaScript side.

Change-Id: I66cd0a9629253a6462aace9902ef8200b94b2a21
2020-10-27 20:00:45 +09:00
Akihiro Motoki c9e47d6595 Add new setting for SimpleTenantUsage
This introduces a new setting OPENSTACK_USE_SIMPLE_TENANT_USAGE
as a replace of SimpleTenantUsage in OPENSTACK_NOVA_EXTENSIONS_BLACKLIST.
We received feedbacks on the need to control whether SimpleTenantUsage
is used or not, so we need a new setting before retiring
OPENSTACK_NOVA_EXTENSIONS_BLACKLIST.

Change-Id: Ib786ea2ac232fcd851f4b276b9144c14c0b62a0a
2020-10-27 19:59:34 +09:00
Akihiro Motoki 22741aaa3e Drop the legacy way to retrieve neutron quotas and usages
quota_details neutron API extension was implemented since Pike
and the enough migration period has passed. We have not received
any negative feedback on the removal of the legacy way since
its deprecation in Ussuri release.

Change-Id: Ia249e83a7d40af873d6509c932b11cb9bb7a9497
2020-10-26 17:25:56 +09: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
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
Marek 161b4ae5d4 Fixes a series of bugs related to Floating IPs.
- Fixes KeyErrors when accessing 'floatingip' values in usages, which
  broken Floating IP allocation.
- The quota display in the bottom right of the Allocation dialog are
  only displayed if 'enabled_quotas' is True
- Adds security group rule tallying for the usages overview page, which
  fixes a KeyError crash for installations where Horizon 'enable_quotas'
  is set to true, but the 'quota_details' extension is not installed on
  in Neutron
- Adds a policy check to show and hide The plus/add button in
  Instances->Associate Floating IP to match the Allocate IP To Project
  button in Floating IPs
- Fixed the page title not being set for the non-modal version of the
  modal allocation dialog/form
- Added an 'allowed' functionality for network usage overview charts to
  allow for them to be dynamically disabled
- Added tests and mocks for the above
- Added tests for non-legacy quota tallying for networks
- Added test for disabled network quotas in overview

Change-Id: I47f73ff94664d315a2400feb8ce8a25f4e6beced
closes-bug: #1838522
2019-12-17 13:30:25 +09:00
Gloria Gu 44987f02be Remove the check which causes plugin's quotas update failure
The check causes external plugin's quotas fields unknown
exception because the quotas fields are not part of
QUOTA_FIELDS which only includes the fields for
cinder, neutron and nova.

Meanwhile the exception message throws TypeError.

This commit removes the uncessary check. It also helps
fix the manila-ui's bug #1842119

Change-Id: If093f4ecf1e344792b347c5c338b441b1ab42a04
Closes-bug: #1798048
Closes-bug: #1842119
2019-09-03 12:29:53 -07: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 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
manchandavishal d6217b3e63 Instances column is shortened so it fits properly
The 'Time since created' column name has been shortened to 'Age'
in project instances and admin instances meaning it fits properly
in table header cell and doesn't cause table header height to
increase.

Closes-Bug: #1614287

Change-Id: I94fc9eb260050e187445abd8236ac414b885b467
Co-Authored-By: Sam Wright <swright.wellington@gmail.com>
2018-12-18 10:01:56 +00:00
Zuul 033b57ce13 Merge "quota: Move targets argument to get_disabled_quotas" 2018-05-16 16:59:31 +00:00
Zuul 63ac162658 Merge "quota: Merge tenant_limit_usages into tenant_quota_usages" 2018-05-16 16:52:55 +00:00
Zuul 17ce74e4f0 Merge "usage: Categorize Limit Summary by service" 2018-05-08 08:23:47 +00:00
wei.ying e0e81e2b87 Add server groups and server group members quota management in Horizon
Currently we can't set server groups and server group members quotas
in Horizon, they are still the back end definition of default.
In some cases, it will failed to create an instance when server group
members quota is insufficient. Therefore, it is necessary to specify
the quota of the server groups and server group members when creating
and editing the project. This patch allows the user to modify the
default values for the server groups and the server group members
quota.

Change-Id: Ifbd51bec3e775d8fecbf110da37309a443a3d1ba
Closes-Bug:#1732429
2018-05-06 00:33:41 +08:00
Akihiro Motoki df780f21d7 quota: Merge tenant_limit_usages into tenant_quota_usages
The response of tenant_quota_usages is now baesd on the limit API,
so tenant_limit_usages and tenant_quota_usages provide same information.
This commit changes all consumers of tenant_limit_usages to use
tenant_quota_usages and updates the corresponding templates.

blueprint make-quotas-great-again
Change-Id: I620e2946f2aca31bac134c247ceaf971498f9eeb
2018-05-02 01:19:25 +09:00
HyunsikYang fa20420246 Bug Fix : Local variable 'quota_display' referenced before assignment
closes-Bug: #1767354

Change-Id: I6eed169b8c5f18295734cb6453c7256f31de10d3
2018-04-28 15:32:03 +09:00
Akihiro Motoki 06ca3c811b quota: Move targets argument to get_disabled_quotas
In addition, unnecessary API calls determined by 'targets'
are now removed.

blueprint make-quotas-great-again
Change-Id: I77b1335c25f2e2f3952e0d3c59f8c89a2bad3195
2018-04-19 20:37:46 +00:00
Akihiro Motoki f897837444 usage: Categorize Limit Summary by service
blueprint make-quotas-great-again
Change-Id: Ia030defa851d8ce3e9a5e225dbf9c360b2b0c09a
2018-04-20 05:34:33 +09:00
Akihiro Motoki b5671a22ee usage: Add network resources to Limit Summary
blueprint make-quotas-great-again
Change-Id: I5594b594e5f5d7ca5341fb479b48efac6578c5c8
2018-04-20 05:29:58 +09:00
Akihiro Motoki b0dc533527 usage: move field-specific logic from template to code
_limit_summary.html has field-specific logic in the template,
but it is better to have such logic in python code so that
we can make the limit summary more pluggable in future.

In addition, filters for ram and volume gigabytes are applied
only when quota is not unlimited. This commit also fixes it.

blueprint make-quotas-great-again
Change-Id: I4c9584431c2526ebecf6d1438c1bf0e44f70a493
2018-04-20 05:29:57 +09:00
Akihiro Motoki 7fabda7ef1 usage: Use tenant_quota_usages() for Limit Summary
Previously we have almost duplicated logic for the limit summary
and quota usages. This commit shares the logic.

blueprint make-quotas-great-again
Change-Id: Ie5d7e51c9424701fdbcbfbcb1032c0b833a69371
2018-04-20 05:29:53 +09:00
Ivan Kolodyazhny b12264140c Speed up quotas fetching using futurist library
Partial-implements: blueprint fetch-resources-in-parallel
Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Change-Id: I95f02f16b3d3dcbc1dff60d7fb35d31016e8679d
2018-03-15 13:00:48 +02:00
Akihiro Motoki e477eafa45 django2: Replace django.core.urlresolves with django.urls
(In Django 2.0) The django.core.urlresolvers module is removed
in favor of its new location, django.urls.
It was depreacted in Django 1.10:
https://docs.djangoproject.com/en/2.0/releases/1.10/#id3

blueprint django2-support
Change-Id: I46ab5c325491274b8eaffbf848e5d80f83c2fd26
2018-02-17 01:36:48 +09:00
Zuul b967a3c3c7 Merge "usage: split out the limit related logic into ProjectUsageView" 2018-01-25 21:25:24 +00:00
Akihiro Motoki dc7d2582db quota: Use neutron default quota (read-only) API
Neutron provides an API to retrieve default quotas since newton.
Unfortunately there is no corresponding neutron API extension
is not defined, so there is no way to detect it via API.
The API exists since newton, so this commit just switches to
the default quota API.

Closes-Bug: #1337473
blueprint make-quotas-great-again
Change-Id: Ia826b67f4cec7d95335c62ef98c3040feaa06117
2018-01-14 04:53:30 +09:00
Akihiro Motoki 788388c486 usage: split out the limit related logic into ProjectUsageView
Previously limit information was always retrieved but it is not
used in the admin overview. This commit moves the limit related logic
into a separate class ProjectUsageView.

testing of usage.views is covered by individual panel tests,
so UTs for panels which uses UsageView rather than the new
ProjectUsageView need to be updated in this commit.

blueprint make-quotas-great-again
Change-Id: Id93b66d11e3b0c98d1fbb0454bb43984c2999d92
2018-01-14 04:15:27 +09:00
Zuul 01ffeb9389 Merge "quota: Move neutron quota logic in identity.projects.views" 2018-01-12 14:04:48 +00:00
Akihiro Motoki e0fb453e17 quota: Move neutron quota logic in identity.projects.views
identity.projects.views has a special logic related to neutron
quota, but it is time to merge this into usages.quotas.
This commit merges the logic into usages.quotas.
It is a preparation to use neutron default quotas API.

blueprint make-quotas-great-again
Change-Id: I35f0dede5d53ee6758996268cd1a6c2095565cc8
2018-01-10 15:33:00 +09:00
Akihiro Motoki 6baf8c9fa0 Handle float('inf') in tenant_quota_usages properly
tenant_absolute_limits API wrapper converts -1 (unlimited)
to float('inf'), but tenant_quota_usages() cannot handle this
properly. This is a regression during the quota refactoring work.
This commit changes QuotaUsage.add_quota() to accept float('inf')
as one of unlimited quota value.

Closes-Bug: #1741493
Part of blueprint make-quotas-great-again
Change-Id: Ic6ed00761381d52ee04a15a43ee4fe2a30b9a106
2018-01-06 03:54:30 +09:00
Akihiro Motoki 1340904d47 quota: Use network quota field names consistently
Previously neutron quota names and nova-network quota names are
mixly used and this makes the readability terrible.
We no longer supports nova-network, so it looks simple to use
neutron quota names consistently.

Neutron quota names use singular form and it is different
from nova and cinder (which adopt plural form as quota names).
Although it might be confusing, the mixed usage is much worse.
Some wrapper layer may address singular vs plural form issue,
but it can be solved later. Let's use neutron quota names
directly now to simplify the code.

blueprint make-quotas-great-again
Change-Id: Ie31414ada34cbdbd046063b512d3cef0a6e68acf
2017-12-13 20:27:02 +09:00
Akihiro Motoki cd3f3e5127 quota: Use neutron quota_details API to retrieve usage
Previously neutron did not provide a way to retrieve resource usage
in a single API, so we need to call list APIs and count the number of
resources. Since Pike release, quota details API is provided and
it returns both quota and usage (used + reserved).

blueprint make-quotas-great-again
Change-Id: I63d0e81654c18f0f235631922d64d1109233fcfa
2017-12-13 20:27:02 +09:00
Akihiro Motoki df0a18e7a3 quota: retrieve quota (limit) and usage at once
Previously tenant_quota_usages() uses list API operations
to count usages. It is not efficient. This commit changes
the limit APIs from nova and cinder to retrieve usages.

blueprint make-quotas-great-again
Change-Id: I2c9a479758a1dfe134e5fabf16ab02831338718d
2017-12-13 20:27:02 +09:00
Akihiro Motoki 34fb3e5b0e quota: Disable nova-network quotas completely
nova-network quotas are considered in usage/quotas.py previously.
This commit completely always disables nova-network quotas.

The nova API wrapper ensures nova-network quota fileds are not
included in responses from tenant_quota_get and default_quota_get.

Drop nova-network quota fields from the Admin Defaults panel and
the Identity Project quota form.

blueprint make-quotas-great-again
Change-Id: Ie69d3003f62d3a124d79a1fea003092f73372187
2017-12-13 20:27:02 +09:00
Zuul c019486483 Merge "Use specified phrases in lieu of 'Used' for limit summary" 2017-11-14 13:30:45 +00:00
Nick Timkovich edbf88fa79 Use specified phrases in lieu of 'Used' for limit summary
Some resources, namely floating IPs, are limited based on those
allocated, rather than in actual use. The "Allocated" string is present
in the code but not used in the template. This effectively changes "Used
X of Y" to "Allocated X of Y" for floating IPs.

Change-Id: I7919b883a47d66b1e870862363d07e0f90bdbe7b
Closes-Bug: #1708733
2017-11-14 12:06:17 +00:00
David Lyle 33dc94079c Correct quota usage check for instances
Previously, updating the quota value for instance on a project that
the user was not currently scoped to would validate the new quota
value by comparing with the usage of the currently scoped project.
The cause of this error was an incorrect use of the server list
parameters.

According to the comment in nova source:
d43d1d6734/nova/api/openstack/compute/servers.py (L277-L280)
and the comments in this bug:
https://bugs.launchpad.net/nova/+bug/1185290

indicate that the tenant_id or project_id flag cannot be used without
the --all-tenants flag.

The fix involves passing the --all-tenants flag when querying instance usage
for any project the user is not currently scoped to. It also removes the
passing of the tenant_id flag when querying the current project.

Tests were also updated to match the new behavior by not passing the
tenant_id to the API call to list servers where the target project is
the currently scoped project.

Change-Id: Iee06bc1c8ccd50f595f4cb274f956c13495c8494
Closes-Bug: #1713724
2017-10-23 14:18:50 +00:00
wei.ying 0b65dbc913 Disable 'Create Port' button if ports quota is exceeded
Ports has quota management in a project, if quota is exceeded,
will create failure and API returns
"Recoverable error: Quota exceeded for resources: ['port']".
So, it should be like creating a network and subnet to
perform quota checks on ports, and if the quota is exceeded,
add text descriptions to the create port button and disable it.

Change-Id: I31bd8f93c312179b86115544ba0fadc9a9ffec63
Closes-Bug:#1712556
2017-08-29 20:41:58 +08:00
wei.ying 233680f541 Delete unnecessary judgment when getting the neutron quota
Nova and cinder quotas data does not contain networks, subnets, and
routers. So, some judgments are not necessary when getting the neutron
quota.

Change-Id: Icad9fdf34199942a976def23905d586739ef25df
2017-08-28 14:06:36 +08:00
Mykhailo Dovgal d132c2eb11 Get rid of redundant cinder api calls
During executing tenant_limit_usages quotas function we get
information about cinder volumes/snapshots/gigabites usage
that we've already had after tenant_absolute_limits call.
Getting this information we make more api calls that slow down
our application.

This patch fixes this issue.

Closes-Bug: #1703584
Change-Id: Ia6d2dbb8f18ce93f71668d6ebd2689b851586ca9
2017-07-14 16:29:06 +03:00
Mykhailo Dovgal ca0f293cb6 Fix tenant_quota_usages function calls caching
This patch changes type of 'targets' input parameter in
tenant_quota_usages function from list -> tuple. It provides
possibility for @memoized decorator to cache function calls.

Change-Id: I3c32c3b65ae91e8487fda6148f259fe1931d7c9f
Closes-Bug: #1700578
2017-06-26 17:36:07 +03:00
Akihiro Motoki 359467b401 Retrieve quota and usage only for resources really required
tenant_quota_usage() is used to retrieve quota and usage
to determine if a resource can be created.
However, tenant_quota_usage retrieves quota and usage for
all resources and it can be a performance problem.

This commit allows to load quota and usage only for resources
which are actually required.

Closes-Bug: #1675504
Change-Id: Iab7322a337a451a1a040cc2f4b55cc319b1ffc4c
2017-06-14 08:53:32 +00: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
Akihiro Motoki 9067ae8b0f Move SG and FIP API wrapper to api.neutron
We no longer need to have SG and FIP API wrapper in api.network
as we only supports a single network back-end.

Completes blueprint drop-nova-network

Change-Id: I4e59d897508b497a3cd2ae2fda93b30b786610dc
2017-06-04 17:51:25 +00:00
Akihiro Motoki 81891697c6 Retrieve quota and usage only for quota-enabled resources
Previously _get_tenant_(compute|network|volume)_usage are callled
regardless of resources are listed in enabled_quotas.
This commit retrives usage information only for resources listed
in eanbled_quotas.

floating_ips and security_groups were returned even when
they are included in disabled_quotas. They are not needed
and they are cleanup in this commit.

All (*_)QUOTA_FILEDS were previously a list but it is always used
after converting into a set, so this commit changes (*_)QUOTA_FIELDS
into a set in the initial definitions.

This is a preparation for fix of bug 1675504

Partial-Bug: #1675504
Change-Id: I41cdabde477d87aa8b35d1c908e18a69454286c3
2017-05-05 13:53:11 +00:00