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
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
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
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
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
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
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
Horizon will get all servers from Nova in different several places,
but sometimes it only need ID and name instead of all the related
information of servers. novaclient already support 'detailed=False'
param for servers query.
Horizon page loading performance can also be improved with this patch.
Closes-Bug: #1661423
Change-Id: Ic4cc95cb4eaed0461a22ab1045fa83ba5a5e9ce4
This patch makes the Floating IPs tab in Access & Security its own panel
under Project > Network
Change-Id: Ibb83ae5a0448d2824c10f867e620cec8219b7b72
Implements: blueprint reorganise-access-and-security