Previously attach_interface tests in project/instances/tests.py
did not cover the case of attach_interface by port.
This commit adds UT for such cases.
Details:
- The second call of the mocked network_list_for_tenant retured
an empty list. It sounds tricky to change the return value for
network_list_for_tenant() in two calls, but this trick was used
to skip the processing of port_field_data.
This should return a same value for the two calls to test
port_field_data() function.
- To test the behavior of attach_interface by "port",
an unbound port (whose device_owner/device_id of the port is empty)
is required, so this commit adds it to neutron_data.py.
- test_interface_attach_get() covers a list of choices when "By Port"
is selected in the form.
- test_interface_attach_post_by_port() is added.
Related to the addition of an unbound port to neutron_data.py,
the following other tests are adjusted.
They assumed that all non-network ports are owned by servers,
but it is no longer true as an unbound port is added to the test data.
Note that associating an unbound port with a floating IP is a valid
operation in neutron, so there is no problem to adjust UTs.
- openstack_dashboard/dashboards/project/floating_ips/tests.py
- openstack_dashboard/test/unit/api/test_neutron.py
Related-Bug: #1943639
Change-Id: Ib0ee342463e5668858078db43c04fe0a1be6e995
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
Also, rename instance_id field to proper port_id.
Before this change, when instance_id was passed from the Instances
page in the URL, the information would be lost on form submission,
and if the form contained an error, the it would be redisplayed with
the port drop-down containing all ports from all instances. This also
made submitting this form slow, as the drop-down would be populated
with all ports on form validation.
It also creates a bug, where if there are more instances than Nova's
pagination allows, the ports from newer instances would no longer
appear in the drop-down, and the form would fail to validate, even
though the choice of port on initial form was correct.
Closes-bug: #1920010
Change-Id: I3ab26c19dc9ea1ed23fcff790d0db919039099eb
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
openstack_dashboard/dashboards/project/floating_ips/tests.py:
The floating IP panel implementation calls
openstack_dashboard.usage.quotas.tenant_quota_usages, but
its unit test mocks functions called inside tenant_quota_usages.
tenant_quota_usages itself should be mocked.
openstack_dashboard/test/unit/usage/test_quotas.py:
Mocked methods were not verified test_tenant_quota_usages_non_legacy.
Verifications for called methods are added.
Mocking floating_ip_supported is dropped as it is not called and
there is no need to mock it.
Change-Id: Iad66c882738fd90eb6dd6de3df96459c10a29aa2
In python3, super() does not always require a class and self reference.
In other words, super() is enough for most cases.
This is much simpler and it is time to switch it to the newer style.
pylint provides a check for this.
Let's enable 'super-with-arguments' check.
NOTE: _prepare_mappings() method of FormRegion in
openstack_dashboard/test/integration_tests/regions/forms.py is refactored.
super() (without explicit class and self referece) does not work when
a subclass method calls a same method in a parent class multiple times.
It looks better to prepare a separate method to provide a common logic.
Change-Id: Id9512a14be9f20dbd5ebd63d446570c7b7c825ff
'unnecessary-comprehension' warning is emitted when
unnecessary use of a comprehension is found.
classes attribute in Action can be a tuple,
so we need list() to ensure it is a list before adding 'disabled'.
I think it is time to introduce a method in Action class or somewhere
but it should be handled separately.
Change-Id: I16a98d56b6d0bd0af234b00735c6ed576620df7e
This pylint check 'no-else-return' might be debatable.
but as far as I checked it works in most cases.
Change-Id: Ie8574d4a529454c6e050fa62a7a17ea097d00240
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
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: I26a59176be9e9f213128e4945a58b9459334b626
- Fixes KeyErrors when accessing 'floatingip' values in usages, which
broken Floating IP allocation.
- The quota display in the bottom right of the Allocation dialog are
only displayed if 'enabled_quotas' is True
- Adds security group rule tallying for the usages overview page, which
fixes a KeyError crash for installations where Horizon 'enable_quotas'
is set to true, but the 'quota_details' extension is not installed on
in Neutron
- Adds a policy check to show and hide The plus/add button in
Instances->Associate Floating IP to match the Allocate IP To Project
button in Floating IPs
- Fixed the page title not being set for the non-modal version of the
modal allocation dialog/form
- Added an 'allowed' functionality for network usage overview charts to
allow for them to be dynamically disabled
- Added tests and mocks for the above
- Added tests for non-legacy quota tallying for networks
- Added test for disabled network quotas in overview
Change-Id: I47f73ff94664d315a2400feb8ce8a25f4e6beced
closes-bug: #1838522
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
string_concat was removed in django 2.1 when it reached the end
of it's deprecation cycle. It was removed because the same behavior
can be achieved with format_lazy.
For more details see:
https://docs.djangoproject.com/en/2.2/releases/2.1/
Change-Id: I5e1c9bdfa1d0e049e0516198abbdb76be1667216
Closes-Bug: #1836671
Partial-Bug: #1789046
This commit mainly covers settings
in openstack_dashboard/dashboards/project/.
Part of blueprint ini-based-configuration
Change-Id: I22413d2fe20576a507634dc4e2d0354c7db8800a
Removes the default 'required' attribute rendered by Django into the
hidden Selects of the ThemableDynamicTypedChoiceField widgets. This
attribute causes issues in Chrome with a new, client side validation
present in Django 1.10.
Change-Id: I6d0a2951cc74ffa57d091a4589372bf9b93cd33f
Closes-Bug: #1792127
This adds support for the "DNS Domain" and "DNS Name" options to the
panels for listing and allocation Floating IPs.
These options are available as a Neutron extension, so we need to
make them conditional based on the availability of that extension.
Change-Id: Ife8e19aac44dccbdf11a6a6d4bb50cd3b7ed8d8e
In addition, unnecessary API calls determined by 'targets'
are now removed.
blueprint make-quotas-great-again
Change-Id: I77b1335c25f2e2f3952e0d3c59f8c89a2bad3195
(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
The networking API supports setting a description on floating IP addresses.
This patch adds a form input field to the allocation form, and a column to the
table that displays floating IP list.
Closes-Bug: #1738625
Change-Id: I3cec286d01f319402dd652f2f0fe7a59e7d1cfbb
Previously neutron quota names and nova-network quota names are
mixly used and this makes the readability terrible.
We no longer supports nova-network, so it looks simple to use
neutron quota names consistently.
Neutron quota names use singular form and it is different
from nova and cinder (which adopt plural form as quota names).
Although it might be confusing, the mixed usage is much worse.
Some wrapper layer may address singular vs plural form issue,
but it can be solved later. Let's use neutron quota names
directly now to simplify the code.
blueprint make-quotas-great-again
Change-Id: Ie31414ada34cbdbd046063b512d3cef0a6e68acf
Previously neutron did not provide a way to retrieve resource usage
in a single API, so we need to call list APIs and count the number of
resources. Since Pike release, quota details API is provided and
it returns both quota and usage (used + reserved).
blueprint make-quotas-great-again
Change-Id: I63d0e81654c18f0f235631922d64d1109233fcfa
Previously when associating an FIP to a server, neutron ports which
do not belong to a target server were also shown in the target list.
It is clearer if only neutron ports connected to a target server
are shown. This commit changes the logic to lookup FIP targets to
achieve this.
Closes-Bug: #1630412
Change-Id: I9901b54e125b6bf09df86537c8308b2bfb1499f2
FloatingIpTarget was introduced but it was used partially.
This commit clean up the remaining logic of FIP target ID calculation.
Related-Bug: #1725657
Change-Id: I4b93b9a7a3977b042bb9c3200923c5c2fa84476d
It fixes an issue when pool name is not
displayed for floating ip in a case when any
floating ip is not associated with an instance.
Change-Id: Ic20ec3709fa7c5313f59a16aa32b975eb004f753
Closes-Bug: #1716431
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
This patch changes type of 'targets' input parameter in
tenant_quota_usages function from list -> tuple. It provides
possibility for @memoized decorator to cache function calls.
Change-Id: I3c32c3b65ae91e8487fda6148f259fe1931d7c9f
Closes-Bug: #1700578
This is a minor refactoring.
Members of FloatingIpTarget class is not clear.
From maintenance perspective, it would be nice if we have
explicit member definitions in the class definition.
TrivialFix
Change-Id: Iaaf5f8351e8ea35d19dc79c8dbfcc256f70d2e63
tenant_quota_usage() is used to retrieve quota and usage
to determine if a resource can be created.
However, tenant_quota_usage retrieves quota and usage for
all resources and it can be a performance problem.
This commit allows to load quota and usage only for resources
which are actually required.
Closes-Bug: #1675504
Change-Id: Iab7322a337a451a1a040cc2f4b55cc319b1ffc4c
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
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
Previously security group and floating IP tests covered
both nova and neutron APIs. This commit drops Nova security
group and floating IP unit tests. All these unit tests now
consumes neutron API wrapper and neutron test data.
Partially implement blueprint drop-nova-network
Change-Id: I1e3ad42cbeb90c00be29784869108d3d0db83162
This commit drops Nova floating IP dependency from
the dashboard implementation.
* Use neutron policy for floating IP operations.
* SimpleAssociateIP is supported only by Nova API,
so the action was removed in this patch.
Floating IP support in the nova API wrapper will be dropped
in a separate patch.
Partially implement blueprint drop-nova-network
Change-Id: I1610fb9aa2212b3f34814fdb9894b715a5211d9c
When retrieving resource usage, the current code calls subnet_list
twice for shared=False/True, but 'shared' attribute of subnet is
not defined in the Networking API and actually there is no need to
use it (even though it works as expected accidentally).
What we need here is to specify tenant_id as a query parameter
with a single API to limit the scope to a given project.
The same way can be used for network_list() and router_list() calls
and it is more efficient. By doing so, we now need only one
network_list() call.
Change-Id: I40d61ed9cbae4b083e4f3cec9caa269e92daf306
Closes-Bug: #1663170
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