Commit Graph

39 Commits

Author SHA1 Message Date
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
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
Rodolfo Alonso Hernandez 1e81fd2bc0 Do not query the DB if QoS policy ID is None
When retrieving the QoS policy rules, if the QoS policy ID passed is
None, do not query the DB and return an empty rule list for this
non existing QoS policy.

Change-Id: Idccbd22a1dc9bef81b2cdae0a597c1a587a60ae0
2020-12-24 12:22:40 +00:00
Brian Haley 08a60f7483 Remove usage of six.add_metaclass
With python 3.x, classes can use the metaclass= logic
to not require usage of the six library.

One step in removing all of six usage from neutron.

Change-Id: I2f815e412d9a96eb5faf2b3bb3a1e393a9db9309
2020-05-21 14:41:18 -04:00
Boden R b4972e246d use objects common_types from neutron-lib
This patch consumes the neutron-lib OVO common_types module by
removing it from neutron and switching imports over to use neutron-lib
instead.

NeutronLibImpact

Change-Id: Ic9819a27e3e72038b819ab2fe845c26fc63b26d5
2019-11-26 15:34:18 +01:00
Rodolfo Alonso Hernandez db3001a7a2 Remove QoS related objects unneeded compatibility conversions
Last changes affecting to object compatibility, done in those OVOs:
* QoSPolicy: https://review.opendev.org/#/c/428304/, 2y 4m ago.
* QosBandwidthLimitRule: https://review.opendev.org/#/c/449831/,
  2y 5m ago
* QosDscpMarkingRule: https://review.opendev.org/#/c/300501/,
  3y 3m ago
* QosMinimumBandwidthRule: https://review.opendev.org/#/c/344145/,
  3y ago
* QosRuleType: https://review.opendev.org/#/c/475260/, 2y 3m ago

Change-Id: I5fd394c2deb4446e21e092ea490791cc5bbc5669
Related-Bug: #1828437
2019-09-27 12:06:07 +00:00
Brian Haley c3b83a9ca6 Fix all pep8 E265 errors
Fixed all pep8 E265 errors and changed tox.ini to no longer
ignore them.  Also removed an N536 comment missed from a
previous change.

Change-Id: Ie6db8406c3b884c95b2a54a7598ea83476b8dba1
2018-04-30 16:35:52 -04:00
Brian Haley 90cd939047 Fix W503 pep8 warnings
Fix W503 (line break before binary operator) pep8 warnings
and no longer ignore new failures.

Trivialfix

Change-Id: I7539f3b7187f2ad40681781f74b6e05a01bac474
2018-04-17 14:22:58 +00:00
Zuul 8456a3af7a Merge "Fix error message when duplicate QoS rule is created" 2018-02-13 21:14:43 +00: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
Ihar Hrachyshka 6f83466307 Allow objects to opt in new engine facade
New facade is enabled by setting new_facade = True for the object of
interest. With new_facade on, all OVO actions will use the new reader /
writer decorator to activate sessions.

There are two new facade decorators added to OVO: db_context_reader and
db_context_write that should be used instead of explicit
autonested_transaction / reader.using / writer.using in OVO context.

All neutron.objects.db.api helpers now receive OVO classes / objects
instead of model classes, since they need to know which type of engine
facade to use for which object. While it means we change signatures for
those helper functions, they are not used anywhere outside neutron tree
except vmware-nsx unit tests, and the latter pass anyway because the
tests completely mock out them disregarding their signatures.

This patch also adds several new OVO objects to be able to continue
using neutron.objects.db.api helpers to persist models that previously
didn't have corresponding OVO classes.

Finally, the patch adds registration for missing options in
neutron/tests/unit/extensions/test_qos_fip.py to be able to debug
failures in those unit tests. Strictly speaking, this change doesn't
belong to the patch, but I include it nevertheless to speed up merge in
time close to release.

There are several non-obvious changes included, specifically:

- in neutron.objects.base, decorator() that refreshes / expunges models
from the active session now opens a subtransaction for the whole span of
call / refresh / expunge, so that we can safely refresh model regardless
of whether caller opened another parent subtransaction (it was not the
case for create_subnetpool in base db plugin code).

- in neutron.db.l3_fip_qos, removed code that updates obj.db_model
relationship directly after corresponding insertions for child policy
binding model. This code is not needed because the only caller to the
_process_extra_fip_qos_update method refetches latest state of floating
ip OVO object anyway, and this code triggers several unit test failures.

- unit tests checking that a single commit happens for get_object and
get_objects are no longer valid for new facade objects that use reader
decorator that doesn't commit but close. This change is as intended, so
unit tests were tweaked to check close for new facade objects.

Change-Id: I15ec238c18a464f977f7d1079605b82965052311
Related-Bug: #1746996
2018-02-09 04:07:34 +00:00
Sławek Kapłoński 5e08a9b0e7 [OVO] Switch to use own registry
Neutron will now use own registry for versionedobjects.
It avoids problems with loading wrong OVO objects from
different projects (like os_vif) when names are the same.

Change-Id: I9d4fab591fbe52271c613251321a6d03078976f7
Closes-Bug: #1731948
2017-11-22 17:44:22 +01: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 0822b0aef4 consume common constants from lib
The neutron-lib commit I360545b6ee4291547e0c5c8e668ad03d3efa4725 moved
the externally consumed globals from neutron.common.constants into lib.
With the exception of PROVISIONAL_IPV6_PD_PREFIX all other constants
in neutron.common.constants should only be used in neutron, and will
hopefully remain that way. External consumers needing access to other
common constants should move them into lib first.

NeutronLibImpact

Change-Id: Ie4bcffccf626a6e1de84af01f3487feb825f8b65
2017-10-13 11:45:18 -06:00
Sławek Kapłoński c29f3aaa7c Add QoS bandwidth limit for instance ingress traffic
This patch introduces the new parameter "direction" to
the QoS bandwidth limit rule. It will allow the creation
of bandwidth limit rules for either ingress or egress
traffic. For backwards compatibility the default direction
will be egress.

DocImpact: Ingress bandwidth limit available for QoS
APIImpact: New type of parameter for QoS rule in neutron API

Change-Id: Ia13568879c2b6f80fb190ccafe7e19ca05b0c6a8
Partial-Bug: #1560961
2017-04-27 12:51:50 +00:00
Maxime Guyot 2d1ee7add7 Apply QoS policy on network:router_gateway
All router ports (internal and external) used to be excluded from QoS
policies applied on network. This patch excludes only internal router
ports from network QoS policies.
This allows cloud administrators to set an egress QoS policy to a
public/external network and have the QoS policy applied on all external
router ports (DVR or not). To the tenant this is also egress traffic so
no confusion compared to QoS policies applied to VM ports.

DocImpact

Update networking-guide/config-qos, User workflow section:
- Replace "Network owned ports" with "Internal network owned ports"

Change-Id: I2428c2466f41a022196576f4b14526752543da7a
Closes-Bug: #1659265
Related-Bug: #1486039
2017-03-21 11:24:57 +01:00
Rodolfo Alonso Hernandez 4ffeef246f Enforce port QoS policies for all ports.
This patch enforces the port QoS policies applied on all ports.
Besides that, a port QoS policy must prevail over a network QoS
policy, if both are present on the same port.

Change-Id: Icccb835e48bb70ac1a08e0887ecb34160bec8cfa
Closes-Bug: #1659312
Closes-Bug: #1665282
2017-02-18 15:33:40 +00:00
Zainub Wahid bb78621a72 Make UUIDField actually validate UUIDs
Instead of using oslo.versionedobjects UUID type, use a custom UUIDField
class located in common_types that will actually validate passed values
for UUID-ness.

Closes-Bug: #1614537
Change-Id: I20b24ee57c521b1c68977c2ff7ae56b56875dd64
2016-12-07 15:11:43 +00:00
Gary Kotton 7c0b219e66 neutron-lib: complete usage of helpers
Add support for:
    - get_random_string
    - camelize
    - round_val
    - safe_decode_utf8

Change-Id: I3b5ccbbcfa18aa488b1772f4ae9a591eb494de59
2016-11-10 05:40:15 -08:00
Rodolfo Alonso Hernandez 60325f4ae9 Add QoS minimum bandwidth rule for instance egress traffic
This patch introduces the front end implementation for QoS
minimum bandwidth rule.

APIImpact: New type of parameter for QoS rule in neutron API
DocImpact

Change-Id: I6b619a96a2bfde164646c71409b671352bc6ce7d
Partial-Bug: #1560963
2016-08-27 17:08:18 +00:00
David Shaughnessy 1bb95a4554 Add object versioning to QoS DSCP.
- Changes RULE_TYPE_DSCP_MARK to RULE_TYPE_DSCP_MARKING to conform
  with the rules name.
- Added object versioning to qos related objects.
 - qos/rule: Throws a QosRuleVersionUnavailable exception when
   the QosDscpMarkingRule version is < '1.1'.
- removed test object version incrementation TODO from test_policy.py
 - Object versioning can not be used to increment the object version.

Change-Id: I4f10ef3c1cbaa2a868de2b8e3abc4c39eb1f44c7
Partial-Bug: #1468353
2016-07-12 11:11:11 +01:00
Henry Gessau 4148a347b3 Use constants from neutron-lib
With this we enable the deprecation warnings by default.

Related-Blueprint: neutron-lib

Change-Id: I5b9e53751dd164010e5bbeb15f534ac0fe2a5105
2016-04-23 21:23:56 -04:00
David Shaughnessy a9a1943fde DSCP QoS rule implementation
This patch adds the front end and back end implementation of QoS DSCP.

Associated patches that are dependent on this one:

* python-neutronclient: https://review.openstack.org/#/c/254280
* openstack-manuals: https://review.openstack.org/#/c/273638
* API Guide: https://review.openstack.org/#/c/275253
* Heat:
  * Spec: https://review.openstack.org/#/c/272173
  * QoSDscpMarkingRule resource: https://review.openstack.org/#/c/277567
* Fullstack tests: https://review.openstack.org/#/c/288392/

APIImpact - The API now supports marking traffic egressing from a VM's
            dscp field with a valid dscp value.

Co-Authored-By: Nate Johnston <nate_johnston@cable.comcast.com>
Co-Authored-By: Victor Howard <victor.r.howard@gmail.com>
Co-Authored-By: Margaret Frances <margaret_frances@cable.comcast.com>
Co-Authored-By: James Reeves <james.reeves5546@gmail.com>
Co-Authored-By: John Schwarz <jschwarz@redhat.com>
Needed-By: I25ad60c1b9a66e568276a772b8c496987d9f8299
Needed-By: I881b8f5bc9024c20275bc56062de72a1c70c8321
Needed-By: I48ead4b459183db795337ab729830a1b3c0022da
Needed-By: Ib92b172dce48276b90ec75ee5880ddd69040d7c8
Needed-By: I4eb21495e84feea46880caf3360759263e1e8f95
Needed-By: I0ab6a1a0d1430c5791fea1d5b54106c6cc93b937
Partial-Bug: #1468353

Change-Id: Ic3baefe176df05f049a2e06529c58fd65fe6b419
2016-03-18 10:07:24 +01:00
Martin Hickey 074268f74c Add test for Neutron object versions
Adds a test to Neutron to check object versions for any changes
to objects. It prompts the developer to update the version of the
changed object. It uses oslo.versionedobjects.

Change-Id: I99454b28ae0b5fa663354eeccdf709d4030a280b
Co-Authored-By: Ryan Rossiter <rlrossit@us.ibm.com>
2016-01-06 10:34:03 +00:00
Miguel Angel Ajo fe236bdaad No network devices on network attached qos policies
Network devices, like internal router legs, or dhcp ports
should not be affected by bandwidth limiting rules.

This patch disables application of network attached policies
to network/neutron owned ports.

Closes-bug: #1486039
DocImpact

Change-Id: I75d80227f1e6c4b3f5fa7762b8dc3b0c0f1abd46
2015-09-16 15:11:04 +02:00
Ihar Hrachyshka 582d03e464 objects.qos.policy: provide rules field, not type specific
It should be forbidden to have multiple rules of the same type attached
to a policy, so the idea of having per type lists is moot.

Instead, we should have a single list of all rules that belong to the
policy.

Also fixed a test that validated a single transaction to actually work
with multiple autonested transactions applied.

Partially-Implements: blueprint quantum-qos-api
Change-Id: Ia152b3ff385d2aa0cf40664ef039265b046b1d17
2015-08-01 22:16:34 +02:00
Ihar Hrachyshka c9bdcb5557 Unite qos_rules and qos_*_rules tables
The only values in qos_rules table are: type, id and qos_policy_id. Both
id fields point to qos_*_rules and qos_policies objects.

Type is redundant since qos_rule and qos_*_rule objects maintain 1-to-1
relationship.

Keeping a separate table just to link qos_*_rule and qos_policy objects
has no meaning. At the same time, it complicates the code for rule
objects significantly.

So instead of copying with all those issues, we just squash the tables
into single one. It allows us to reuse all base methods from
NeutronObject for rules.

LOC stats for the patch clearly shows the point:

65 insertions(+), 267 deletions(-)

And no actual functionality is lost.

While at it, the following changes were applied:

- some base tests are reimplemented to test objects in a more explicit
  way;
- fields_no_update class attribute is now actually enforced in base
  object class.

Partially-Implements: blueprint quantum-qos-api
Change-Id: Iadabd14c3490c842608e53ceccf38c79dcdf8d85
2015-08-01 22:13:14 +02:00
Ihar Hrachyshka 12f7abd398 Introduce mechanism to determine supported qos rule types for a plugin
Every plugin that supports some of QoS rules will define a property
called supported_qos_rule_types of list type.

For ml2, determine supported qos rule types as a subset of rule types
supported by all drivers. (In the future, we may expand the list to
include all types supported by at least one of enabled drivers. This
would require synchronized work with nova scheduler though.)

For ml2, tests are limited, and should be expanded to check that common
subset of qos rules is calculated properly when intersection != the list
of each plugins. For now, it's enough since we don't have more than one
rule type planned for Liberty.

Added API test for the resource.

Partially-Implements: blueprint ml2-qos
Co-Authored-By: Irena Berezovsky <irenab.dev@gmail.com>
Co-Authored-By: John Schwarz <jschwarz@redhat.com>
Change-Id: I0d18ae256877a129e203110003fcadd1d63590b4
2015-07-27 16:48:48 +03:00
Jakub Libosvar fd0bf11183 QoS: Remove type attribute from QoS rules
The type is given by object itself. We don't specify type when creating
resource cause it's a part of uri. This patch allows a
bandwidth_limit_rule to be created in given policy.

Partially-Implements: blueprint quantum-qos-api
Change-Id: Ica4626083054200e3b82bef23984462e7c596e1e
2015-07-25 15:50:31 +02:00
Jakub Libosvar 7ed1d4f616 Support qos rules and fields parameters in GET requests
Previously we didn't load the rules into policy object. This patch adds
loading the rules and defines bandwidth_limit_rules as a policy
resource in a single transaction. As a part of moving towards usage of
single transaction, create() and update() of rule were modified
accordingly.
Finally, we support types in GET requests in this patch.

API tests will follow in different patch.

Change-Id: I25c72aae74469b687766754bbeb749dfd1b8867c
2015-07-24 11:47:10 +00:00
Ihar Hrachyshka 69f4b813e8 [qos] cleanup _find_object from neutron.db.api
Instead of having a separate function for id-based search, make
get_object accept any kwargs, including id=, and reuse it everywhere
where we used _find_object before.

Change-Id: Ibd94c41fb847d67aabb94172d0117bafc0fdbdf6
2015-07-23 13:49:49 +02:00
Ihar Hrachyshka d3708de0cb Merge remote-tracking branch 'origin/feature/qos' into merge-branch
Also applied the following fixes:

===

1. cleaned up some pylint failures that were not spotted before:

Module neutron.objects.qos.policy: Metaclass class method __new__ should
have 'mcs' as first argument

Module neutron.objects.qos.rule: Lambda may not be necessary

===

2. Revert "Introduce the AFTER_READ callback for ports and networks"

This reverts commit e3dba14241.

We don't use callbacks to extend resources anymore, instead relying on
ml2 extension drivers. No need for the patch to achieve QoS, and it also
breaks test_delete_subnet_with_callback that was added in master
recently.

===

3. updated requirements.txt and test-requirements.txt based on:

https://review.openstack.org/#/c/204398/

to avoid requirements gate checks failing due to incompatible
requirements comparing to global-requirements.txt

Change-Id: I744ab2d8327a428a5467f2d07d073a5f8c333520
2015-07-23 11:48:57 +02:00
Ihar Hrachyshka 0a33e355bc objects.qos.policy: support per type rule lists as synthetic fields
This is a significant piece of work.

It enables neutron objects to define fields that are lazily loaded on
field access. To achieve that,

- field should be mentioned in cls.synthetic_fields
- obj_load_attr should be extended to lazily fetch and cache the field

Based on this work, we define per type rule fields that are lists of
appropriate neutron objects. (At the moment, we have only single type
supported, but I tried hard to make it easily extendable, with little or
no coding needed when a new rule type object definition is added to
rule.py: for example, we inspect object definitions based on
VALID_RULE_TYPES, and define appropriate fields for the policy object).

To implement lazy loading for those fields, I redefined get_by_id for
rules that now meld fields from both base and subtype db models into the
corresponding neutron object.

Added a simple test that checks bandwidth_rules attribute behaves for
policies.

Some objects unit test framework rework was needed to accomodate
synthetic fields that are not propagated to db layer.

Change-Id: Ia16393453b1ed48651fbd778bbe0ac6427560117
2015-07-16 15:51:47 +02:00
Jenkins 950dde86df Merge "objects.base: fixed object.delete()" into feature/qos 2015-07-13 15:51:51 +00:00
Ihar Hrachyshka 954e9de8b3 objects.base: fixed object.delete()
It was using wrong call to delete an object from a session.

Also, expanded test_create() test to check all basic operations:
get_by_id, create, update, and delete.

To facilitate update() check, introduced a new field for objects called
fields_to_update that stores names of fields that are not expected to be
updated in an object. This allows us to keep the above mentioned test
untangled from specific object type.

Also made get_by_id() behave correctly (returning None) if the object
does not exist.

Change-Id: I1aecb2e7c4d8cb8f239072d1cb9df3db29dcedde
2015-07-10 18:01:52 +00:00
John Schwarz 00589382cf Cleanup rule models and objects
- drop tenant_id for base and bandwidth_limit rules;
- added 'to_dict' function to convert objects into dicts.

Change-Id: I28167e356e70235304b166c997df52ca1b28f836
2015-07-10 17:59:48 +00:00
Ihar Hrachyshka a71cb067d0 objects.qos: fixed create and update for QosBandwidthLimitRule
To simplify Qos*Rule object type implementation, renamed 'qos_rule_id'
field for qos_bandwidth_limit_rule table into 'id'.

Also added unit test coverage for the object type.

Change-Id: Id6bc992af9f1ab46c022d3c88aa66a0f3bb7f227
2015-07-10 17:59:19 +00:00
Ihar Hrachyshka e90b28662e First QoS versioned objects, ever
Well, first versioned objects in the tree.

Binding to networks and ports is not implemented.

No tests. Checked manually.

blueprint quantum-qos-api

Co-Authored-By: vikram.choudhary <vikram.choudhary@huawei.com>
Change-Id: I9b6cacfda4f40230d746222bed5b6c490be63743
2015-07-02 09:21:45 +03:00