Commit Graph

78 Commits

Author SHA1 Message Date
Brian Haley 3ef02cc2fb Consume code from neutron-lib
All of these exceptions and constants have been in
neutron-lib for a while, start using them.

While looking for other things to consume found an old
neutron-lib TODO that did not apply anymore, so removed.

TrivialFix

Change-Id: I9431075a50ba05be872db422125e6af6266ccb99
2024-01-19 17:18:57 -05:00
Slawek Kaplonski 670cc383e0 [S-RBAC] Switch to new policies by default
As part of the Secure RBAC community goal, we should switch options
"enforce_new_defaults" and "enforce_scope" to be True by default.
It will be still possible to fallback to old policy rules by configuring
those config options to False in Neutron config.

Change-Id: I09c0026ccf87e6c0bb1fa59165c03dc508fba6fa
2023-04-21 16:22:42 +02:00
Rodolfo Alonso Hernandez 3ebdfe612a Support for minimum bandwidth rules in tunnelled networks
This patch adds support for QoS minimum bandwidth rules in tunnelled
networks. Now the ML2/OVS and ML2/OVN mechanism drivers can represent
in the Placement API the available bandwidth of the tunnelled networks
in each compute host.

Both mechanism drivers represent the compute VTEP (VXLAN) or TEP
(Geneve) interface as an IP address. This new resource provider
(by default called "rp_tunnelled") represents the available bandwidth
of this interface. Any new port created in a compute node that belongs
to a tunnelled network, will request to the Placement API the
corresponding bandwidth from the resource provider inventory.

This patch does not provide backend enforcement support for minimum
bandwidth rules.

RFE spec: https://review.opendev.org/c/openstack/neutron-specs/+/860859

What is missing and will be added in next patches:
* Tempest tests, that will be pushed to the corresponding repository.

Depends-On: https://review.opendev.org/c/openstack/neutron-tempest-plugin/+/863880

Partial-Bug: #1991965
Related-Bug: #1578989
Change-Id: I3bfc2c0f9566bcc6861ca91339e32257ea92c7e9
2023-01-02 11:14:50 +00:00
Rodolfo Alonso Hernandez 2f944d3105 Support filtering for QoS rule type list
Added support for filtering the QoS rule type list command.
Two new filter flags are added:
- all_supported: if True, the listing call will print all QoS rule
  types supported by at least one loaded mechanism driver.
- all_rules: if True, the listing call will print all QoS rule types
  supported by the Neutron server.

Both filter flags are exclusive and not required.

Depends-On: https://review.opendev.org/c/openstack/neutron-lib/+/827533

Closes-Bug: #1959749
Change-Id: I41eaab177e121316c3daec34b309c266e2f81979
2022-02-24 08:28:53 +00:00
Przemyslaw Szczerbik 084bb163f2 Add qos-pps-minimum-rule-alias API extension
Introduce a new API extension to enable GET, PUT and DELETE
operations on QoS minimum packet rate rule without specifying
policy ID.

Partial-Bug: #1922237
See-Also: https://review.opendev.org/785236
Change-Id: Ia083b5ac98c9e18ddbcdd2e0fc46f2f8432a628c
2022-02-07 11:52:46 +01:00
Przemyslaw Szczerbik 18ec0eb209 Fix placement allocation update for port with network QoS policy
If port has no QoS policy on its own, fallback to the network
QoS policy and use it to check if Placement allocation needs
to be updated.

Closes-Bug: #1915849
Change-Id: Iffc87e4021391bcb98375621739a59064540a6a7
2022-01-10 17:15:06 +01:00
Zuul b737f4a86e Merge "Update placement allocation of bound ports when network QoS policy is changed" 2021-12-16 20:13:26 +00:00
elajkat 6288dc7259 Keep binding:profile keys during placement allocation change
[1] overwrites the port's binding:profile with the  allocation dict,but
that dict can contain other fields also.

[1]: https://review.opendev.org/c/openstack/neutron/+/805637#617

Change-Id: I687686a673979cd9b95bac7282e836a6435f0521
Partial-Bug: #1922237
2021-12-07 10:52:38 +01:00
Przemyslaw Szczerbik e68a283211 Update placement allocation of bound ports when network QoS policy is changed
When QoS policy is changed on a network, placement allocation of bound
ports in that network has to be updated. This applies only to ports
that do not overwrite network QoS policy.

To detect network resource change, a new callback is registered for
AFTER_UPDATE event.

Closes-Bug: #1915898
Change-Id: Ibc71d26cbb0dce99ea6dad9e5ccd0966e72f3f20
2021-11-25 08:27:05 +01:00
Rodolfo Alonso Hernandez 4909c8c18d Bump neutron-lib to 2.17.0
Remove the QoS constants from Neutron code. QoS constants are now
located in ``neutron_lib.services.qos.constants``.

This patch also reverts [1]. This patch was merged in order to
allow a newer neutron-lib release in "requirements". This test
was failing because the element order of the "VALID_RULE_TYPES"
list was different between Neutron and neutron-lib. That was
modifying the "QosRuleType" OVO hash.

[1]https://review.opendev.org/c/openstack/neutron/+/817940

Closes-Bug: #1950977
Related-Bug: #1922237
Change-Id: I31edea3cc0f4a284a773a35302997ca6069efc95
2021-11-17 10:09:14 +00:00
Zuul 7f9fb75d90 Merge "Add port-resource-request-groups extension" 2021-10-31 22:09:55 +00:00
Rodolfo Alonso Hernandez e49485f2aa Replace "tenant_id" with "project_id"
Replace "tenant_id" with "project_id" in:
- Trunk service
- QoS plugin service

This is part of the remaining technical debt of the specs
https://specs.openstack.org/openstack/neutron-specs/specs/newton/moving-to-keystone-v3.html

Change-Id: I39d049bb506f24d1e1e2a35b659c93d0a22093f8
Blueprint: https://blueprints.launchpad.net/neutron/+spec/keystone-v3
2021-10-22 12:35:13 +00:00
Przemyslaw Szczerbik 8db15cb2f3 Add port-resource-request-groups extension
port-resource-request-groups extension provides support for the
new format of resource_request. The new format allows to request
multiple groups of resources and traits from the same RP subtree.

Closes-Bug: #1943724
Partial-Bug: #1922237
Depends-On: https://review.opendev.org/c/openstack/tempest/+/809168/
See-Also: https://review.opendev.org/785236
Change-Id: I99a49b107b1872ddf83d1d8497a26a8d728feb07
2021-10-21 14:30:07 +02:00
Przemyslaw Szczerbik 56044db26d Add API extension for QoS minimum pps rule
This patch implements support for CRUD operations for QoS minimum
packet rate, for example:

DELETE /qos/policies/$POLICY_ID/minimum_packet_rate_rules/$RULE_ID

Placement or dataplane enforcement is not implemented yet.

Partial-Bug: #1922237
See-Also: https://review.opendev.org/785236
Change-Id: Ie994bdab62bab33737f25287e568519c782dea9a
2021-09-29 12:27:30 +02:00
LIU Yulong 8e30639452 [QoS] Add rule type packet per second (pps)
This patch adds new API extension to QoS service plugin
to allow CURD actions for packet rate limit (packet per
second) rule in Neutron server side.

NOTE: This patch will NOT implement the real functionality
in L2/L3 backend to limit the pps.

Co-Authored-By:  NANALI <lin203@chinaunicom.cn>

Closes-bug: #1912460
Change-Id: Icc88accb88d9cec40c960c56f032c3c27317b42e
2021-07-22 09:53:38 +08:00
Przemyslaw Szczerbik 26b06d246a Use os-resource-classes lib for resource classes names
The os-resource-classes lib is the official source of the standard
placement resource classes. Currently, the neutron-lib contains a copy
of those constants. However, they are already marked as deprecated and
are going to be removed with next major release.

Related-Bug: #1934256
Change-Id: I33ecd6f32410f9b7ab1e87a6640201ea157bc383
2021-07-07 09:33:54 +02:00
Nurmatov Mamatisa 324a35a3d0 use payloads for PORT BEFORE_UPDATE events
This patch switches the code over to the payload style of callbacks
for PORT BEFORE_UPDATE events

Change-Id: Ie55a04deac6c2f54f7f5d475c350f0fbf7b1fe77
2021-06-23 12:14:48 +03:00
Nurmatov Mamatisa 07c64d8384 Payloads for PORT: BEFORE_CREATE and PRECOMMIT_CREATE
This patch switches the code over to the payload style of callbacks
for PORT BEFORE_CREATE and PRECOMMIT_CREATE events

Change-Id: Ia6903be1af4de575ab9d82c9cb0c88290d07abb3
2021-06-08 10:09:28 +00:00
Nurmatov Mamatisa 4aa5de254d use payloads for NETWORK callback events
This patch switches over to the payload style of callbacks for
NETWORK based events. As part of this change a few shims are needed
to handle cases where some callbacks don't yet use payloads and others
do. Once we move over to payloads for all callbacks the shims can be
removed.

NeutronLibImpact

Change-Id: I889364b5d184d47a79fe6ed604ce13a4b334acfa
2021-05-08 20:50:46 +03:00
Nurmatov Mamatisa 26f3de0f78 Add minimum bw qos rule validation for network
Minimum bandwidth QoS rule is only applicable for the network which is
backed by physical networks.
It will raise exception when you want to set Minimum bandwidth QoS rule
or update rule on network without ports.

Closes-Bug: #1913180
Change-Id: I6ab945086b13730ad60957760bbc2eb5c321aca2
2021-02-19 11:26:40 +03:00
Oleg Bondarev a7e02cdb17 [QoS] Get only min bw rules when extending port dict
Only min bw rules are required hence no need to fetch
all rules of QoS policy.
Also no need to get qos policy from DB

Partial-Bug: #1905726
Change-Id: Iad29cb34825adaa8c766d01b192a6bbe9992148b
2021-01-18 11:13:43 +00:00
elajkat 3605e9f82d QoS policy update with placement: handle missing key
Closes-Bug: #1898994
Change-Id: Ibb826346117cd5cc824fff55d123497a19370f5c
2020-10-08 19:49:07 +02:00
elajkat 87e5131432 Allow replacing the QoS policy of bound port
Change-Id: Iebdfd2b303f47ff9f049cf583ea754b35ca26f78
Related-Bug: #1882804
Depends-On: https://review.opendev.org/748279
2020-09-24 06:18:38 +00:00
Brian Haley 7594bb0627 Remove the dependency on the "mock" package
Now that we are python3 only, we should move to using the built
in version of mock that supports all of our testing needs and
remove the dependency on the "mock" package.

This patch moves all references to "import mock" to
"from unittest import mock". It also cleans up some new line
inconsistency.

Fixed an inconsistency in the OVSBridge.deferred() definition
as it needs to also have an *args argument.

Fixed an issue where an l3-agent test was mocking
functools.partial, causing a python3.8 failure.

Unit tests only, removing from tests/base.py affects
functional tests which need additional work.

Change-Id: I40e8a8410840c3774c72ae1a8054574445d66ece
2020-04-28 18:05:37 -04:00
Bence Romsics 321afc8f89 Move rejection of min-bw rule on non-physnet port to the ovs qos driver
The ovs qos driver only supports the min-bw rule on physnet ports.
However other (future) qos drivers may support the min-bw rule on
non-physnet ports too, therefore implementing the rejection of the
unsupported combination in the qos plugin was a bug.

This change moves the rejection from the qos plugin to the ovs qos
driver.

Change-Id: I02d77a03c411dc8ab303a7d7b53d7ea93cc9f4c6
Closes-Bug: #1861442
Depends-On: https://review.opendev.org/705694
Related-Bug: #1819029
2020-02-21 15:00:23 +01:00
Rodolfo Alonso Hernandez 4a06e08de6 Improve "QoSPlugin._validate_create_port_callback"
Make use of the OVO Port new field "qos_network_policy_id" to avoid
a DB call.

Change-Id: I3724acfbe88ab3db1641c3edb5dd4c76bc84bc00
Related-Bug: #1834484
2019-07-09 16:54:03 +00:00
Rodolfo Alonso Hernandez 8b00349a63 Refactor qos_plugin._extend_port_resource_request
In order to speed up the port collection, some DB calls
have been deleted in the extended function
"QoSPlugin._extend_port_resource_request".

With the parent commit, the port DB/OVO object now has the
network QoS policy ID, making the network retrieval unneeded.

In this refactor the QoS policy is collected from the DB only
if a valid QoS policy ID exists, bound to the port or to the
network. This reduces the number of QoS objects collection to
one or zero.

Change-Id: Iadf704c00378da99c502dca3e3b79796c368cac7
Closes-Bug: #1834484
2019-07-05 08:10:01 +00:00
Boden R 9bbe9911c4 remove neutron.common.constants
All of the externally consumed variables from neutron.common.constants
now live in neutron-lib. This patch removes neutron.common.constants
and switches all uses over to lib.

NeutronLibImpact

Depends-On: https://review.openstack.org/#/c/647836/
Change-Id: I3c2f28ecd18996a1cee1ae3af399166defe9da87
2019-04-04 14:10:26 -06:00
Bence Romsics 3e008fd51b FUP: Unit tests for https://review.openstack.org/636970
I forgot to add unit tests to the original change.
This patch adds the missing unit tests.

Change-Id: If281f9a8c33864fa18a3b8a8de854816f5773efe
Related-Bug: #1578989
Related-Change: https://review.openstack.org/636970
See-Also: https://review.openstack.org/502306 (nova spec)
See-Also: https://review.openstack.org/508149 (neutron spec)
2019-03-25 12:58:01 +01:00
Bence Romsics d1696619c5 Reject min-bw rule operations on non-physnet networks/ports
Change-Id: I54d421d0993bd9515ab5ba32f75f40d1ef46eccb
Closes-Bug: #1819029
Depends-On: https://review.openstack.org/644847
2019-03-23 15:44:31 +00:00
Miguel Lavalle 636f1b5394 Define qos-rules-alias extension
This patch adds qos-rules-alias extension to enable users to perform
GET, PUT and DELETE operations on QoS rules as though they are first
level resources. In other words, the user doesn't have to specify the
QoS policy ID.

Change-Id: Ia7535d83e3ae874106e22652dfd97bd9250ad37b
Partial-Bug: #1777627
2019-03-21 15:06:10 +00:00
Boden R 68fd13af40 remove neutron.common.exceptions
Today the neutron common exceptions already live in neutron-lib and are
shimmed from neutron. This patch removes the neutron.common.exceptions
module and changes neutron's imports over to use their respective
neutron-lib exception module instead.

NeutronLibImpact

Change-Id: I9704f20eb21da85d2cf024d83338b3d94593671e
2019-02-01 14:35:00 -07:00
Boden R c8c201bca9 consume get_updatable_fields from neutron-lib
The neutron.objects.base.get_updatable_fields function is now in
neutron-lib. This patch consumes it by removing the function from
neutron and using lib's version instead.

NeutronLibImpact

Change-Id: Ia06ad97e053dd59a1163f6c31199dde07bb0ffbf
2019-01-02 07:10:25 -07:00
Lajos Katona e78f82e64f Fill port-resource-request
port-resource-request is an admin-only, read-only attribute for neutron
ports. The content of this field is filled from the QoS minimum
bandwidth rule attached to the port.

Change-Id: Ic9862a1b5e24eb798d67823ac3bacab9e54420d8
Partial-Bug: #1578989
See-Also: https://review.openstack.org/502306 (nova spec)
See-Also: https://review.openstack.org/508149 (neutron spec)
2018-12-18 10:18:40 +01:00
Zuul e8168345ef Merge "Refactor duplicated implementation of _get_policy_obj" 2018-07-13 14:51:40 +00:00
IWAMOTO Toshihiro 0f180d8e2e Adopt hacking 1.1.0
This incorporates flake8 2.6.x and pycodestyle will be used
instead of older pep8.  This ensures future python3 compatibility
and a bit better code styling.

Change-Id: Ia7c7c5a44727f615a151e1e68dd94c7ed42f974f
2018-07-05 11:31:40 +09:00
LIU Yulong a034e8e0f8 Refactor duplicated implementation of _get_policy_obj
This patch moves the implementation of the function
_get_policy_obj to the policy object code scope.

Change-Id: I7057558a5ec32a55a37a6b93dabc997d69abfb98
2018-06-20 09:51:02 +08:00
Brian Haley 7cfdf4aa81 Fix all pep8 E129 errors
Fixed all pep8 E129 errors and changed tox.ini to no longer
ignore them.

Change-Id: I0b06d99ce1d473b79a4cfdd173baa4f02e653847
2018-05-03 13:44:04 +09:00
Ihar Hrachyshka f69389004a Revert "Revert "Automatically expire obsolete relationships""
This reverts commit a75014792a.

This is the second attempt to merge the patch after the previous one resulted
in revert due to multiple gate breakages in dependent projects (neutron-lbaas,
vmware-nsx, heat, networking-odl). This second attempt is validated with a set
of depends-on patches for all projects that were affected during the first
failed attempt.

The original commit message for the patch is included below for context.

===

Listen for foreign key changes and expire related relationships.

With this, we can remove OVO code that refreshes / detaches models on
each fetch. The patch also removes a bunch of expunge calls in plugin
code.

writer.using context manager is added to _get_subnets so that segment
plugin's _notify_subnet_updated handler that calls to _get_subnets
doesn't use the facade-less context.session that in specific cases may
cache old models from previous sessions when used in mixed
facade/facade-less environment.

This patch bumps SQLAlchemy minimal requirement to >= 1.2.0 because
pending_to_persistent event didn't exist before this version. It could be >=
1.1.0 if not for the fact that all 1.1.x releases have a bug that results in
breakage of test_update_with_none_and_own_mac_for_duplicate_ip due to obscure
import ordering issue in the library.

(The issue is fixed by https://github.com/zzzeek/sqlalchemy/commit/
63ff0140705207198545e3a0d7868a5ba8486e93)

Partially-Implements: blueprint enginefacade-switch
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db

Co-Authored-By: Michael Bayer <mike_mp@zzzcomputing.com>
Depends-On: If4b28110f460f6ac77ace1bbb02967ea986d4cab
Depends-On: I9f1e76cb24838533572b5fbe269ff96a24ce4af1
Change-Id: I0d65d19204da8ce30addfa5faff68544534b7853
2018-04-26 22:04:07 +00:00
Rabi Mishra a75014792a Revert "Automatically expire obsolete relationships"
This reverts commit 90ede813b0.

Closes-Bug: #1766267
Change-Id: Ia491a2a404bcbd9e108d20b2d9393aff1bb48c8e
2018-04-23 14:30:32 +00:00
Ihar Hrachyshka 90ede813b0 Automatically expire obsolete relationships
Listen for foreign key changes and expire related relationships.

With this, we can remove OVO code that refreshes / detaches models on
each fetch. The patch also removes a bunch of expunge calls in plugin
code.

writer.using context manager is added to _get_subnets so that segment
plugin's _notify_subnet_updated handler that calls to _get_subnets
doesn't use the facade-less context.session that in specific cases may
cache old models from previous sessions when used in mixed
facade/facade-less environment.

This patch bumps SQLAlchemy minimal requirement to >= 1.2.0 because
pending_to_persistent event didn't exist before this version. It could be >=
1.1.0 if not for the fact that all 1.1.x releases have a bug that results in
breakage of test_update_with_none_and_own_mac_for_duplicate_ip due to obscure
import ordering issue in the library.

(The issue is fixed by https://github.com/zzzeek/sqlalchemy/commit/
63ff0140705207198545e3a0d7868a5ba8486e93)

Partially-Implements: blueprint enginefacade-switch
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db

Co-Authored-By: Michael Bayer <mike_mp@zzzcomputing.com>
Change-Id: I18c6794f99d2847c208dfd6e9eb187d53b657a05
2018-04-20 15:33:59 -05:00
Boden R 537bfb9a1c use callback payloads for PRECOMMIT_UPDATE events
This patch switches callbacks over to the payload object style events
[1] for PRECOMMIT_UPDATE based notifications. To do so a DBEventPayload
object is used with the publish() method to pass along the related data.
In addition a few UTs are updated to work with the changes. Finally
a few shims are put into place to allow PRECOMMIT_UPDATE based events to
use payloads while still supporting the existing kwarg style events.

NeutronLibImpact

[1] https://docs.openstack.org/neutron-lib/latest/contributor/callbacks.html#event-payloads

Change-Id: Ie6d27df01cd7b87894efc80946d41eb1ebe25bef
2018-03-13 11:38:19 -06:00
Sławek Kapłoński 8c23e35709 Fix creation of port when network has admin's QoS policy set
In case when admin user creats QoS policy and will attach it to
user's namespace there was an issue with getting such QoS policy
with user's context to validate it.

This patch changes it, that QoS policy is always get with elevated
context during port/network create/update validation.

Change-Id: I464888ca3920b42edd6ab638f6a317ee51ef0994
Closes-Bug: #1750591
2018-02-22 13:36:43 +01:00
Sławek Kapłoński a91d84cfb4 Fix error message when duplicate QoS rule is created
When user tries to create QoS rule which already exists in same
QoS policy, only check if rule is duplicated was done on DB layer.
Because of that, there was many retries of DB operations so user
waits to response from Neutron server long time.
Also error message returned from this DB related exception was not
user friendly.

This patch adds additional check of such duplicated rules before
there is attempt to save new/updated rule in database so in case
of error, response is send to user faster and it has proper
message.

Change-Id: I7d55df1eb931583c3dde064e073deb3e5479acc2
Closes-Bug: #1746526
2018-02-13 10:16:02 +01:00
Reedip a9aef9b9c7 Improve Qos Policy Rule test
The current policy rule tests do not test the actual
rule information involved in the test.
This patch takes care of the same.


Closes-Bug: 1676877
Change-Id: I50ccb9e9237f7e3b2f5c66d1fc3b539905fa0281
2017-12-20 08:47:15 +00:00
Boden R 1b8664f8e1 use qos constants from neutron-lib
neutron-lib contains the QoS constants. This patch removes them from
neutron and replaces all such uses to lib's QoS constants.

NeutronLibImpact

Change-Id: I6ed379b178a2b79fd14385a1d1e87d87eb04bfb9
2017-10-26 19:57:19 +00:00
Boden R 95f1e03446 use plugin constants from neutron-lib
neutron-lib contains a number of the plugin related constants from
neutron.plugins.common.constants. This patch consumes those constants
from neutron-lib and removes them from neutron. In addition the notion
of the dummy plugin service type is moved strictly into the test
package of neutron since it's not a real service plugin.

NeutronLibImpact

Change-Id: I767c626f3fe6159ab3abd6a7ae3cb9893b79bf66
2017-10-16 09:32:20 -06:00
Sławek Kapłoński 2cc547241c New API call to get details of supported QoS rule type
This commit adds new API call that allows to discover
details about supported QoS rule type and its parameters
by each of loaded backend drivers.

DocImpact: New call to get details about supported
           rule_type for each loaded backend driver
ApiImpact

Change-Id: I2008e9d3e400dd717434fbdd2e693c9c5e34c3a4
Closes-Bug: #1686035
2017-07-11 14:24:17 +00:00
Sławek Kapłoński 09c946910f Fix updating Qos policy to be default/not default
During QoS policy update there was no project_id
attribute loaded to QoS object. That caused problem with
updating policy object because "get_default()" method
requires project_id.
This patch fixes it by first getting QoS policy object and
then update it.

Additionally there was mistake in assertion in QoS Default
policy fullstack test and this patch fixes it also.

Change-Id: I57011bd4d40479855203061554090d19bb668960
Closes-Bug: 1694553
2017-06-02 16:05:42 +00:00
Rodolfo Alonso Hernandez 9d69822e43 Add "default" behaviour to QoS policies
This patch implements the "default" behaviour for QoS policies.
If this flag is enabled for a QoS policy in a project, all
new networks created will have this QoS policy assigned by default.

If a new QoS policy is created or updated with this flag and another
QoS policy in the same project is set as the default policy, the new
one won't be created or updated. To set another QoS policy as default,
the current one must be unset.

DocImpact: A "default" flag is introduced for QoS policies. If this flag
           is enabled in a QoS policy (attached to a project), then all
           networks created in this project would have this QoS policy
           assigned, unless an explicit policy is specified.
APIImpact

Closes-Bug: #1639220
Change-Id: If5ff2b00fa828f93aa089e275ddbd1ff542b79d4
2017-05-26 23:31:36 +00:00