Commit Graph

64 Commits

Author SHA1 Message Date
okozachenko aa21f4baa3 fix: ignore errors when flavors are deleted
The code used to list flavors when in the admin
or project side was not consistent and raised
alerts if viewing in the admin side but not in the
project side.

This patch moves their behaviour to be consistent
and refactors the code to use the same code-base.

Closes-Bug: #2042362
Change-Id: I37cc02102285b1e83ec1343b710a57fb5ac4ba15
2023-11-02 01:27:40 +11:00
Vadym Markov 4a2a1db145 Show image names at Admin-Instances dashboard
Admin-Compute-Instances dashboard shows "-" as image name for every
instance. Despite, Project-Compute-Instances dashboard displays image
name correctly. Admin dashboard just lacks code to resolve image name

Also, reverted commit deb55b8 which functionality is not needed anymore

Closes-Bug: #1932341
Change-Id: Ieb19e66dc51165d9935424b2e9ab5cdae757b07f
2021-08-11 18:12:09 +03: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
Stephen Finucane 2b3ab46440 Remove errant references to mox
There is still a single user of mox but all other references to this can
be removed. Do just that.

Change-Id: I611573a41c47e99e41a54bf53cea55322a493de1
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2020-01-30 10:35:50 +00: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
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
Ferenc Cserepkei 4676694179 Add "prev" link to instance page list pagination
Currently there is no link to previous page at paginated instances
table. This patch resolves that issue by re-using the pagination
code for flavors.

It also supports Ying Zuo's scenario:
After I set only 1 item per page and deleted the instance on the first page,
the expected behavior is showing the next instance in the table after one is
deleted.

xxxIndexView uses PagedTableMixin's _get_marker() from now instead of GET()-
ing the markers

Closes-Bug: #1274427
Co-Authored-By: Dmitry Ratushnyy <dratushn@cisco.com>
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: Id8eaae6bf1b5d6f42291291655e14b8715c08bc8
Signed-off-by: Ferenc Cserepkei <ferenc.cserepkei@ericsson.com>
2018-12-28 20:46:11 +09:00
BubaVV deb55b8411 Call Glance list with certain image ids
This patch uses glance list filtering, which allow to query images
for the list of required ids. See [1] for details.

Patch rebased to master. Added test for proposed Glance API request

[1] https://developer.openstack.org/api-ref/image/v2/#show-images

Related-Bug: #1508554
Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Co-Authored-By: Vadym Markov <markov.vadim@gmail.com>
Change-Id: Iac485c1b448011fec97ba5bfaa83851914b294d9
2018-11-06 12:30:57 +02:00
Akihiro Motoki f545272f12 Fix pep8 errors
Recent pep8 upgrade and corresponding pycodestyle update break
horizon pep8 job due to the new rules.

This commit fixes the following new errors:
- E226 missing whitespace around arithmetic operator
- E241 multiple spaces after ','
- E731 do not assign a lambda expression, use a def

The following errors are added to the ignore list
as there are many errors:
- E402 module level import not at top of file
- W503 line break before binary operator

Change-Id: I3478b0684175d2604bbcc1d89cbfca298b97f1e1
2018-04-11 00:34:21 +09:00
Vladislav Kuzmin a5f5962849 Convert admin.instances tests into mock
Partially-Implements: blueprint mock-framework-in-unit-tests
Change-Id: Ibce26865a4fe2b872bbbc09629eb8f6458900290
2018-03-18 18:12:14 +09:00
Akihiro Motoki 56ae087995 Refactor futurist calls
After futurist calls were introduced, the code became difficult to
understand. For example, local variables are used something like global.
To keep the code easier to understand, the usage of local variables
should be more scoped.

This commit introduces a wrapper function for futurist.ThreadPoolExecutor
and converts inline functions into normal methods.
I believe it improves the code readability a lot.

Change-Id: Id5b7a06c50e397c8c27447322d7f64f2d65c06b6
2018-03-14 21:15:52 +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
Akihiro Motoki 45442821d0 Use nova os-services to retrieve host list
novaclient version 10 has dropped the support for novaclient.v2.hosts.
os-aggregates and migrateLive APIs expects host from os-services,
so this commit retrieves host list from os-services API.

Change-Id: I5ec007ab1f244ca8caee1eb7b5d4262ac6c32171
Closes-Bug: #1745502
2018-02-01 12:19:56 +00:00
Feilong Wang a42f58de50 Allow to skip API calls to Neutron in instance tables
Now instance panel is sending API calls to Neutron to get the addresses
info about network. It take some time until Nova network info cache is
synced when IP address operation like floating IP association is made
in Neutron. The API calls to Neutron exist from this reason.

However, it retrieves a full list of port, so it can potentially leads
to performance issues in large deployments. This commit adds a setting
flag to control whether API calls to Neutron is used or skipped in
the project instance table.

This commits drops a call of servers_update_addresses() in the admin
instance table. In the admin instance table there is no need to retrieve
IP addresses from neutron because the main purpose of the admin panel is
to see all instances and IP addresses in nova network info cache will be
synced soon.

Closes-Bug: #1722417
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: Ie16784eb6352f70ab644dc8b6ea03fc6a881d3f9
2017-12-11 23:19:01 +09:00
Akihiro Motoki 44251a7abb Fix admin/project instance UT
The expected error count was wrongly changed in
commit df194c8b4c.

The expected error count was changed from 1 to 2 in the commit
but one new error message was caused by a wrong test code.
api.glance.image_list_detailed should return a tuple of
(images, has_more, has_prev) but the mocked method only returns
a list of images and this causes another error.

Change-Id: Ic1083014f9572bfd20adc60e7ec3eeeac387e9d5
2017-11-24 23:32:31 +00:00
Ivan Kolodyazhny 3a99499ba0 Get all needed instances for volumes attachments at Admin->Volumes
Nova server_list() wrapper needs to receive an explicit `all_tenants`
boolean flag in order to request instances for _all_ tenants -
otherwise while rendering Admin->Volumes table Django will request
missing instances (to get their names for volume attachments) one by
one, thus significantly increasing response time.

This patch adds check if all_tenants in search_opts and add it to
the search else uses tenant_id in the search_opts.

Co-Authored-By: Dmitry Sutyagin <dsutyagin@mirantis.com>
Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Change-Id: I4761d7da15036b69619649871aef91e1799ee385
Closes-Bug: #1508568
2017-07-13 20:35:21 +03:00
zhangdebo 9d9a2f6c1b Check the target host before live migrating a instance
In the live migrate form, the selections "Automatically schedule
new host." and "No other hosts available" both use an empty value,
and this input is not required, that causes I can submit the
form even there are no other hosts available.

I think the value of selection "Automatically schedule new host."
should not be empty, and this input should be required.

Change-Id: I6a88ffa23087a0d845cf8a71a6359f3f4fbddbe0
Closes-Bug: #1684604
2017-04-26 00:58:39 -07: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
Mateusz Kowalski df194c8b4c Make API calls in Instances view parallel
In order to increase rendering speed, make
api.nova.server_list, api.network.servers_update_addresses,
api.nova.flavor_list and api.glance.image_list_detailed
parallel. For admin panel also api.keystone.tenant_list
is parallelized.

Closes-bug: #1655307

Change-Id: I83150d3963f1233edc9efbcdac299520dedbed3c
2017-02-14 14:11:03 +01:00
liaozd 296d48074d clean unused imports
Change-Id: I9db0bbe3d24fb04e647fcfca1a3a746df006f85c
2017-02-12 17:58:11 +08:00
Rob Cresswell 560f23a1c9 Add default common template to python table views
Many of the Python table views are using identical (or nearly identical)
table templates. This patch adds a common template and makes it the
default for a DataTableView, which allows us to remove many similar
templates and redundant lines of code.

Change-Id: I1e4e15e695ee1f21f4d44f141a854e30f1e567a1
Closes-Bug: 1653986
2017-01-05 08:59:35 +00:00
Eddie Ramirez 460a53f96d Server-side filtering for Instances (Project/Admin)
New Filters:
- UUID
- Flavor Name
- Image Name
- Availability Zone
- Key Name
- IPv4 Address
- IPv6
- vCPUs
- Changes-since.

Affected views: Project->Instances and Admin->Instances

Implements blueprint: server-side-filtering
Change-Id: I3b07674fc1083607cae5d1db5a691827bde46d7c
2016-09-15 22:33:35 +00:00
Luis Daniel Castellanos e15b61f58a Update admin filter first setting to a dict
Previously the ADMIN_FILTER_DATA_FIRST setting was a True/False
setting that was taking over all the admin views leaving
operators without the opportunity to set this setting to views
individually.

This patch changes the setting to a dict where it can be specified
which panels/views will implement this setting individually.

Implements blueprint: admin-views-filter-first

Change-Id: I50deab878f68c1cc519aa9b47feaa2c58bb8eacc
2016-09-14 15:52:20 -05:00
Luis Daniel Castellanos 488efd784f Implement admin_filter_first in Instances and Images Admin Views
Implementing ADMIN_FILTER_DATA_FIRST setting will allow operators to
require admin users provide a search criteria first before loading
data into the Admin views.
Starting with Instances and Images admin views since they already have
server side filtering options.

Implements blueprint: admin-views-filter-first

Change-Id: I846690854fd443bb98692674bf9fe6733dd04263
2016-06-23 10:18:11 -05:00
eric cc42e94c0c Live migration auto schedule new host
This change adds the option of using the nova scheduler
to place a vm during live migration

Change-Id: I136de833ab1b9e38c8077ad1b3ff156b761055d5
Closes-bug: #1586527
2016-06-10 10:10:37 +00:00
David Lyle 037d1c0927 removing httplib2 test dependency
Once upon a time, the python-*client libraries were primarily built to
use httplib2. They have subsequently shift to using requests and thus
urllib3. The horizon test helpers code was maintaining a reference to
httplib2 as it intercepted errant library calls that were not mocked.

httplib2 is not actively maintained and OpenStack is moving to remove it
as a dependency. See
http://lists.openstack.org/pipermail/openstack-dev/2016-March/089225.html
for more details.

This patch removed the httplib2 dependency. Upon removing the
dependency it exposed a missed update from httplib2 to urllib3. A
function that was intended to catch unmocked calls was only listening
for httplib2 connections. This patch updates that failsafe to work with
urllib3. Upon doing so, it pointed out many, many missing mocks and in
turn, many broken tests that appeared to work because of API call
failures. This patch adds the missing mocks and fixes the broken tests.

The new failsafe prints the stack trace when an outside connection is
attempted. Additionally, to fix the fact that a missed mock used to
allow tests to potentially pass, as documented by bug 1517704, a test
failure is now forced on tests where a missing mock is detected.

Closes-Bug: #1517704
Implements blueprint: remove-httplib2-dep
Change-Id: Iaabdf03966c14c82e0c58a3b1ab1a6755c05adcb
2016-05-02 13:19:08 -06:00
Itxaka b59ebcfaac Refresh the networks on ajax update
If using neutron, the ajax will query the last status from
nova which could be out of date, so any floating ips
added wont show up unless you refresh the whole page.

Change-Id: Iad1684d1a2fb677ee8850a98c8219794698722e3
Closes-Bug: 1505935
2016-01-26 10:26:03 +01:00
Cedric Brandily 9bee1c103c Enable compute shelve/unshelve commands
This change enables shelve/unshelve commands in user/admin views.

Closes-Bug: #1285389
Implements: blueprint horizon-shelving-command
Change-Id: I15e1e5d2fdb3d246a7f3e7e676c4b364694410fb
2015-09-11 12:08:42 +00:00
Masco Kaliyamoorthy 4e8549ee9a Replace SortedDict with OrderedDict
From django V1.9 django.utils.datastructures.SortedDict
will be removed and it is deprecated in V1.7.

The similar functionality is added in collections.OrderedDict
from python 2.7.

Horizon code also should avoid the SortedDict class and
start using the OrderedDict class.

This patch replacing the SortedDict with OrderedDict.

Change-Id: I8dfcf7c29fc49b6215451f160cf7a951bf11b5ad
Closes-Bug: #1492270
2015-09-04 18:39:15 +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
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
Jenkins 20be51e43a Merge "Uniquify horizon messages returned in a single response" 2014-09-19 09:15:04 +00:00
Vlad Okhrimenko a212ef399f Uniquify horizon messages returned in a single response
A network operation can fail because of different
reasons - yet in many places just one error message
is provided. Combined with too broad exception clause,
and incorrect assumptions on the reasons of failure
(e.g. Neutron service being unavailable causes all
other sorts of errors like inability to Allocate IP
or Associate it) this leads to multiple errors when just one
would suffice. The fix aims to provide sensible error
messages in case the network service is down. This includes
returning only unique messages in a single response.

Partial-Bug: #1301374
Change-Id: Id6c620ca51f7703f35c0c172e39fdf237fa42278
Co-Authored-By: Timur Sufiev <tsufiev@mirantis.com>
2014-09-17 13:45:07 +00:00
Jenkins fd5c313f01 Merge "Fix host listing in live migration" 2014-09-12 06:30:51 +00:00
Akihiro Motoki 198c7dcd5f Show floating IPs from other projects of admin instance table
Change-Id: I36e1c7a3808994d1481463ed6b595506e579ae28
Closes-Bug: #1319669
2014-09-10 14:55:46 +09:00
Dirk Mueller 89dc7de2e8 Fix host listing in live migration
The live migration selector needs to offer a list
of hosts, not a list of hypervisors.

Change-Id: I73c1175a5f87b0f91e36083f05467c26feca5d51
Closes-Bug: #1335999
2014-09-10 11:17:46 +08:00
Christian Berendt 233b4345c4 Display flavor details in instance listing in a popover
This patch moves the flavor details in the instance listing into
a popover to reduce the amount of displayed details in the listing.

Change-Id: Ibd8cd228bae41e0f2870a8a14b6ce21338d61a8f
Closes-Bug: #1314177
2014-07-16 11:33:48 +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
Zhenguo Niu 06e1132734 Live Migration should not contain current host in the new host list
Change-Id: I30af5aa4943284edc16dfbde1b1354951698c77c
Closes-Bug: #1267733
2014-03-05 13:41:17 +08:00
Zhenguo Niu 417372a802 Change redirect of details on admin instance table
Change-Id: I3d56b9f4b76a5b02a4d3a7dd66db3a0a0ed5e84c
Closes-Bug: #1282361
2014-02-21 10:55:50 +08:00
Jenkins 16a22952c5 Merge "Get instance networking information from Neutron" 2014-02-17 16:33:55 +00:00
Assaf Muller 715d6b8228 Get instance networking information from Neutron
project/instances, admin/instances and the instance details page
all get networking information from Nova. However, with Neutron
enabled, floating IP associations are done direcly with Neutron,
meaning that Nova's DB will fall out of sync and thus the GUI
won't reflect successful floating IP associations until Nova
polls Neutron again and updates its DB. The polling can take
up to several minutes to complete for consecutive floating IP
operations.

The solution is to update instances' networking information from
Neutron immediately after the call to list Nova instances.

Closes-Bug: #1265032
Change-Id: I0382fa9a4a9fff21e7b4d05cd3b76783f826735f
2014-01-26 11:46:18 +02:00
Jenkins 7b13386435 Merge "Inconsistent filesizeformat return value" 2014-01-11 07:14:11 +00:00
Juan Manuel Olle 0cf6a10d43 Inconsistent filesizeformat return value
Add units for values in the range 0 < x < 1024

Change-Id: I357c0a3404895959419cd21b73d09185e938212e
Closes-Bug: #1261279
2014-01-09 10:29:12 -03: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
liyingjun cf75d04a3d Live migration support
Currently Horizon only provides support for 'nova migrate', which
involves a reboot, and is also confusing for users who do not know there
are 2 ways of migrating an instance. We should provide another option in
order to support live migration, as enabled by `nova live-migration`.

Implements blueprint live-migration-support

Change-Id: Id83ba9e19461a7217f521a09bde3109428ecbf11
2013-11-22 16:08:49 +08:00
simon afaa72185c PEP8 E126 has been resolved
Change-Id: Ic5d3b96b6061b7a34e7620d8d09418bd6976fbb1
Partial-Bug: #1085346
2013-09-17 20:48:09 +09:00
simon ec727ac394 PEP8 E121 has been resolved
Change-Id: I6ad2704100447c5a3be12c2ebeec824726e3bd0b
Partial-Bug: #1085346
2013-09-05 14:38:58 +08: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