Commit Graph

46 Commits

Author SHA1 Message Date
Akihiro Motoki f3af02f20f openstack_dashboard: Move test files to match module structure
This commit relocates test codes in openstack_dashboard
according to blueprint relocation-test-codes.

Change-Id: I397a5a47fe9c1bf3a498c22056d924bf409c514b
2017-12-09 21:38:06 +09: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
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 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
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
Itxaka 4958805863 Merge "missing" quotas with nova quotas
There was an extra variable for the so called "missing"
quotas since 2013. This patch merges them with the
normal nova quotas, cleans up the tests, removes any
usage of that special var and as a side effect, adds
the missing keys to the project quota update page.

Change-Id: Icaac1ebb1749e13fdfc307e89dcc6bbd64bef922
Closes-Bug: 1655393
2017-03-01 15:30:33 +00:00
Jenkins c16c950d40 Merge "Fix volume storage usage value" 2016-12-16 05:07:21 +00:00
liyingjun 1a3ab89f22 Disable router and fip quotas when router is disabled
Currently Horizon unable to change quotas if routers extension is
disabled, fix this by adding router and floatingip quotas to
disabled_quotas when router extension is disabled.

Change-Id: I14d8a6e2e439ab48b62ce64c88ebb4643d11e49f
Closes-bug: #1457598
2016-11-18 17:27:34 +00:00
andrewbogott d7d59b8596 Remove all_tenants flag in quota check
I don't really know what this was meant to do, but what it actually
does doesn't make any sense -- when checking a quota for project
'foo' we really don't care about how many instances are used
in the entire cloud, only in project 'foo'.

Until Liberty, the all_tenant flag was broken in the nova
api, which probably explains why this was harmless until
Liberty.

Change-Id: I9e12c10951e7518ab1c622a4daac962bad332da5
Closes-Bug: #1610693
2016-10-26 15:30:33 +00:00
Rebecca Finn 212e8b889c Fix volume storage usage value
When calculating the used volume storage value to compare against
"Total Size of Volumes and Snapshots", only the size of volumes
was being used while volume snapshots were ignored. This allows a
user to update the "Total Size of Volumes and Snapshots" quota to
a value that is below what was currently being used without the
expected error.

This patch updates _get_tenant_volume_usages to use both volumes
and volume snapshots. It also updates a test to reflect the correct
"used" value.

Change-Id: Ifb2586b048edbabfe9740a5c72b7abfbcf12576d
Closes-Bug: #1611027
2016-08-09 23:40:45 +00:00
Steve McLellan 018e99d20e Allow horizon to function without nova
Adds conditional block to nova quotas to exclude them if nova is not
enabled; adds 'permission' checks to the project overview and
access_and_security panels to only enable them if compute is enabled;
adds permission checks on compute and image to the admin overview
and metadef panels; disables 'modify quota' and 'view usage' project
actions; disables 'update defaults' if there are no quotas available.

The 'access and security' panel still appears (under Compute) but
tabs other than the keystone endpoint and RC download tab are hidden.

Closes-Bug: #1580116
Change-Id: I1b2ddee0395ad9f55692111604b31618c4eaf69e
2016-07-26 09:15:48 -05:00
Timur Sufiev baca29144b Pay attention to Nova disabled quotas defined in a config file
Since Nova doesn't currently provide an API call to indicate whether
its quotas are disabled, we could use a parameter named
'enable_quotas' within 'OPENSTACK_HYPERVISOR_FEATURES' setting for
this purpose. This allows to avoid errors while trying to update
quotas which are disabled on service side. Also make disabled_quotas
collection to be a set instead of a list - this removes duplicate
fields that appear due to some possible quota overlaps between Nova
and Neutron.

Also, since we dropped out python2.6 support fancy set literals and
dict comprehensions can be used.

Co-Authored-By: Paul Karikh <pkarikh@mirantis.com>
Closes-Bug: #1286099
Change-Id: I10923f147e4c323aba8bbcc130d2016ad6725e86
2016-07-19 17:51:08 +00:00
Itxaka 35eb25a955 Make sure we always get all limits
When checking with nova for the absolute limits
we were not taking into account the reserved
quotas (i.e. instance in rebuilding will take
cpu and ram) so this could lead to wrongly
thinking that the user could launch more instances
that its quota allowed. It also made the overview
page display wrong quotas as it didnt took into
account those reserved resources.

Change-Id: If51470d185ddc122acbdf4cf0d0fd952f3f791a0
Closes-bug: 1561310
2016-06-08 10:40:46 +00:00
IWAMOTO Toshihiro 2e59431227 Look for volumev2 endpoints instead of volume
Volumes tabs should be enabled when volumev2 endpoint is registered.
Currently, Horizon considers no volume service is running if there
is no V1 endpoint, which doesn't make sense as Horizon no longer
supports the cinder V1 protocol.

Co-Authored-By: itxaka <itxaka@redhat.com>
Change-Id: I35d821eedb75f73f9330ed11f921694104eed0c6
Closes-Bug: 1415712
2016-02-23 11:47:25 +01:00
Itxaka fb8bedc375 fix ClientException call
We were calling cinder.ClientException even when the import
had changed to be cinder.cinder_exception.ClientException
Adds 3 tests for the methods calling that exception so
failures will be tested as well.

Co-Authored-By: zhurong <aaronzhu1121@gmail.com>
Change-Id: I8c415eb8ef847f6dc34fa56fca3181560ead366b
Closes-Bug: #1537713
Closes-Bug: #1535215
2016-01-26 10:22:20 +01:00
Victor Stinner 674a45ffe0 Replace mox with mox3
mox doesn't work on Python 3, whereas mox3 works on Python 2 and Python
3. Cinder, Nova and many other projects already replaced mox with mox3.
mox3 is now maintained by OpenStack.

Partial-Implements: blueprint porting-python3
Change-Id: I10e6a9754ebd58a2640d73ec8966527c3aa1fe9a
2015-07-13 15:02:10 +02:00
liyingjun faa44bfe1d Fix _get_tenant_volume_usages
The search opts for volume/snapshot list should be 'all_tenants' and
'project_id' instead of 'alltenants' and 'tenant_id'.

Change-Id: I9ab71421447b3f8fb402247df3290fa3066bf8c5
Closes-bug: #1469589
2015-06-29 21:45:35 +08:00
Kieran Spear d54e7b91bb Fix incorrect mocking in quota tests
We're using self.snapshots as the return value for volume_snapshot_list,
which is a list of Glance snapshots. It should be
self.cinder_volume_snapshots.

Also change the assert to assertItemsEqual since we're dealing with
dictionaries.

Closes-bug: 1413480
Change-Id: I9632490e94c5d5cd435363c74a2ec65546a9c29f
2015-01-22 16:37:06 +11:00
eric f5b77f9a14 Quotas for users with admin role do not work
The quotas code does not isloate counts to resources within the
current tenant/project.  So if a user with the admin role makes
calls for quota items, the admin role will have counts of a global
list of resources.  This changes that for the tenant quota call
to fallback to the request.user.project_id if no project was
otherwise specified for the tenant quota api call.

Change-Id: Ib0e6ce7774c4c03686a044f233dbb9aa36dbe1b9
Closes-bug: #1391242
2014-11-30 07:03:20 -07: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
Akihiro Motoki 26da6ed48c Fix E127 errors in remaining openstack_dashboard/
E127 continuation line over-indented for visual indent

Also fixes E127 introduces by other reviews
after other E127 fixes were merged.

Closes-Bug: #1375931
Change-Id: I0a09f1c2f74c707fc8a347f0ea5975bf2679976e
2014-10-15 13:50:07 +09:00
ChenZheng c7d5371b47 Fix order of arguments in assertEqual
Some tests used incorrect order assertEqual(observed, expected).

The correct order expected by testtools is
assertEqual(expected, observed).

Change-Id: Iabf6e55146412b57b6a6544f312f9510f762566a
Partial-Bug: #1259292
2014-09-01 10:41:52 +08:00
Akihiro Motoki 936fc59aa8 Disable Floating IP features if Neutron router is disabled
If the config option 'enable_router' is set to False,
Floating IP features are disabled when Neutron is enabled.
It does not affect when Neutron is disabled.

It also adds unit tests for api.network.servers_update_addresses
which is affected by this change.

Completes blueprint hide-router-panel-by-config
Closes-Bug: #1292022
Change-Id: Ib63c6a0e7bb5661d4a60d10a1722fdad978b50bb
2014-08-30 05:12:27 +09:00
Santiago Baldassin 023caca4ba Removing non-bootable volumes from boot source
Volumes which bootable flag is set to False should
not be included in the boot source combo box when
the user select the Boot from volume option

Change-Id: I7bfe0aa1c4954ef2d50fa27db147bf15d4daccc1
Closes-Bug: #1319900
2014-05-20 10:07:07 -03:00
He Yongli e790ac070e Remove extraneous vim configuration comments
Remove vim setting:
comment - # vim: tabstop=4 shiftwidth=4 softtabstop=4

at the top of source code files, except for files in
openstack/common.

Change-Id: I9a5c6b17c6ef7ecec601f4503dfc7b31fc72e90a
Close-bug: #1229324
2014-05-06 15:30:10 +08:00
Ana Krivokapic f2de787d8a Add missing __contains__() and get() methods to QuotaUsage
The QuotaUsage class was missing __contains__() and get() methods which was
causing unexpected behaviour, e.g:

    >>> usages = quotas.tenant_quota_usages(request)
    >>> 'ram' in usages
    False
    >>> usages.get('ram')
    None

Change-Id: Ib0b1ad69c4bf4effd7c10827d23bcc713bdc5ed6
2013-12-20 13:19:51 +01:00
simon afaa72185c PEP8 E126 has been resolved
Change-Id: Ic5d3b96b6061b7a34e7620d8d09418bd6976fbb1
Partial-Bug: #1085346
2013-09-17 20:48:09 +09:00
Dirk Mueller 872f44c167 assertEquals is deprecated, use assertEqual
Change-Id: Id3ebdf4862b02f2965199701a4994846bcecbb18
2013-09-16 22:55:16 +02:00
Julie Pichon 3852d1ce19 View and update Neutron project quotas
Also ensure that the correct quota is displayed in the Floating IPs
allocation page (Security & Access panel).

Closes-Bug: #1109140

Change-Id: I30d207fbf149bfbcfefeaddf91af49082b7b1f53
2013-08-27 19:13:10 +01:00
Julie Pichon 065786c745 Import is_service_enabled from module
An additional step for H302, and needed here to make mocking
is_service_enabled across modules more consistent and easier
(e.g. mocking only one signature as opposed to both
api.base.is_service_enabled and quotas.is_service_enabled).

Partial-Bug: #1109140

Change-Id: Ie6cec3138de6f2fc57b68e90db45f53bb94ab87d
2013-08-27 19:13:10 +01:00
Tatiana Mazur 953d1b9793 Enable H302 check
This patch replaces some method imports with module imports and
makes H302 test enabled.

Fixes bug 1188531

Change-Id: Ibfbddeaa19cbbb244da58ffd5c918c41f03a0c65
2013-08-22 17:39:09 +04:00
Tihomir Trifonov 0c0153a037 Improvements in csv export for usage data
Added a csv writer using the 'csv' library to format
properly exported data - escaping, encoding etc.
Added a HttpResponse-based class to handle csv generation
Added translation for the CSV columns and template.

Fix bug #1158383

Renamed few occurencies of 'tenant' to 'project'.

Also added a new 'project' in nova_data.py, which required
some refactoring of few tests, that didn't consider the current project
for project-based calls.

Note: I've added a StreamingHttpResponse example,
which is introduced in Django 1.5+ and being advised in the ticket.
However, my opinion is that at the moment we don't need this - it is
too complicated for the current usage.

Change-Id: I18bd70a23b7b8389c7c0f96dbf8794fea5e1e75b
2013-06-21 14:00:37 +03:00
Jan Provaznik ea1edcb027 Enable snapshot quota setting
Change-Id: Ie8bcd2d2fddf717a29328bc802a2fda80198183b
Fixes: bug #1177249
2013-05-27 14:22:38 +02:00
Kieran Spear ef26414b8d Revert "Improvements in csv export for usage data"
This reverts commit a4e583cffb

Fixes bug 1183441, bug 1183230, bug 1183310.
2013-05-23 16:50:57 +00:00
Tihomir Trifonov a4e583cffb Improvements in csv export for usage data
Added a csv writer using the 'csv' library to format
properly exported data - escaping, encoding etc.
Added a HttpResponse-based class to handle csv generation
Added translation for the CSV columns and template.
Improved consistency for exported data - now passing project name
instead of project id for csv export. Also added both project name/id
in the header of a project usage export.

Fix bug #1158383

Renamed few occurencies of 'tenant' to project.

Also added a new 'project' in nova_data.py, which required
some refactoring of few tests, that didn't consider the current project
for project-based calls.

Note: I've added a StreamingHttpResponse example,
which is introduced in Django 1.5+ and  being advised in the ticket.
However, my opinion is that at the moment we don't need this - it is
too complicated for the current usage.

Change-Id: Ic00626b273921fa5c6c89704b3a9e08b252aaeb0
2013-05-22 11:09:49 +03:00
David Lyle 81247fda00 Adding pagination to the instance views
Modifying the api.nova.server_list() method to optionally handle
pagination.  The method will also work without pagination to
support the many other place than the instance views that continue
to call the method.

Fixes: bug #1046915

Change-Id: I8195f1f2d8922e1722743d7a2d627a8645e8b3bd
2013-04-11 21:24:01 -06:00
Julie Pichon e65e3e8bc3 Refactor the quotas tests
Refactoring as part of bug 1157950 to limit the amount of copy-pasting
required when adding a new quota

Change-Id: I32fb28da0d4640c463fb6e22ee04763012d12190
2013-04-04 14:47:56 +01:00
Julie Pichon d5f2dc38e6 Allow admin to edit project quotas for fixed IPs
Fixes bug #1157950

Change-Id: If8bf548f66ff13b2b5218ca6c1e8c69c054e0a59
2013-03-26 17:58:01 +00:00
Julie Pichon 7584fe39b4 Allow admin to edit project quotas for security groups and rules
Fixes bug 1078092

Change-Id: I1018f07f740b7e27e14fb00bac4c3cce177469e2
2013-02-19 15:57:24 +00:00
Akihiro MOTOKI dbfcc97e89 Quantum Floating IP support
blueprint quantum-floating-ip

This commit allows OpenStack dashboard users to use Quantum floating
IP feature directly using Quantum API rather than Nova Proxy.
By this users can associates a floating IP per virtual NIC.

blueprint nova-net-quantum-abstraction

This commit defines an abstract class in api/network.py.
This class provides common interfaces related to network features
duplicated in Nova and Quantum. A concrete class to handle operations
should be defined in api/nova.py or api/quantum.py.

Change-Id: I780356a9f41e72e32ce1877d390ac7f99e96899c
2013-01-30 20:38:35 +09:00
Victoria Martínez de la Cruz aec73a78b2 Add a check for unlimited quotas
This extra check will prevent Horizon to misunderstand "-1" value when tallying quotas,
setting the "Available" field to inf instead of 0.

Fixes: bug #1084976
Change-Id: Ib316a15ac8ffa8ed4e4c51c02d5956db57fb6f6e
2012-12-05 16:34:20 -03:00
Julie Pichon 300747c9a3 Make sure vCPU and RAM quotas are initialised when no instances are running
Fixes bug 1084609

Change-Id: Ia89c2071e8366912f97bc7c3a63caccc26430e53
2012-11-29 21:11:45 +00:00
Tihomir Trifonov 4c88b9b597 Added a check for volume service in quota functions
When displaying the quotas, we have to check if
volume service is present in the service catalog.
If not - then to remove the volume quotas from
the result object.

Fixes bug 1075319

Change-Id: Icd049a5b147cac039add1570a166d775fd0d6ec4
2012-11-09 15:00:30 +02:00
Gabriel Hurley cdcd8e3df6 Enable quota data from multiple sources.
Now that there are multiple projects with quota data (cinder, quantum)
we need to accommodate that data being aggregated in a centralized
fashion. This commit takes care of that for nova + cinder, and paves
the way for quantum later.

Fixes bug 1070022.

Change-Id: Ifc68c2dc681b2a7b4e7787e0b1a7dca1a970fc36
2012-10-24 12:53:42 -07:00