Commit Graph

241 Commits

Author SHA1 Message Date
Heather Lemon c90c0b709c Fix instance table behavior after deleting an instance
After deleting a VM from the instances table,
all VMs above it in the table list disappear from the
UI until the page is refreshed.

Partial-Bug: #1859851

Change-Id: Icae04fd0f0c3f3fa5127309b64fc1b15e3bbc677
2023-01-31 18:17:07 +00:00
Alban Lecorps ee92961fe5 Remove console_type parameter for server_mks_console function
The "get_mks_console" use "console_type" as param, but causes an issue on Nova.
In horizon logs we have "Recoverable error: No available console found." and in the dashboard we have "Unable to load console. Please reload page to try again." when we load the console.
There is no need to call the function with this parameter, as it's already defined automatically since microversion 2.53.

Change-Id: I776b19f053ca74c699ca069e04553740f1e83b3e
2022-11-02 11:03:20 +01:00
Jan Hartkopf 05dd53a3cf Fix rescue of volume-based instances
Rescue of volume-based instances is supported since Nova
microversion 2.87.
However, Horizon does not use this microversion when requesting
rescue of any instances, causing a Nova exception for volume-
based ones.

The patch fixes this by explicitly setting the required
microversion.

Closes-Bug: #1941744
Signed-off-by: Jan Hartkopf <jhartkopf@inovex.de>
Change-Id: Ic0cdfd326475882f839fd218cd7b4bfa62a2a76b
2022-09-12 15:57:31 +02:00
Akihiro Motoki cd7c1b5110 Address RemovedInDjango40Warning (2)
django.utils.translation.ugettext(), ugettext_lazy(), ugettext_noop(),
ungettext(), and ungettext_lazy() are deprecated in favor of the
functions that they’re aliases for: django.utils.translation.gettext(),
gettext_lazy(), gettext_noop(), ngettext(), and ngettext_lazy().

https://docs.djangoproject.com/en/4.0/releases/3.0/#id3

Change-Id: I77878f84e9d10cf6a136dada81eabf4e18676250
2022-02-04 16:22:07 +09:00
manchandavishal 64fe0abb65 Fix Unable to use multiattach volume as boot for new server
If we try to create a new server from a bootable volume that
supports multiattach, it will fail to create with an error
message that ``multiattach volumes are only supported starting
with compute API version 2.60``. This patch fixes the issue.

Closes-Bug: #1931440
Change-Id: Ic8330b947b1a733f70c3bdad8b3493f20a2f26fb
2021-06-30 22:48:56 +05:30
Akihiro Motoki 672c43c43e Drop OPENSTACK_NOVA_EXTENSIONS_BLACKLIST finally
Part of the removal of OPENSTACK_NOVA_EXTENSIONS_BLACKLIST (3/3)

Clean up nova extensions related code in the API layer.

Change-Id: I9730095365342cac1023f4112bae4b3a28cdeaf7
2020-10-27 20:02:05 +09:00
Akihiro Motoki 692778f8cf pylint: Address no-else-return warning
This pylint check 'no-else-return' might be debatable.
but as far as I checked it works in most cases.

Change-Id: Ie8574d4a529454c6e050fa62a7a17ea097d00240
2020-09-27 12:44:16 +09:00
Hervé Beraud 17d8ab6103 Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: Ic03754dcaaa4f1c0018294aa52bb05d956aa5d10
2020-06-03 10:45:18 +02:00
KeithMnemonic 9637d73374 Fix "prev" link pagination for instances with identical timestamps
This patch resolves an issue with the "prev" link when instances
have identical "created_at" values. This can occur when creating
instance using the "min/max count" option. The reverse sort does not
work correctly as the server list returned from nova is not an exact
reverse as the forward sort. It looks like the combination of sort_keys
must be unique to ensure the forward and reverse pagination properly.
As a workaround 'uuid' (server ID) is added to 'sort_keys'.
In addition, 'display_name' is added before 'uuid' in 'sort_keys'
to list servers in the alphabetical order (which sounds natural).

Closes-Bug #1856243
Change-Id: I73234b2c69ce8ea648b4a9721abe4f5670031909
2019-12-25 20:12:03 +09:00
Matt Riedemann b148c92075 Remove dependency on novaclient list_extensions API
The novaclient list_extensions API binding was removed in the
16.0.0 release [1]. The ability to enable/disable extensions
in nova has been deprecated since Liberty [2] and was removed
in Newton [3].

For horizon this only matters for the OPENSTACK_NOVA_EXTENSIONS_BLACKLIST
config setting and some javascript code used to compile panels based on
enabled extensions. In order to work with novaclient 16.0.0+, this
change removes the list_extensions usage since all extensions
are enabled in nova and thus for horizon a nova extension is only
not supported if it's in the configured blacklist. To continue supporting
the javascript code which uses the getExtensions function, the extension
names are hard-coded. Note that the method meant to test that code,
_test_extension_list, was wrong but never ran because of the underscore
prefix on the method name. That is fixed here.

[1] https://review.opendev.org/686516/
[2] https://review.opendev.org/214592/
[3] https://review.opendev.org/351362/

Change-Id: Iebb1e78c718b931d632445e4de6d7a29ccb92be2
Closes-Bug: #1847959
2019-10-24 15:24:39 -04:00
Akihiro Motoki ec970fd6e8 Handle partial dict setting
In Train cycle, we moved the definition of default values
to openstack_dashboard/defaults.py. The current code accesses
a dict member using []. It requires operators to define a dict
setting with a full member.

This commit allows to use dict-type settings with partial members.

A new function is introduced to retrieve a dict-type setting
considering default values defined in
{openstack_dashboard,horizon,openstack_auth}/defaults.py

Change-Id: I7ff0ad4bca698aef9c0eba370b0570200a14367a
Closes-Bug: #1843104
2019-09-26 14:31:17 +09:00
Akihiro Motoki 7c897b677c Move openstack_dashboard specific settings from horizon
Cookie-based settings related to openstack_dashboard are located
under horizon directory,, but they are not related to "horizon".
This commit moves them to "openstack_dashboard" directory.

Part of blueprint ini-based-configuration
Change-Id: Id48ececdbe819a95485e9a91dc5a1a163a5568c3
2019-09-12 15:05:56 +09:00
Akihiro Motoki 9c19b07a26 Define default settings explicitly (openstack_dashboard 1/5)
Currently horizon defines default values of settings in the logic
using getattr(settings, <setting name>, <default value>) and
it is not easy to handle the default values of available settings.

This commit starts the effort to define default settings explicitly.
This is a preparation for ini-based-configurations.

It covers settings in openstack_dashboard/api.

Part of blueprint ini-based-configuration
Change-Id: Id4c3287f0a572fd14ea93b54bcab8fabda39e583
2019-04-24 02:32:47 +09:00
Daniel Vincze e332cef01c Add key_type selection on Keypairs form
Key type can be selected through both Django and Angular panels.
This change will allow X509 Public Certificates to be imported
or created through Horizon.

Also, the key type is being showed in the keypairs list.

Change-Id: I0a07b4805e6af96f06ec12d2e86708c94946e9c9
Closes-Bug: 1816041
2019-03-13 16:32:06 +02:00
Akihiro Motoki 949802264e pylint: fix cyclic-import
openstack_dashboard/api nova.py and cinder.py are imported
by each other. To avoid cyclic imports, some imports are placed
inside functions now, but it would be nice if we can move them
to a separate module and nova.py/cinder.py can import it.

This commit tries to achieve this by moving some stuffs in nova.py
into a separate module named _nova.py.
The module name starts with an underscore to clarify
it is intended to use only in openstack_dashboard.api.

Change-Id: If91cf4f30d2ddab471757129c2a74b26b6d38b1e
2019-02-09 21:08:48 +09:00
Akihiro Motoki c076db20c8 pylint: fix len-as-condition warning
Change-Id: Ib89c1854ad42b96e4caf281160d568fe98430afe
2019-01-16 12:56:20 +09:00
Akihiro Motoki 220b1346bd Enable pylint in horizon
tests.py files are excluded from targets checked by pylint
because it takes longer and longer time to check them somehow.

pylint 2.2.x is supported only in Python 3 and we already switched
our pep8 basepython to python3, so pylint and astroid are installed
only for python3. This seems the easiest way to ensure py27 env works.

literal-comparison error in openstack_dashboard/api/nova.py
is also fixed in this commit as it is simple enough.

Change-Id: Ic8868a44b296dba457be721716ca6f9d37ad9369
2019-01-12 22:41:20 +09: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
Zuul 119ce678da Merge "Support of rescue instance in Horizon" 2018-12-03 14:51:43 +00:00
Adrian Turjak e2360f9fe5 fix an issue with nova extension support checking
This bug was introduced by 3acb28270a

Closes-Bug: #1805469
Change-Id: I0d5d98718e764c89451ab3829cb325a150f29724
2018-11-28 05:24:45 +13:00
pengyuesheng ffa8b5404e Support of rescue instance in Horizon
Change-Id: Ie195befde8fe10ce419583ead06fdb759dd3813c
Implements: blueprint instance-rescue-horizon-support
2018-11-20 10:25:37 +00:00
Radomir Dopieralski 3acb28270a Replace @memoized_with_* with @memoized
Since @memoized now uses weakref to delete old cache entries, and no
longer keeps the object passed as parameters alive indefinitely, we
no longer need to treat the Request objects specially. In fact, if
we stop doing it, it should improve memory use, because now all
request-specific caches will be removed as soon as the request
object dies.

I also removed the memoized_with_argconv function, and replaced it
with an explicit function for converting teh parameters in the one
place where it was used.

Change-Id: I710b96a170e429c6ffdf22ad3e552ee6e1c6b7e3
2018-09-25 11:44:06 +02:00
Akihiro Motoki d68447452c Avoid UnhashableKeyWarning in api.nova.novaclient
In python3, novaclient APIVersion instance is not hashable.
If APIVersion insstance is passed to novaclient(),
UnhashableKeyWarning will be emitted.
An error message on UnhashableKeyWarning is emitted repeatedly
and this can pollute error log with unuseful messages.

To convert all unhashable arguments into hashable variables,
a new decorator memoized_with_argconv is introduced.
This decorator takes a converter function.

Change-Id: I773355b9332b3b195576b51cc81eda80aa4402ed
Closes-Bug: #1790929
2018-09-08 18:39:08 +00:00
Akihiro Motoki f9bb10b945 Avoid UnhashableKeyWarning in api.nova.extension_supported
In python3, novaclient ListExtResource is not hashable.
An error message on UnhashableKeyWarning is emitted repeatedly
and this can pollute error log with unuseful messages.

A tuple of extension names are now passed to the memoized
decorator so that the decorator can hash it.

Change-Id: I7f200ee6ece36767586207dc26aed1325b909226
Closes-Bug: #1790930
2018-09-05 20:25:53 +00:00
Akihiro Motoki d16ed45e06 Support "Get me a network" in launch instance
"Get-me-a-network" feature is supported in Nova API 2.37 or later.
To support this in horizon, a dummy "auto_allocated_network" is shown
in the launch instance form. I believe this approach fits the current
way of the launch instance form. The dummy network is a special network ID
and if specified the nova API wrapper converts 'nics' parameter properly.

In addition, a dummy "auto_allocated_network" is now shown in the network
table. This is because Neutron creates an actual auto allocated network
once a server is created specifying nics=="auto".
I believe this fake behavior brings consistency in the network table
to some extent, while this is just a compromise.

Note that this patch does not cover the network topology integration.
"auto_allocated_network" is not shown until the actual auto allocated
network is created. The network topology integration requires more work.
For example, the link for the fake auto allocated network should be
disabled in the flat view. The pop-up for the fake auto allocated network
should be disabled in the graph view.

Change-Id: I062fc1b7ed75dc771ddc7f13c8324ed4ffab6808
Closes-Bug: #1690433
2018-05-07 20:49:29 +09:00
Zuul 0d6061c47c Merge "Use microversion 2.60 when attaching a multiattach volume" 2018-04-25 13:55:23 +00:00
Sam Morrison 0887722914 Sort nova availability zones by name
Change-Id: I1e9a37e3dcf5040aa59e4efa65115f75819ef06e
Closes-Bug: #1762880
2018-04-12 11:59:44 +10:00
Akihiro Motoki 986e90248b Exclude nova-network quotas properly
openstack_dashboard.api.nova.QuotaSet was introduced to exclude
nova-network properly, but it did not work because QuotaSet does
not support 'in' and 'del' operations.
This commit fixes the logic and add a unit test.

Closes-Bug: #1743589
Change-Id: I8c3bfe985cccdf53fd555bf185c293806c14b6f6
2018-04-12 00:09:17 +09:00
Matt Riedemann 1e2dfc4bb4 Use microversion 2.60 when attaching a multiattach volume
Multiattach capable volumes can only be attached with microversion
2.60 or later, so this checks if the volume being attached is
multiattach capable and if microversion 2.60 is available, use it.

Part of blueprint multi-attach-volume

Closes-Bug: #1751564

Change-Id: If708e3edb05cff6e93cfc3dfccb91b1441dcd181
2018-04-10 16:22:06 -04:00
liyingjun 2ad84cb34f Support description for instance update/rebuild
In Nova Compute API microversion 2.19, you can specify a description
attribute when creating, rebuilding, or updating a server instance. This
description can be retrieved by getting server details, or list details
for servers, this patch adds support for this attribute for instance in
horizon.
This patch adds description for instance update/rebuild

Change-Id: I1c561607551fe6ed521772688b643cb27400e24e
Closes-bug: #1753661
2018-03-30 11:02:27 +08:00
wei.ying 940ff111a1 Add angular server group details page
This patch adds angular server group details page to show details of
the given server group, also shows the server group members under the
current server group.

Change-Id: I5b903972dd4fc5c9f1b52f97bdd7e0852d7d00d3
Partial-Implements: blueprint ng-server-groups
2018-03-18 22:42:43 +08:00
wei.ying 37647dd318 Add angular delete server groups action
This patch adds delete actions for angular server groups panel.

Change-Id: I9cd887fb315a5523c44c48d284cdea3a6673b3b2
Partial-Implements: blueprint ng-server-groups
2018-03-18 22:20:03 +08:00
wei.ying df857f00b5 Add angular create server group action
This patch adds create server group action for angular server groups
panel.

Change-Id: Ia4354448dcb42bc5e53e2415084f0569a75a68a3
Partial-Implements: blueprint ng-server-groups
2018-03-16 23:51:41 +08:00
Vladislav Kuzmin 38ebec57e9 Convert admin.aggregates tests into mock
Change-Id: Ia6c39234ea80128c36b1d2e3c891812f286acf56
2018-03-02 11:25:54 +04:00
Zuul 795b10280a Merge "Use nova os-services to retrieve host list" 2018-02-07 05:03:10 +00: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
David Lyle f25748293e Handle novaclient ec2 cert support removal
In Queens, ec2 cert support was removed from python-novaclient.
This causes horizon to be unable to get the keystone values of
ec2 credentials.

This patch removes the code that handles ec2 certs from nova.
Since the ec2 cert code in nova was removed in Mitaka. There is
no real risk of breaking backwards compatibility.

Change-Id: I470761d67004f6e6b188d3afc4b7f081b7bc708f
Closes-Bug: #1729175
2018-01-25 16:09:17 -07:00
peiy 42fe004c30 elif replace if
3 'if' at same levels and each 'if' has 'return',
in this case, elif is better than if.
more readable, more effective.

Change-Id: Ib0528ab69679f320f1580971945ce36eaaedf011
Signed-off-by: peiy <peiy@rc.inesa.com>
2018-01-19 16:35:41 +08:00
Akihiro Motoki df0a18e7a3 quota: retrieve quota (limit) and usage at once
Previously tenant_quota_usages() uses list API operations
to count usages. It is not efficient. This commit changes
the limit APIs from nova and cinder to retrieve usages.

blueprint make-quotas-great-again
Change-Id: I2c9a479758a1dfe134e5fabf16ab02831338718d
2017-12-13 20:27:02 +09:00
Akihiro Motoki 34fb3e5b0e quota: Disable nova-network quotas completely
nova-network quotas are considered in usage/quotas.py previously.
This commit completely always disables nova-network quotas.

The nova API wrapper ensures nova-network quota fileds are not
included in responses from tenant_quota_get and default_quota_get.

Drop nova-network quota fields from the Admin Defaults panel and
the Identity Project quota form.

blueprint make-quotas-great-again
Change-Id: Ie69d3003f62d3a124d79a1fea003092f73372187
2017-12-13 20:27:02 +09:00
Akihiro Motoki 4c8a294aee API micro-version support for multiple features
Previously horizon micro-version support only supports one feature,
but there is a case where we need to support more than one feature
using micro-versioning. For example, "instance_description" and
"auto_allocated_network" in the server create operation both require
micro-version. This case was not supported previously.

This commit changes get_microversion() function to take a feature list
and looks up a micro-version which supports all requested features.

A known limitation is that we need to re-call get_microversion() with
different feature(s) if no micro-version which satisfies all requested
features is found and we would like to look up a micro-version which
supports a subset of the requested features. Most features are expected
in recent API versions, so I believe this would be a minor limitation.

Change-Id: I46f1c7fa1ddcf1dfac93d921cffaf3aa5ac011a7
Related-Bug: #1690433
2017-12-03 07:59:32 +09:00
Akihiro Motoki 9854147407 Fix broken nova console support
A patch of MKS console support replaces 'console' key into
'remote_console', but 'remote_console' key is only available
in Nova API version 2.6 or later. Horizon uses Nova API version
2.1 by default, so this change breaks the existing server console
support completely. This patch fixes it.

Change-Id: I656037511e0d80688df4b82fa8c77fe5c09402bd
Closes-Bug: #1735436
2017-12-01 00:07:31 +09:00
Zuul 865f793ff8 Merge "Add MKS console support" 2017-11-30 04:39:27 +00:00
yong sheng gong 1f41f29f0b Add MKS console support
Co-Authored-By: jinke <jin.ke@99cloud.net>
Co-Authored-By: yong sheng gong <gong.yongsheng@99cloud.net>

Change-Id: Id8ee4a28a09eb3d7f7598c507c0a4320a97cd01c
implements: bp support-mks-console-type
2017-11-29 21:06:38 -05:00
Zuul c4c738be37 Merge "Show updated data on Flavor Access tab" 2017-11-21 20:46:36 +00:00
Shu Muto e7f22178b2 Add delete action for key pair
This patch adds delete actions for angularized key pair panel.

Change-Id: Iccb5014add0e19d6154bd6261d97a83b2ecdf32f
Partial-Implements: blueprint ng-keypairs
2017-11-01 14:53:04 +09:00
Trygve Vea af9505f1d5 Remove unused API function from Nova API
os-virtual-interfaces is part of nova-network, which Horizon does not support.
No code in Horizon is using this function, and it is no longer necessary.

Change-Id: I118c81db1e581487384677aa0b0020dd35001a29
2017-10-28 20:25:13 +00:00
liyingjun 2161b91264 [Micro version] Support description for instance
In Nova Compute API microversion 2.19, you can specify a “description”
attribute when creating, rebuilding, or updating a server instance. This
description can be retrieved by getting server details, or list details
for servers, this patch adds support for this attribute for instance in
horizon.

Change-Id: Ic9217234021d236aee8295915f1a9c3c544396b0
Implement-blueprint: support-description-for-instance
2017-10-26 22:36:00 +08:00
Feilong Wang fa2e8327b9 Add cache for get_microversion() against Nova
Actions "Lock" and "Unlock" of instance on instances table are calling
api.nova.is_feature_available() to check if the feature is supported
by current Nova server. Unfortunately, the function get_microversion()
called by is_feature_available() is not cached, which is causing about
40 unnecesary REST API calls. If the Nova's version is under Mitaka,
it could be even worse, about 80 unnecesary API calls, see
openstack_dashboard/api/nova.py#L60 and
novaclient/v2/versions.py#L47 for more details.

Closes-Bug: #1721423

Change-Id: Ie96b1a35e379d4cf407bfd53b1ee734178f9cb07
2017-10-05 14:37:38 +13:00
Jenkins 5428b96c2c Merge "Get all needed instances for volumes attachments at Admin->Volumes" 2017-09-05 11:53:52 +00:00