Commit Graph

112 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
elajkat ec4bfb91f0 [qos] _validate_create_network_callback return in no network
It seems that _validate_create_network_callback notified without
network_id in payload, to avoid issues in such case return.

Change-Id: I15d22e0e2b4bf3e4f882b521bcd6a13f84e4feed
Closes-Bug: #2008912
2023-06-20 15:14:15 +00:00
Rodolfo Alonso Hernandez 9ac59e4b4a Avoid retrieving ports if network list is empty
In ``QoSPlugin._get_ports_with_policy``, if the network IDs list is
empty, the SQLAlchemy throws the following warning:
  SELECT statement has a cartesian product between FROM element(s)
  "subports_1", "ports", "portnumaaffinitypolicies_1",
  "testportextensions_1", "portuplinkstatuspropagation_1",
  "portdataplanestatuses_1", "standardattributes_2",
  "portdeviceprofiles_1", "ml2_port_bindings_1",
  "portsecuritybindings_1", "portdnses_1",
  "securitygroupportbindings_1", "qos_network_policy_bindings_1",
  "qos_port_policy_bindings_1", "trunks_1",
  "standardattributes_1" and FROM element "networks".  Apply
  join condition(s) between each element to resolve.

This patch avoids this query by checking the network IDs list. If the
list is empty, the expected port list will be too. This is also a
small optimization because we are skipping the port query.

This patch is also applying the same logic to the second query in this
method.

Closes-Bug: #2018000
Change-Id: Ia5380bc78cc1d0136e11cc4692069279419e285e
2023-04-28 16:40:04 +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
Brian Haley cca0b3a026 Fix some pylint indentation warnings
Running with a stricter .pylintrc generates a lot of
C0330 warnings (hanging/continued indentation). Fix
the ones in neutron/services.

Trivialfix

Change-Id: Ie9779b257981bc80e69639cdaa4d7dfd0ffa5809
2022-12-01 16:21:37 +00:00
Nurmatov Mamatisa 738fb24f44 Use neutron-lib method update_qos_allocation
Method update_qos_allocation was modified and released
in neutron-lib [1] so can be removed from neutron code

1) https://review.opendev.org/c/openstack/neutron-lib/+/813660

Change-Id: Iebf38c0d4d01559b799eebee7221ed1f3b9baf6d
2022-06-24 08:14:22 +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
Slawek Kaplonski d7371e13e4 Revert "Set system_scope='all' in elevated context"
This reverts commit 062336e59b.

Now, we have proper fix for the system_scope='all' in elevated context
in the neutron-lib so we can revert temporary fix made at the end of the
Wallaby cycle.

Related-Bug: #1920001

Conflicts:
    neutron/api/rpc/agentnotifiers/dhcp_rpc_agent_api.py
    neutron/common/utils.py
    neutron/db/address_group_db.py
    neutron/services/segments/db.py

Change-Id: Ife9b647b403bdd76a8a99984ea8858bf95c96bc3
2021-06-15 10:29:20 +02: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
Slawek Kaplonski 062336e59b Set system_scope='all' in elevated context
In case when enforce_new_defaults is set to True and new policy rules
are used, context.is_admin flag isn't really working as it was with old
rules.
But in case when elevated context is needed, it means that we need
context which has full rights to the system. So we should also set
"system_scope" parameter to "all" to be sure that system scope queries
can be done with such elevated context always.

It is needed e.g. when elevated context is used to get some data from
db. In such case we need to have db query which will not be scoped to
the single project_id and with new defaults to achieve that system_scope
has to be set to "all".

Proper fix for that should be done in neutron-lib and it is proposed
in [1] already but as we are have frozen neutron-lib version for
stable/wallaby already this patch for neutron is temporary fix for that
issue.
We can revert that patch as soon as we will be in Xena development cycle
and [1] will be merged and released.

[1] https://review.opendev.org/c/openstack/neutron-lib/+/781625

Related-Bug: #1920001
Change-Id: I0068c1de09f5c6fae5bb5cd0d6f26f451e701939
2021-03-19 12:05:56 +01: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
Nurmatov Mamatisa 6ffeb0d623 Use constants from neutron-lib
Constants were released in neutron-lib 2.8.0

Change-Id: Iad52edda8c737585ff2fca59c032be38ba673d57
2021-02-04 06:33:49 +00:00
Oleg Bondarev 2a6fd9d44d Optimize get_ports with QoS extension
Apply qos resource extend func for a full list of ports,
not for each port individually, thus avoiding DB queries for each
individual port.
This should drastically improve port list time in case of many
ports/network with QoS policies assigned.

Change-Id: I1d0b3975ae6e92e34e9da20a0e26ce024422d332
Closes-Bug: #1905726
2021-01-25 08:21:39 +00: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
Slawek Kaplonski bf35cf65c8 Finish the new DB engine facade migration
This patch implements the last code bits pending to
conclude the new DB engine facade migration.

Due to the resultant interactions in the modified code, is
not possible to submit smaller patches; this code must be
migrated at once.

Partially-Implements blueprint: enginefacade-switch

Signed-off-by: Slawek Kaplonski <skaplons@redhat.com>
Co-Authored-By: Rodolfo Alonso Hernandez <ralonsoh@redhat.com>

Change-Id: Id3f09b78c8d0a8daa7ec4fa6f5bf79f7d5ab8f8b
2020-11-24 09:20:35 +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
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 f2b52b5e8f Add "qos_network_policy_id" to port definition
Added "qos_network_policy_id" key to port dictionary.

Change-Id: I75713e0e3924ad4c9177e7c9b04c58882e292dc0
Closes-Bug: #1851362
2020-01-17 17:57:11 +00: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
Rodolfo Alonso Hernandez 51dd91df5b Switch to new engine facade for QoS
* QosCoreResourceExtension
* QoSPlugin

Partially-Implements blueprint: enginefacade-switch

Change-Id: I034cad8d5290b416e55acdaeea69c5a130308afe
2019-05-28 08:11:35 +00:00
ZhongShengping 161e6b80f0 Replace git.openstack.org URLs with opendev.org URLs
Thorough replacement of git.openstack.org URLs with their opendev.org
counterparts.

Change-Id: Ifc446e00d7f69cb23411b3a50c8d880c719f1e73
2019-04-23 10:00:45 +08:00
Boden R ee77344ac1 use api def ALIAS in supported_extension_aliases
Today a number of classes define their supported_extension_aliases
using static strings rather than API definition ALIASes. This patch
switches them to use the ALIAS where applicable.

Change-Id: I716270c68a9fcd850c3c26de31bc13ea16def23d
2019-04-08 08:30:20 -06: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
Zuul c21d922abd Merge "Fix pep8 E128 warnings in non-test code" 2019-03-15 11:37:27 +00:00
Brian Haley eaf990b2bc Fix pep8 E128 warnings in non-test code
Reduces E128 warnings by ~260 to just ~900,
no way we're getting rid of all of them at once (or ever).
Files under neutron/tests still have a ton of E128 warnings.

Change-Id: I9137150ccf129bf443e33428267cd4bc9c323b54
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
2019-03-12 21:22:33 +00:00
Lajos Katona c1999a2b22 Fix QoS rule update
QoS rule (QosBandwidthLimitRule and QosMinimumBandwidthRule) update now
expects to have direction field in the API request for checking for
duplicates.
This patch changes this by using the rule fetched from the policy and
the update will work on that rule object instead of a newly created
object which for minimum_bandwidth rule has no default direction, which
causes the update to fail.

Change-Id: Ib8f95bf14193a50f22102668bed9208a93d1caba
Closes-Bug: #1815618
2019-03-11 07:24:30 +00:00
Bence Romsics abc8524db7 Use constant from neutron-lib
Follow up to https://review.openstack.org/636970.

TrivialChange

Change-Id: Ie0dce55b370a9942595ca205e560e6329609a2bf
2019-02-25 15:47:10 +01:00
Bence Romsics facc4e94ca Reject QoS minimum bandwidth rule updates for bound ports as NotImplemented
Updating QoS policies and rules backed by resources tracked in Placement
is a complex task, which was left out of scope for the Stein release.
Of course this is only relevant for policies/rules already in use on
bound ports. Rules of unbound ports can still be updated freely.

Please note this patch cannot catch all possible problems. There will
always be a time window between the allocation committed to Placement
and Nova sending the port binding request to Neutron. If the policy or
rule is changed in this window we cannot do anything against it.

APIImpact: Reject QoS minimum bandwidth policy/rule updates for bound
           ports as NotImplemented

Change-Id: I477edb0ae35b385ac776a58195f22382e2fce4ed
Partial-Bug: #1578989
See-Also: https://review.openstack.org/502306 (nova spec)
See-Also: https://review.openstack.org/508149 (neutron spec)
2019-02-21 16:59:31 +01: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
Nate Johnston 65a2f86aaf Gracefully handle fetch network fail in qos extend port
When the qos plugin is handling a port resource request through it's
port resource request extension, sometimes the network a port is
attached to is looked up and returns None. It may happen like that
if network will be deleted in concurrent API request.

Change-Id: Ide4acdf4c373713968f9d43274fb0c7550283c11
Closes-Bug: #1810504
2019-01-17 20:30:35 +00:00
Boden R 29f56478d1 remove the neutron.db._resource_extend module
The _resource_extend module is already rehomed into neutron-lib and is
shimmed in neutron. This patch removes the module as no active
consumers are using it.

NeutronLibImpact

Change-Id: I1550075fa5fa2aa2f1a88ee7189d311a1fe78391
2019-01-02 13:02:06 -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
Rodolfo Alonso Hernandez 8eee74f626 Use RBACBaseObject OVO in neutron/db/rbac_db_mixin.py
Implemented RBACBaseObject metaclass, inherited from NetworkRBAC
and QosPolicyRBAC.

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

Change-Id: I07d1e0bb27e19bd19911255c069fa27a42451264
2018-11-08 13:41:36 +00:00