Commit Graph

27 Commits

Author SHA1 Message Date
Pedro Martins 1db1764749 Add NAT rules to the floating IP workflow
The floating IP workflow is now able to manage NAT
rules (portforwarding) if the floating IP is not
associated with any NICs (ports).

This patch is the one of a series of patches
to implement floating ip port forwarding with
port ranges.

The specification is defined in:
https://github.com/openstack/neutron-specs/blob/master/specs/wallaby/port-forwarding-port-ranges.rst

Implements: blueprint https://blueprints.launchpad.net/neutron/+spec/floatingips-portforwarding-ranges
Change-Id: Id715da6591124de45f41cc367bf39a6bfe190c9a
2023-03-01 10:38:16 -03:00
Akihiro Motoki 516e57bc89 Add UT coverage for attach_interface by port
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
2022-10-26 15:34:17 -05:00
Radomir Dopieralski 3d82d57353 Save instace_id inside Associate Floating IP workflow
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
2021-03-18 12:39:23 +01:00
Akihiro Motoki b89c705164 Refactor quota related unit tests
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
2020-10-26 17:20:52 +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 d870b40583 Remove six usage from openstack_dashboard 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: I26a59176be9e9f213128e4945a58b9459334b626
2020-01-15 12:47:48 +02:00
Jens Harbott 9e703aec2f Add DNS parameters to Floating IP panels
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
2018-07-22 20:24:36 +09:00
Akihiro Motoki 06ca3c811b quota: Move targets argument to get_disabled_quotas
In addition, unnecessary API calls determined by 'targets'
are now removed.

blueprint make-quotas-great-again
Change-Id: I77b1335c25f2e2f3952e0d3c59f8c89a2bad3195
2018-04-19 20:37:46 +00:00
Akihiro Motoki d62d6e39e1 Convert project tests into mock: fip/sg/key_pairs/topology
Partially-Implements: blueprint mock-framework-in-unit-tests
Change-Id: I13b3f15736b9a26863d18f732fd26ea35ac00f00
2018-03-20 08:33:05 +09: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 1340904d47 quota: Use network quota field names consistently
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
2017-12-13 20:27:02 +09:00
Akihiro Motoki cd3f3e5127 quota: Use neutron quota_details API to retrieve usage
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
2017-12-13 20:27:02 +09:00
Akihiro Motoki d14fbc849e FIP associate: Show only ports from a target server
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
2017-11-18 00:03:00 +00:00
Akihiro Motoki 7961c6a84f Refactor FIP code to use FloatingIpTarget properly
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
2017-11-18 00:03:00 +00:00
Mykhailo Dovgal ca0f293cb6 Fix tenant_quota_usages function calls caching
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
2017-06-26 17:36:07 +03:00
Jenkins 829a961d73 Merge "api.neutron: Explicit member of FloatingIpTarget class" 2017-06-14 12:10:03 +00:00
Akihiro Motoki cabdbcccb3 api.neutron: Explicit member of FloatingIpTarget class
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
2017-06-14 09:05:18 +00:00
Akihiro Motoki 359467b401 Retrieve quota and usage only for resources really required
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
2017-06-14 08:53:32 +00:00
Akihiro Motoki 9067ae8b0f Move SG and FIP API wrapper to api.neutron
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
2017-06-04 17:51:25 +00:00
Akihiro Motoki acd3f2a240 Drop novalclient security group and floating IP dependency
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
2017-04-28 08:38:28 +00:00
Akihiro Motoki f23c84189c Drop Nova SG and FIP related unit tests from dashboard code
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
2017-04-28 08:35:39 +00:00
Akihiro Motoki 8b6d3422e8 Drop Nova floating IP dependency from dashboard
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
2017-04-28 08:28:41 +00:00
MinSun af8a01b362 usage: Ensure to count resources of a given project
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
2017-04-13 09:40:15 +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
Béla Vancsics ff733ceced Use more specific asserts in tests
Instead of assertTrue and assertFalse use more specific asserts.
They are compatible with Python 2.7[1] and 3.4[2]

[1]: https://docs.python.org/2.7/library/unittest.html
[2]: https://docs.python.org/3.4/library/unittest.html

Change-Id: I9b07cc324757f35b1e8431b715412bf5d7fa8ecb
2017-02-15 11:19:43 +01:00
Lingxian Kong c33b0840cb Only get detailed info for Nova servers when necessary
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
2017-02-03 12:03:22 +13:00
Rob Cresswell 99849ad88f Move Floating IPs from Access & Security to panel
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
2017-02-01 18:57:44 +00:00