Commit Graph

47 Commits

Author SHA1 Message Date
Thomas Goirand 8770753fcc Specify transform=repr in assertQuerysetEqual()
Previously "repr" was automatically applied to "qs" argument of
assertQuerysetEqual() and most horizon unittest behaviors assume it.
It was deprecated in Django 3.2 and removed in Django 4.1. We need to
specify transform=repr explicitly to use the existing behavior.

[1] https://docs.djangoproject.com/en/3.2/topics/testing/tools/#django.test.TransactionTestCase.assertQuerysetEqual

Closes-Bug: #2038474
Change-Id: Ie7c7e9a1efc492889639e25509c8e614268c1d26
2023-10-23 14:24:49 +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
Ivan Kolodyazhny e976461d85 Remove six usage from horizon 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: I0b567382edf4d68674a7b8d0b02333fb57293958
2020-01-15 12:36:11 +02:00
Stephen Finucane f654c893ec django22: django.test.client.encode_multipart no longer accepts None
As seen here [1]. With this change, all test are passing with Django
2.2.

[1] https://github.com/django/django/commit/6fe9c45b725

Change-Id: Idef0bd9dff4b27d22cfb756fc248c5c6bd24e097
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-09-11 07:25:03 +09:00
Akihiro Motoki 53486be43f Define default settings explicitly (openstack_dashboard 2/5)
This commit mainly covers settings
in openstack_dashboard/dashboards/admin/.

Part of blueprint ini-based-configuration
Change-Id: Ifb3e9401a926ba9e035e1b498a4a4493c1b594f5
2019-04-24 02:32:47 +09:00
Akihiro Motoki 22deb550c0 Convert admin.flavors tests into mock
blueprint mock-framework-in-unit-tests

Change-Id: Ia62d4f7efa3334d5e422bea1c5638bcd22d92fe7
2018-05-14 09:29:38 +09:00
Zuul 70e897729d Merge "Drop Flavor Edit completely" 2018-04-30 08:41:54 +00:00
Akihiro Motoki 70b9d258bd Drop Flavor Edit completely
After dropping the flavor edit feature was dropped in Rocky-1,
we still allow to edit flavor in the "Modify Access" form.
This commit drops the remaining flavor edit forms.

Duplicated API calls (flavor_get and flavor_access_list)
in the UpdateFlavorAccess form are refactored into one API
call per request.

Change-Id: I009fe285d2263fd9b9f07ed1c3f4c96df261b535
Closes-Bug: #1766053
2018-04-24 01:18:55 +09: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
Ahmed Zaid 154ddab1d4 Drop flavor name validation in horizon side.
This patch drop name validation in horizon and
let nova check if the is name is valid or not.
Instead of using pattern in the flavors form,
pattern will be checked in the nova. Also I
added limation for the name size with tests to
check the max size since the min size has it's unit
test.

Closes-Bug: 1738328
Change-Id: Ib4f6f9b87560df43819d992254603e55ea8ff6a3
2017-12-21 01:13:53 +09:00
Akihiro Motoki af3b7e4134 flake8-import-order: Ensure to place project imports last
To ensure project imports are placed after third party import,
we need to specify application-import-names.
Previously flake8-import-check checks only standard imports or not.

Change-Id: I9beb2105f686dc7d9aebfce8e21c5e182698e2fe
2017-09-20 01:19:38 +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
liyingjun 30a75642c4 Pagination for flavor - prev link
More link for flavors table is already supported, this patch adds
support to prev link for flavors table.

Implement blueprint: pagination-for-flavor

Change-Id: I3111e929c59077a0e52bf8f84a512ee18eee5f12
2015-12-25 00:14:03 +08:00
liyingjun 90d0f4e830 Pagination for flavor - more link
Nova and novaclient already support pagination for flavor, it would be
nice to have this in horizon. Adding pagination for flavors table.

Implement blueprint: pagination-for-flavor

Change-Id: Icff51302158263f2101a78519f509415514cd880
2015-12-16 19:43:14 +08:00
Itxaka 90b3276e60 Add rxtx factor to flavors.
Adds rxtx factor to create and update flavor.
Adds rxtx factor column to flavor table.
Update tests.

Change-Id: I0b6c0a8faff5ae32339c41ec95258b5ac3da5148
Closes-Bug: 1481425
2016-02-12 19:20:42 +01:00
kelfen 3f3da92350 Swap and ephemeral fields should be optional
Such as in Nova CLI, during flavor create/update the
swap and ephemeral fields should be optional.
If Nova receive an empty value in swap or ephemeral
field sets it to "0"

Change-Id: I896e4fa842a1cf6213f564d8890931a0818b657a
Closes-Bug: #1480343
2015-09-16 14:57:55 +00:00
Szymon Wroblewski 3c2ce866df Angularize metadata update modals
Update table action to use new angular modal dialog.
Remove "Metadata Update" views.

Implemenents: blueprint angularize-metadata-update-modals
Change-Id: I7b3d2eab8c0830dc44a45901981eb0e71009c038
2015-08-25 13:29:03 +00: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
Radomir Dopieralski 8697a93d18 Use novaclient v2 instead v1_1
Because v1_1 is deprecated.

Closes-bug: #1435201
Change-Id: I12a8c961d90bc79cc44b7c7f4e1a4bdbfa55f6a2
2015-03-23 09:45:42 +01:00
Akihiro Motoki 393642fd02 Fix E128 errors in openstack_dashboard/dashboards/admin/
E128 continuation line under-indented for visual indent

Partial-Bug: #1375929
Change-Id: I7a258d624f35b602da07c9b8604fb26c63287824
2014-10-15 13:50:07 +09: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
Bartosz Fic df25035fd1 Flavors metadata cleanup
Fix review comments on https://review.openstack.org/#/c/112874/
in admin/flavors/views.py regarding exception handling. Also
adding unit test to test negative scenario after changes.

Closes-Bug: 1369678
Co-Authored-By: Bartosz Fic <bartosz.fic@intel.com>
Co-Authored-By: Michal Dulko <michal.dulko@intel.com>
Change-Id: I5ea1216a22560cc0e8a5ba57be548b54674db689
2014-09-18 12:15:26 +02:00
Michal Dulko d5fea888a8 Enable flavors metadata update
Nova currently expose an api to let the users update
the flavors metadata so horizon should expose
this functionality. At the same time Glance is exposing
a metadata dictionary in Juno, where users can register
the key/value pairs that describe their cloud deployment.
This patch uses the glance metadata api to expose the available
metadata and the nova api to update the aggregates metadata.

Implements: blueprint glaance-metadata-flavors

Co-Authored-By: Santiago Baldassin <santiago.b.baldassin@intel.com>
Co-Authored-By: Pawel Skowron <pawel.skowron@intel.com>
Co-Authored-By: Pawel Koniszewski <pawel.koniszewski@intel.com>
Co-Authored-By: Michal Dulko <michal.dulko@intel.com>

DocImpact:
    New UI. FLAVOR_EXTRA_KEYS setting deprecated.

Change-Id: Ica9d3d06314a4d5afa77f644bd1f8900a1c328f7
2014-09-15 16:48:06 +02:00
Radomir Dopieralski 0eca7449cc Fix Flake8 style warnings in openstack_dashboard/
Warnings H904, H307 and H405 are new or considerably changed, and will
be fixed in a separate patch.

Closes-bug: #1349820
Partial-bug: #1347472

Change-Id: I4fd28990dacf16f03a4eaa6074ef59c37f1a2c14
2014-07-30 14:13:24 +02:00
Nicolas Simonds a75df6f267 Add a column to show if Extra Specs are defined on a Flavor
UX improvement: Adds a column to the Flavors DataTable to show if
any Extra Specs have been defined for the flavor.  Also contains a
LinkAction to open the Extra Specs view for the flavor

BP: extra-specs-as-column
Change-Id: I044b86c366c6687f4b0e9870371ef63a2066083d
2014-05-21 13:12:56 -07:00
Jenkins 5bc73087b4 Merge "Don't copy the flavorid when updating flavors" 2014-02-07 09:31:36 +00:00
Nicolas Simonds 4100a1cbc2 Don't copy the flavorid when updating flavors
The Nova API makes the implicit assumption that flavorids are unique,
so if one creates two flavors with the same flavorid, subsequent
requests for flavor information can vary between "inaccurate" and
"wildly f*cking inaccurate"

From an end-user perspective, it makes it look like data such as
flavor access settings get lost between edits (because the API pulls
the access list from the wrong flavor)

Let the API assign a new flavorid on changes.  The comments around
the handler code imply that is the desired behaviour, anyhow.

Change-Id: I5403202396a7b136b0ae8637d6aae1cf32550747
Closes-Bug: 1276371
2014-02-05 09:35:19 -08:00
Leandro I. Costantino 7fb3afaf3c Restrict flavor fields input on creation/update.
If flavor properties are invalid, an update message error
is shown, but the flavor get deleted.
The reason is that update flavor is not yet supported so horizon
will delete the flavor and create a new one, failing in the last case.

Fields ram and vcpus need to be >= 1 and eph_gb, swap_mb and disk_gb
>= 0 to create a flavor.

Change-Id: I20d178bad6e4e50c0963acdec72ebedb9bbaba17
Closes-Bug: #1269638
2014-01-17 08:24:40 -05: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
Paul Belanger 74117eb8b6 Gate on H102 Apache 2.0 license header not found for pep8
Now all files are properly licensed per OpenStack Hacking.

Change-Id: I223d983018568357197b0d9cf5dde12c135c53c9
Signed-off-by: Paul Belanger <paul.belanger@polybeacon.com>
2013-11-19 13:55:04 -05:00
Yangyang Zheng 9f95409249 Define flavor for each project
Change CreateFlavor/EditFlavor forms to CreateFlavor/UpdateFlavor
workflows. Provide access flavor management in each project. Add
the filtering function in Flavors page.

Implements blueprint define-flavor-for-project

Change-Id: I723bbf250a46af8de58de06a907f6efc737778db
2013-09-01 22:14:23 +10: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
Nikita Konovalov 2c2e21d512 Flavor ID added to Flavor creation form
Flavor ID supported values are:
* integer
* uuid4
* auto

Using 'auto' generates a random uuid4.

Clean method from Edit Form removed as unnecessary.

Flavor tests updated.

Fixes: bug #1189877

Change-Id: I222836d7a84b66891d5380f323bf123122044d30
2013-07-25 18:43:14 +04:00
Alex Gaynor 56ae8fdfc5 Enable pep8 F841 checking.
This check looks to see whether a local variable
is unused. Also fixed all violators of said check.

Change-Id: I7c186df41b5601078ffc54588aace8136c6576bd
2013-07-22 01:09:52 -07: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
Lin Hua Cheng a1012242d7 Add flavor name regex validation to match nova.
Fixes bug 1148372

Change-Id: Ia1f4d974ddac6cd22c0b8979e98b2ea8f31deb21
2013-03-22 16:57:45 -07:00
Victoria Martínez de la Cruz 0982039209 Prevents flavors to be deleted when reusing a name
Adds an extra check to the EditFlavor form
in order to avoid losing the flavor if an
existing name is setted as the new name.

This control is needed because the current
edit implementation is based in a
delete-create action.

Change-Id: I4251c64fa4719831a1ed949bf95349a350dd303d
Fixes: bug #1133254
2013-03-06 20:13:40 -03:00
Jenkins 9a7b49e086 Merge "Removes unused imports" 2012-12-11 22:04:21 +00:00
Malini Bhandaru 95a034ae62 Fixes bug 1086290
https://bugs.launchpad.net/horizon/+bug/1086290,
edit-flavor broken when flavor has extra specs.
Includes unittest for the same, and modified mock data to
to include extra-specs
Change-Id: I286d97568daff26bbd03418b2ea0b808caceadba
2012-12-10 19:11:05 -05:00
Zhongyue Luo a3d136e365 Removes unused imports
Removed unused imports founded by:

find . -type f -name "*py" -exec pylint -r n {} \; | grep -E "Unused imp|^\*"

Change-Id: I84f81ed833f6f792c5beb41a4d6b26cbb3236b2b
2012-12-10 11:27:51 +08:00
Christian Berendt 06e1d59a5c show swap disk in listing and forms in flavors syspanel
At the moment the swap disk entry of flavors is not listed in
the syspanel listing of flavors and it's not possible to create
a new flavor or edit an existing flavor with the swap size

Change-Id: I92195671024bb361fa5825cbdcea515850ddee31
2012-12-05 15:43:56 +01:00
Alexey Izbyshev 155e3ae7c3 Fix handling of UUID-typed flavor ids
Change the type of flavor_id hidden field in EditFlavor form
from IntegerField to CharField since flavor id is a string
representation of UUID now. Additionally change the type of
similar hidden fields in CreateExtraSpec and EditExtraSpec forms.

Remove flavor id generation from form handling code. Id generation
should be done only in corresponding OpenStack components (nova, etc.).
Since nova supports flavor id autogeneration and 'flavorid' parameter
of FlavorManager.create() in novaclient is optional, remove 'flavorid'
parameter from api.nova.flavor_create().

Change flavor ids in test data from strings containing integers
to UUID-like strings to make them correspond to real data.

Update flavor tests to make them compatible with new
api.nova.flavor_create() signature.

Remove conversions of flavor id to int from all tests. In particular,
update test_index_flavor_get_exception() to make it generate unique
UUID flavor ids instead of integers.

Fixes bug #1076761

Change-Id: Iaa308578981f0379ff61a9dd42620eaf0ab1d605
2012-11-30 01:28:57 +04:00
Matthias Runge dcda694026 Return a friendly error at flavor creation
When trying to create a flavor with an Id/Name that is already in use, the
operation fails and no error message is being displayed

Change-Id: I92db8b52bc4e63e5e5ce4d90169944e484baeddd
Fixes: bug #1079155
2012-11-21 08:26:23 +01:00
Malini Bhandaru 82c19aee05 Flavor Extra Specs support.
Special thanks:

  * Preserves extra specs on flavor edit (Tihomir Trifonov)
  * Displays flavor name on extra specs pages (Vinay Bannai)
  * Extras specs table close (Don Dugger & Gabriel).
  * Final cleanup (Gabriel Hurley)

Change-Id: I6acb1176e5c0ca6987abc758fc45335870c55d57
2012-11-06 17:06:30 -05:00
Gabriel Hurley ef4e9314eb Use UUIDs for flavor create/edit.
Now that Nova accepts strings as flavor IDs we can just use UUIDs
on our end and get rid of the horrors of trying to guess the next
integer ID. This fixes all the instability in flavor editing.

Fixes bug 1057799.

Change-Id: I55eb1d7408655fd27e81cc1196f15ceb3659a7b4
2012-10-24 14:03:17 -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