Commit Graph

48 Commits

Author SHA1 Message Date
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 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
Ivan Kolodyazhny 14e779bbac Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I2de669d8e89b8daeb7ee5405ffab35af6307c40b
2020-03-26 19:45:37 +02:00
Adam Harwell 70629916fe Use quoting for CSV Writing
An attacker could create an instance with a malicious name beginning
with an equals sign (=) or at sign (‘@’).
These are both recognized in Excel as metacharacters for a formula. The
attacker can create an instance name that includes a payload that will
execute code such as:
=cmd|' /C calc'!A0
This payload opens the calculator program when the resulting CSV is
opened on a Windows machine with Microsoft Excel. An attacker could
easily substitute this payload with another that runs any arbitrary
shell commands.

Quote the CSV output so this is no longer a possibility.

Closes-Bug: #1842749
Change-Id: I937fa2a14bb483d87f057b3e8be219ecdc9363eb
2019-10-11 19:52:08 +00:00
Akihiro Motoki f9f01d292c Convert admin.overview tests into mock
blueprint mock-framework-in-unit-tests

Change-Id: Ic4fa8711bb8bc4eef4f721bf230e8262299176b7
2018-05-14 00:20:25 +00:00
Akihiro Motoki 58019a7411 Disable mox usage by default in test helper
- Add use_mox = True to tests which still depend on mox
- Remove use_mox = False from all tests converted into mock
- Update the warning messages
- Replace 'S'-release with 'Stein'

Part of blueprint mock-framework-in-unit-tests
Change-Id: I208185e97b2de346304a09643a9cb3f1425a7683
Signed-off-by: Akihiro Motoki <amotoki@gmail.com>
2018-04-20 03:34:51 +00: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
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
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 acd3f2a240 Drop novalclient security group and floating IP dependency
novaclient 8.0.0 dropped python bindings for security group and
floating IP. This commit drops security group and floating IP logics
from the nova API wrapper.

The following changes are made accordingly.

* Update unit tests to consume neutron test data
* Drop API unit tests for nova security group and floating IP

Partially implement blueprint drop-nova-network
Change-Id: I946c508d7a82162fc8434213e006513867b79350
2017-04-28 08:38:28 +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
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
LiuNanke f96797a006 Replace assertTrue(isinstance()) with assertIsInstance()
Some of tests use different method of assertTrue(isinstance(A, B)) or
assertEqual(type(A), B). The correct way is to use assertIsInstance(A,
B) provided by testtools.

Change-Id: Ib44771be349f359376e35d7673192bc62805b1c2
Closes-Bug: #1268480
2015-12-31 00:05:14 +08: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
tinytmy bd1641c482 unite the property of usage test
unite the property of usage test and fix local_gb
instead of disk_gb_hours

Change-Id: I049160f5a0665f03685c6c5a5f10fbb7b398d9c4
Closes-bug:#1416987
2015-02-12 10:55:58 +00: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 7b47906118 Fix E127 errors in openstack_dashboard/dashboards/admin/
E127 continuation line over-indented for visual indent

Partial-Bug: #1375931
Change-Id: I0c3a95633e267294fc3b5576be2fc3c374b4b5d8
2014-10-02 19:46:52 +09: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
Cindy Lu a6cd12f24d Add missing Disk unit to Overview Usage
Added unit to the Summary table and the csv report

Change-Id: I91a0bdd13384098cd2e306413bfc103c99bbc418
Closes-Bug: #1346389
2014-08-04 15:59:58 -07:00
Cindy Lu 657db22105 change spelling Ram to RAM for consistency
Change-Id: I0d53e674e83457fd7212a5d1da7ca2f31f75d448
Closes-Bug: #1347955
2014-07-23 16:37:21 -07:00
Maxime Vidori 099fd15656 Fix testing fails on specific platforms
Due to the use of dictionaries and sets, some tests fails especially in
the html rendering (attributes are stored in a dictionary), and in
admin/aggregates, where API calls are checked over a set and the use of
InAnyOrder function of mox is needed.

Co-Authored-By: florent <florent.flament-ext@cloudwatt.com>
Change-Id: I9f8482179b7f3c9175c98115770b5239cbd84cb9
Closes-Bug: #1293692
2014-06-03 14:52:21 +02: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
Thiago Paiva Brito 497f69aef3 Correct default usage filtering on overview page
On the overview page, the usage data showed by default was not filtered by
the dates shown on the date selectors. This can lead the user to wrong
conclusions about resource usage.

This patch corrects the default filtering dates to match the dates showed
by default on overview (first day in the month to current date).

Change-Id: I37a240d784ca0826821c125f06922d2c1d1e8659
Closes-Bug: #1294668
2014-04-14 11:44:22 -03:00
liyingjun 63f4e63e53 Handle summary information for deleted project
If we could not get the project name for the usage summary, show the
tenant_id with a 'deleted' identifier instead.

Closes-bug: #1183172

Change-Id: Ieb03a64dd6311bcdb026d8cdf63f08ec10480ea8
2014-01-14 01:34:35 +08:00
Radomir Dopieralski 028332da4a Remove #noqa from most common imports and add them to import_exceptions
We have a lot of import with #noqa that is there to ignore h302,
because it's traditional to import and use a name directly, instead
of a whole module. This hides other errors and gives people the
impression that it's actually fine to import non-modules, you just
have to slap #noqa on those lines.

I went through the code and identified about a dozen names that are
most commonly imported this way. I remove the #noqa tag from them,
and added them to the list in import_exceptions.

I also removed a few unused imports that were revealed in the process.

Change-Id: I27afb8e2b1d4759ec974ded9464d8f010312ee78
2014-01-07 12:26:35 +01:00
Cristian A Sanchez c86918f90c Adds Cinder client mock to tests
Test cases now have a mock for the method tenant_absolute_limits
in cinder client. The absence of this mock was causing real HTTP
requests from this client.

Change-Id: I8b9c4f5affc43e2649f3ebf08580bb3d3687e09b
Closes-Bug: #1259533
2013-12-09 20:41:37 -08:00
Romain Hardouin d43e49ae46 Handle the case no SimpleTenantUsage Nova extension
When the SimpleTenantUsage Nova extension is not enabled,
panels that include usages produce an error and
the usage table is useless.

Three panels use the SimpleTenantUsage extension:
- openstack_dashboard.dashboards.admin.overview
- openstack_dashboard.dashboards.admin.projects
- openstack_dashboard.dashboards.project.overview

This fix avoids errors and does not show the usage
table in such a case.

A context variable 'simple_tenant_usage_enabled' is now
available in templates rendered by usage.UsageView subclasses.

Unit tests now mock nova 'extension_supported' API.

Change-Id: Ib306846bf6c947572ba0e7c773125d03b3dbf68b
Closes-Bug: #1211470
2013-10-08 22:22:35 +02:00
Akihiro MOTOKI c44552fe66 Retrieve security group quotas from Neutron if enabled
Secuirty group quota information in Project overview charts,
Admin defaults panel, and Admin create/update project is
retrieved from Neutron secuirty group is enabled.

Neutron security group is enbled when Neutron is used Neutron
security group extension is supported by a backend plugin.

Also removes the logic to remove quotas of floating IP and fixed IP
when neutron is enabled in dashboards/admin/defaults/tabs.py.
quotas.get_default_quota_data() already handles it properly
and this logic is no longer required.

Closes-Bug: #1212600

Change-Id: I59f069931fad519ca4ec135b92df0040ec8fc230
2013-09-29 17:50:00 +09:00
Jenkins 8b8ab049bc Merge "Small "H302 check" cleanup" 2013-08-27 19:10:51 +00:00
Julie Pichon fde88906b3 Show Neutron floating IPs quotas on Overview
Display the correct limits and usage when Neutron is in use and the
quotas extension is enabled. If Neutron is enabled but the quotas
extensions is not supported, assume the floating IPs quota is
unlimited (a floating IP quota is expected to exist in other places,
e.g. Security and Access panel)

Because quotas may not be configured or enabled even if the extension
is available, add an 'enable_quotas' setting.

Partial-Bug: #1109140

Change-Id: Id6345f4700f0ff45be8ce8acb69cca0d4e05e14a
2013-08-26 16:39:27 +01:00
Tatiana Mazur b4fc9b4bc9 Small "H302 check" cleanup
This patch set removes some commented out stuff that
has been unintentially left in "H302 check" patch set.
It also replaces a couple more method imports with
module imports.

Fixes bug 1215892

Change-Id: I35fd880154a4ea6d6d8d3b3615103c271aa4a005
2013-08-23 18:07:08 +04: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
Victoria Martinez de la Cruz 142a6e97fe Query a period of time for usage summary
Allows the user to pick a range of time
to query services usage data.

Fallback mode: the user will have to input
dates by hand if JavaScript is disabled.

Change-Id: I4cf4d4fd56fd450743b9d624dc066d6ed74df881
Fixes: bug #1102448
2013-07-25 09:50:42 -03: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
Matthias Runge cea720e793 Sort imports alphabetically
This patch also re-organizes imports to import one per line.

Change-Id: Ia958e3a30a48d4308d08d51df243c1272425c316
Fixes: bug 1188529
Fixes: bug 1188537
2013-06-14 12:05:55 +02:00
Jenkins f5bf488c06 Merge "switching to use limits instead of quotas" 2013-06-07 09:38:07 +00:00
Eric Peterson d4b0ab4aa3 switching to use limits instead of quotas
Fixes bug 1178694

Change-Id: I6fad061faf84079492338016fd2bada9a2e434f3
2013-06-05 15:40:37 -06:00
Zhenguo Niu 65c48fc3e8 Adding pagination to the tenant views
Modifying the api.keystone.tenants_list() method by setting
limit/marker parameters to handle pagination.

Change-Id: Ice67a6112ed8b90095e9c9991bee3e715c22ec01
Fixes: bug #904003
2013-06-05 14:31:08 +08: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
Gabriel Hurley 68a55e3fe8 Enable using multiple API versions for Identity Service.
Introduces a mechanism for switching between API versions,
and implements it in a proof-of-concept fashion for the
Keystone v3 API. Converts the existing Users and Projects
API methods to use it.

This changed some method signatures, and therefore altered
a number of views and tests. However, all code related to
the version cahnges is contained in the api.keystone module.
This seems like a sane process going forwards.

Future TODOs are marked in the code, including auto-detection
of API versions and better endpoint URL construction.

Partially implements blueprint api-capability-detection

Change-Id: Ied04200fe6c257aac2241d36628965a3bb6658b9
2013-05-01 18:19:36 -07:00
Akihiro MOTOKI 12faaa5c30 Ensure to use api.<category>.<method>
In the current code both api.<method> and api.<category>.<method> are used.
Using api.<method> directly makes it difficult to identify which module
defined a method and forces developers to use unique method names among
projects. This commit removes api.<method> style method calls.

Change-Id: Iaefa1061f99b7865e02541df87c112a6b2868ec0
2013-01-22 20:37:12 +09:00
Brian Waldon 70ac5bd4a7 Add newline between rows of Admin usage.csv
For some reason, we must also specify precision for vcpu hours
in this change. Adding the newline caused the default behavior
to change.

Fix bug 1073677

Change-Id: Id9a90e787de50f775ed17b15f185273cebba64e8
2012-10-31 12:41:49 -07: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
Gabriel Hurley cb8e7c1f8f Splits OpenStack Dashboard bits from framework app code.
Moves everything OpenStack-specific (dashboards, apis, etc.)
into the openstack_dashboard project, achieving a much
cleaner separation between the project-specific code and
the generic Horizon framework code.

Change-Id: I7235b41d449b26c980668fc3eb4360b24508717b
2012-10-11 11:47:50 -07:00