118 Commits

Author SHA1 Message Date
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
liaozd
296d48074d clean unused imports
Change-Id: I9db0bbe3d24fb04e647fcfca1a3a746df006f85c
2017-02-12 17:58:11 +08:00
Jenkins
c16c950d40 Merge "Fix volume storage usage value" 2016-12-16 05:07:21 +00: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
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
Jenkins
ae67620b5f Merge "Usage tables: Sort by disk properly" 2016-10-21 02:23:56 +00:00
eric
5d64e2db73 Quota cleanup of dynamic methods
Removing the usage of calling dynamic methods within the
quotas code.  This makes it difficult to support and see
who is calling what code.

Change-Id: Ie2c6be3233dd2cff16eb2271e2ac3f4b04d6e2b5
Implements: blueprint make-quotas-great-again
2016-09-19 08:50:15 -06:00
eric
46f99895fb remove unused quotas code
This code is not used anywhere, removing.

Change-Id: I526b8c13e6f5ad8d441f219bb4dca36c0377adfe
Implements: blueprint make-quotas-great-again
2016-08-29 14:56:44 -06: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
Alex Monk
5ea8482ae4 Usage tables: Sort by disk properly
Change-Id: I05057ac399f6b4b0d8935a88684f7ed7099c367d
Closes-Bug: #1610173
2016-08-05 10:30:57 +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
028aecc192 Take shared subnets into account for quotas
Previously, shared subnets were ignored by collecting used
networks; the "Create subnet" button is still enabled, but
subnet creation is forbidden by neutron due to quota reached.

Change-Id: I20b3373ab86631922945285a12ca4810b707b0be
Closes-Bug: #1588764
2016-07-01 09:50:40 +00:00
Pierre-Alexandre Bardina
4570413773 Add units in overview project page (limit summary)
Since liberty, there is no unit in the overview project page. Trying to
fix it.

Closes-bug: #1589523

Change-Id: I82710d7157b0b8b3cc8128283cd0bfa2f075db71
2016-06-24 15:36:33 +00:00
Jenkins
12d7d0bc72 Merge "Make sure we always get all limits" 2016-06-24 02:42:40 +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
Timur Sufiev
5da5fd3196 Reduce the default date range on Overview panel to 1 day
First, the default default date range used on Overview panel is made
configurable (setting OVERVIEW_DAYS_RANGE). Second, its default value
is set to 1 day. Changing the default behavior is aimed to improve
load time of the default page in the presence of large amounts of
data. If OVERVIEW_DAYS_RANGE setting is explicitly set to None, the
behavior remains the same - the default date range is from the
beginning of the current month until today.

Co-Authored-By: Dmitry Sutyagin <dsutyagin@mirantis.com>
Change-Id: I55a0397f69e33ba9c8fb1f27d57838efcd8648af
Closes-Bug: #1508571
2016-05-31 17:57:53 +03: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
Akihiro Motoki
5fc26b0a11 Replace "Terminate Instance" with "Delete Instance"
"Delete" is being used almost everywhere in OpenStack Dashboard
except the instance panel. Using "Delete" looks more consistent.
In addition, "Delete" tells non-native English speakers that
deleted instances will be no longer usable again compared to
"Terminate".

DocImpact
Closes-Bug: #1502773
Change-Id: Idccaf3c45566f20f11d02ada64c1d3934a6f3002
2015-11-30 03:55:19 +09:00
Itxaka
65f919e87f Translate Floating IPs on overview page
Floating Ips was not being translated properly.

Change-Id: I57128e0dba5e2524cc2a326abdfc983d46df4c69
Closes-Bug: 1516162
2015-11-23 12:49:39 +01:00
Jenkins
df83da06cd Merge "Port project instance tests to Python 3" 2015-11-10 12:00:37 +00:00
Victor Stinner
49671ca4cf Port project instance tests to Python 3
* Fix division: replace a/b with a//b to get integers
* test_clean_file_upload_form_invalid_data(): use a byte string, not
  an unicode string for the test. The test ensures that decoding from
  UTF-8 fails.
* quotas: replace filter() with a list-comprehesion to get a list on
  Python 3.
* tox.ini: add the following tests to Python 3.4

  - openstack_dashboard.dashboards.project.instances.tests
  - openstack_dashboard.test.tests.quotas

* tox.ini: add also
  --exclude-dir=openstack_dashboard/test/integration_tests to
  openstack_dashboard tests on Python 3.4

Partial-Implements: blueprint porting-python3
Change-Id: I7caed713222b50ffec431155e6f91b543f7df466
2015-11-09 10:44:25 +01:00
Matthias Runge
79c634422d Take shared networks into account for quotas
Previously, shared networks were ignored by collecting used
networks; the "Create network" button is still enabled, but
network creation is forbidden by neutron due to quota reached.

Change-Id: I97360e354ccb7c2aa58012f737a7e9c67f8d3ad6
Closes-Bug: #1513795
2015-11-06 14:27:11 +01:00
Jesse Keating
944c8bafdc Use sum of volumes and snapshots for cinder usage
The cinder quota on gigabytes is the sum of both volumes and snapshots,
therefore in the horizon view we should be representing usage as the
combination of volumes and snapshots, otherwise users will be confused
when getting quota errors on volume or snapshot creation.

Closes-Bug: 1513179
Change-Id: Id23e0dd3a3f810e75f9013cecbf8a826c97e34c6
2015-11-04 18:45:17 +00:00
Lucas Palm
642aa9a351 Corrected spelling errors throughout the project
While browsing through the Horizon repository, I came across a
few spelling errors that need correction.

Change-Id: I593e9f04ea5d9f3985a14fb994b745243468387a
Closes-Bug: #1511532
2015-10-29 16:18:49 -05:00
Victor Stinner
2d993b4acc Replace filter() with list-comprehension
Replace filter() with list-comprehension when a list is expected. On
Python 3, filter() returns an iterator, not a list.

tox.ini: add openstack admin volume tests to Python 3.4.

Partial-Implements: blueprint porting-python3
Change-Id: Id99124bf0ef5549c596d94f5d10ab5f88a4e200a
2015-10-13 10:39:58 +02:00
Frode Nordahl
4994df59ce Fix unhandled exceptions from cinder in quota code
Enclose calls to Cinder in try except blocks.

Change-Id: Id8559f4936e8ed55078ddc839f2e9bc4ff4152fe
Closes-Bug: 1491309
2015-09-04 10:27:35 -05: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
David Lyle
6bfeee5baf Adding policy check in quota call
The default policy for server_list API in nova has changed. This
exposed a problem in the way Horizon was calling server_list when
reading quota values. The call was always made with
all_tenants=True, which is only something admin should be able to
do. Instead of ignoring the privilege problem in the API as in the
past, there is a pre-emptive policy check that makes the call fail.

The fix in Horizon is to only pass in all_tenants=True when the
user has the appropriate privilege level. nova_policy.json has been
updated with the appropriate default and the permission check has
been added.

Removing passing in all_tenants=True at all was contemplated, but
when setting quota values on projects in the identity dashboard,
the administrator level user needs to read quota values from a
project that they are not currently scoped to.

This fixes the error on the network topology screen that was the
motivation for the original bug report.

Closes-Bug: #1468551
Change-Id: I4255c57f81a13cac121596c99eea4ac629ed9ca7
2015-06-25 22:04:50 +00:00
Bradley Jones
286245b423 Refactor quota limit summary template
Refactor the quota limit summary template to allow easier customisation.
Also change it so that it removes the 'of' when there is no quota limits in
place so that it just reads Used 'x' (No Limit).

Added tests for checking usage['charts'] is in the context and that (No Limit)
is present when there is an infinite quota on the page.

Change-Id: Iba62ca89e53f0d6b9c583e4cc450e853c18ba107
Closes-bug: 1439717
2015-05-26 11:39:52 +01:00
tinytmy
58cbdb55ec Add help text for vcpu hours
In overview page, disk hours and ram hours has help text.
Also add help text for vcpu hours.

Change-Id: Ic44cf8753a0deebc30f7087e2e54bab6dfde5284
Closes-bug:#1417856
2015-02-14 13:10:06 +08:00
Sam Betts
168aa7e162 Document and improve PageTitleMixin readability
This is a follow up patch to https://review.openstack.org/#/c/142802
that adds documentation and also improves code readability in the
PageTitleMixin.

Change-Id: Iac7666252b5ceb9611e0688ef90173edf90475d9
Closes-Bug: 1420744
2015-02-11 16:16:20 +00:00
Sam Betts
1934a7eaa8 Reduced code duplication in creating page headers
The same line of code to add a page title to a template was repeated in
many templates, this patch moves that line into the base.html, and also
tries to standardize the way page titles are defined in the python.

Change-Id: I11367d3007ebae727ba45446076a31307d477995
Closes-Bug: 1399840
2015-02-11 10:45:23 +00:00
lin-hua-cheng
0cde6aa055 Move to hacking 0.10
Release notes:
http://git.openstack.org/cgit/openstack-dev/hacking/tag/?id=0.10.0

Per the release notes, H307, H803 and H904 has been removed.

Fix code issues with H238 and W292.

Change-Id: I747ebb64db5825bc70f1ae19c1c1f5ca2089c06d
2015-02-04 20:27:07 -08:00
tinytmy
99ec0e70e7 Add ram-hours in overview page
In the admin and project overview page, there has cpu-hours,
disk-hours, but has no ram-hours. This patch add ram-hours for
overview page.

Change-Id: I4eaf7cd7639de570058bdb793a95045a0be5d224
Closes-bug:#1415775
2015-02-02 15:06:42 +08:00
tintmy
e31269f5e9 Change mbformat to mb_float_format
In the some page use mbformat to filter RAM,(Usage Summary,
instances details,database,image detail, test file), We need
change to mb_float_format.

Change-Id: Ib2d98d17949ba1b453977cb666b2e10cdf07d90b
Closes-bug:#1319230
2015-01-20 08:32:56 +08:00
Akihiro Motoki
3b24bca074 Split large methods into submethods to reduce max-complexity
By this refactoring max-complexity of PEP8 is reduced from 33 to 19.

Closes-Bug: #1399523
Change-Id: I7e9e5cefd3e72e322d8b327f495ce7fc863c3678
2014-12-05 13:30:41 +09: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
Sam Betts
e98f2429fa Remove duplicated headings from horizon tables
Many panels in horizon only contain a single table, in these cases the
tables often have the same name as the panel, leading to duplicated
headings, e.g. Instances (panel heading) then Instances (table
heading). This patch adds an attribute the table to hide or show the
title, since the majority of panels have this duplication this flag
is set to hide the heading by default allowing a developer to re-enable
it for specific cases.

Tabbed panels also often lead to duplicated titles between the panel
heading and the tabs themselves, that is not fixed, however how this
patch reduces the duplication in the case of Volumes (panel name),
Volumes (tab name) and Volumes (table name), by hiding the table
heading.

Change-Id: I65efa53cc881417288e5c5b29bfa7d539e97c7dd
Closes-Bug: 1379044
2014-11-13 15:31:08 +00:00
Bradley Jones
746af6eeb0 Create Subnet button should respect quotas
The create subnet button (visible for each network in the networks list and on
the detail page when looking at an individual network) should be disabled if
the quota for subnets is at capacity.

Tests have been added to check that when the quota is exceeded the buttons are
disabled.

Change-Id: I7bba89c2d89a39220900480f0091bdc6215505fe
Closes-bug: 1369779
2014-10-29 11:35:11 +00:00
Cindy Lu
13f56fc1bc Clarify meaning of "Disk GB Hours" column
Admin > Overview Usage table has a column called "Disk GB Hours".
The meaning of this column is unclear.

Co-Authored-By: Thiago Paiva <thiagop@lsd.ufcg.edu.br>

Change-Id: I17e4a3ce60c66804e98a18c33261881ea10964b8
Closes-Bug: #1267362
2014-10-28 19:03:56 -07:00
Sam Betts
193d40a414 Pass correct project ID to get tenant_usages
The current implementation of tenant_quota_usages did not allow for
queries regarding projects that were not the currently active project,
this meant that when an admin went to edit or create a project it tried
to verify the usages against the wrong project. This patch adds the
code for passing a project id to the tenant_quota_usages function so
that the usages can be fetched for a specific project, as well as
removes the need for usage validation on creation of a new project.

Change-Id: I3ec84d14c8be7e3aae066119e963c4093f8aa345
Closes-Bug: 1380701
2014-10-17 15:33:28 +01:00
Jenkins
27c56ba541 Merge "Fix inconsistent behaviour exceeding quota limit" 2014-10-10 12:12:57 +00:00
Bradley Jones
42d73e85a6 Fix inconsistent behaviour exceeding quota limit
Added quota checks for security groups, networks and routers. If quotas are
exceeded then buttons to create are disabled and feedback is given to the
user.

Appropriate tests are also in place

Change-Id: Ie49db5397d87a0c9a583b64e5de34460144b5956
Closes-bug: 1278449
2014-10-06 13:10:14 +01:00
Matthias Runge
b5b09140b1 Change column uptime
Renamed misleading column uptime

Change-Id: Id72c10a7166943fcfef68c338a1412897ad9cc4b
Closes-Bug: #1156563
2014-10-01 14:00:31 +02:00
Justin Pomeroy
b388aaacb3 Persist usage start and end dates in the session
This patch adds the usage start and end dates to the user's session
so they are saved while navigating between pages.

Closes-Bug: #1373651
Change-Id: I3046b5533eb96f85fb2f90e63b3ff84360ad14c4
2014-09-25 15:16:28 -05:00
Jenkins
5cc1d2e7b7 Merge "Remove NotImplementedErrors from "virtual" methods" 2014-09-15 10:17:56 +00:00