Commit Graph

37 Commits

Author SHA1 Message Date
Rodolfo Alonso Hernandez dd184c5c10 Fix Loki tempest jobs
This patch fixes the issues reported in the
"neutron-ovn-tempest-with-uwsgi-loki" job:
* The missing retry decorators in some ``TapPlugin`` methods.
* Added a session flush in
  ``OVNL3RouterPlugin.create_router_precommit``. In case the router
  creation fails before the creation of the initial
  ``OVNRevisionNumbers`` register, the transaction is retried.
  That will prevent from trying to retrieve a router standard
  attribute that doesn't exist, due to a previous error.

Closes-Bug: #2017131

Change-Id: Idbf7ea6018146b67387f2ff99e281e32170ba039
2023-04-23 07:26:55 +02:00
Rodolfo Alonso Hernandez eeb918e1b9 Add the corresponding DB context to all SQL transactions
The goal of this patch is to make the Neutron code compliant
with SQLAlchemy 2.0.

All SQL transactions must be executed inside an explicit
writer/reader context. SQLAlchemy no longer will create an
implicit transaction if the session has no active transaction.

A warning message, only available in debug mode, is added. When
an ORM session calls "do_orm_execute", if there is no active
transaction, a warning message with a traceback will be logged
to help to debug the regression introduced.

Related-Bug: #1964575

Change-Id: I3da37fee205b8d67d10673075b9130147d9eab5f
2022-04-08 09:09:54 +00:00
Nurmatov Mamatisa ce3b86eef3 Use neutron-lib standard_attr
Now only neutron uses neutron/db/standard_attr.py
Shim can be removed

Change-Id: I980265335c5f3f6b5ee2e5fbcad9491aad91defe
2021-09-15 09:19:26 +00:00
Miguel Lavalle e22a191f47 Implement tagging during bulk port creation
This change proposes a ML2 plugin extension to implement tagging during
bulk port creation.

Change-Id: Ic70f7d282db478c69016ab1c317c5cae786401ce
Related-Bug: #1815933
2020-01-28 18:23:37 -06:00
Brian Haley b79842f289 Start enforcing E125 flake8 directive
Removed E125 (continuation line does not distinguish itself
from next logical line) from the ignore list and fixed all
the indentation issues.  Didn't think it was going to be
close to 100 files when I started.

Change-Id: I0a6f5efec4b7d8d3632dd9dbb43e0ab58af9dff3
2019-07-19 23:39:41 -04:00
Boden R 957eca96f4 delete common_db_mixin
The functionality within neutron.db.common_db_mixin is available via
neutron-lib APIs. This patch removes common_db_mixin and updates any
uses of it to use neutron-lib instead.

Depends-On: https://review.openstack.org/#/c/636159/

NeutronLibImpact

Change-Id: I2388f90b37abb09408809dda8c21da551bcd94bb
2019-04-17 11:25:41 -06: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
Boden R 1382bf9a32 remove the neutron.db._model_query module
The functionality from model_query is already in neutron-lib and
consumers are using it. This patch removes the _model_query module
from neutron and updates all imports to use neutron-lib's version of
it instead.

NeutronLibImpact

Change-Id: Ib2eae9edb009a93e60b3b0d63ca365056138566b
2019-01-25 08:55:25 -07: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
Boden R e4aa5902f7 use context manager from neutron-lib
The neutron.db.api.context_manager already references neutron-lib's
context manager; so consumers of it are already using neutron-lib. This
patch switches neutron's references to the context_manager over to
use neutron-lib's directly rather than that in neutron.db.api.

NeutronLibImpact

Change-Id: I97120faeec73690592ed21a5ec3c6202f61e1429
2018-10-24 07:18:46 -06:00
Boden R 6d9f1c662f use retry_if_session_inactive from neutron-lib
The retry_if_session_inactive decorator was rehomed into neutron-lib
[1]. This patch consumes it by removing the function from neutron and
using neutron-libs version where appropriate.

NeutronLibImpact

[1] https://review.openstack.org/#/c/557040/

Change-Id: I3e3289f33e62d45933d0fbf165bb4b25078f22d5
2018-10-12 14:47:35 -06:00
Lajos Katona fd17815228 Use Tag OVO in neutron/services/tag/tag_plugin.py
This patch removes neutron/db/tag_db.py and moves the relevant code to
neutron/objects/tag.py.

Change-Id: I147debf7f7c8388140b160cd835dbd4a95fee784
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
2018-08-29 13:00:10 +02:00
Hongbin Lu 2b1d8ea4a2 Implement filter validation
Enforce validation on filter parameters on list requests.
If an API request contains an unknown or unsupported parameter,
the server will return a 400 response instead of silently ignoring
the invalid input.

In resource attributes map, all filter parameters are annotated by
the ``is_filter`` keyword. Attributes with is_filter set to True
are candidates for validation.

Enabling filter validation requires support from core plugin and
all service plugins so each plugin need to indicate if it supports
the validation by setting ``__filter_validation_support`` to True.
If this field is not set, the default is False and validation is
turned off. Right now, the ML2 plugin and all the in-tree service
plugin support filter validation. Out-of-tree plugins will have
filter validation disabled by default.

An API extension is introduced to allow API users to discover this
new API behavior. This feature can be disabled by cloud operators
if they choose to do that. If it is disabled, the extension won't
be presented.

Depends-On: Ic3ab5b3ffdc378d570678b9c967cb42b0c7a8a9b
Depends-On: I4397df1c35463a8b532afdc9c5d28b37224a37b4
Depends-On: I3f2e6e861adaeef81a1a5819a57b28f5c6281d80
Depends-On: I1189bc9a50308df5c7e18c329f3a1262c90b9e12
Depends-On: I057cd917628c77dd20c0ff7747936c3fec7b4844
Depends-On: I0b24a304cc3466a2c05426cdbb6f9d99f1797edd

Change-Id: I21bf8a752813802822fd9966dda6ab3b6c4abfdc
Partial-Bug: #1749820
2018-07-19 04:13:43 +00:00
Boden R 87a36cacc6 remove tag and tag_ext extensions
The tag and tag_ext extensions are deprecated for removal, but are not
used widely today [1]. Rather than rehoming these extensions to
neutron-lib and carrying out their deprecation life-cycle for no
apparent reason, this patch proposes we just remove them now.

While [2] initially removed these extensions, we had to revert
them with [3].

Depends-On: I295a5b84eb7fa3439561fa009b7499f94d8df4d2

[1] http://codesearch.openstack.org/?q=from%20neutron.extensions%20import%20(tag_ext%7Ctag)
[2] I0d7bcd789b468b1dd3f7ea13e6751a46203d6778
[3] If16443616eee703b66d57b6422dd451a443fbc64

Change-Id: I97095453610fff114d999a526d67e78119546ff5
2018-03-16 13:09:42 -06:00
Hongbin Lu 4904455bf2 Revert "remove tag and tag_ext extensions"
It looks this patch breaks Zun's gate. The reason might be
that Zun depends on Kuryr-libnetwork which still use the
legacy tag extension. I propose to revert this for now and
give the kuryr team some time to migrate to the new extension.

This reverts commit 38148d1752.

Change-Id: If16443616eee703b66d57b6422dd451a443fbc64
2018-02-14 06:32:30 +00:00
Boden R 38148d1752 remove tag and tag_ext extensions
The tag and tag_ext extensions are deprecated for removal, but are not
used today [1]. Rather than rehoming these extensions to neutron-lib and
carrying out their deprecation life-cycle for no apparent reason, this
patch proposes we just remove them now.

[1] http://codesearch.openstack.org/?q=from%20neutron.extensions%20import%20(tag_ext%7Ctag)

Change-Id: I0d7bcd789b468b1dd3f7ea13e6751a46203d6778
2018-02-12 09:04:15 -07:00
Boden R 15af19be70 use neutron-lib's OVO exceptions
neutron-lib contains the OVO exception module. This patch switches all
such reference's over to lib's version of the module and removes it
from neutron.

Change-Id: Ic3d435eef51f970598bf50486894838498b2d438
Note: We don't currently have any out-of-tree consumers of this module.
2017-08-28 09:31:19 -06:00
Hirofumi Ichihara 96f0142b80 Tag mechanism supports resources with standard attribute
Tag mechanism supports network, subnet, port, subnetpool
router resources only. This patch allow tag mechanism to support
 resources with standard attribute.

Two old extenions are kept because of backward compatibility.
They will be removed in Queens release.

APIImpact: Tag is supported by resources with standard attribute
DocImpact: allow users to set tags on resources with standard attribute

Change-Id: Id7bb13b5beb58c313eea94ca03835d3daf5c94bc
Closes-Bug: #1682775
2017-07-25 08:14:04 +09:00
Boden R 62576cabf7 use core resource attribute constants from neutron-lib
neutron-lib now contains the API definitions for neutron's core
resources. This patch removes the constant core resource and collection
variables and uses them from lib. Subsequent patches will consume the
actual core resource attribute definitions.

NeutronLibImpact

Change-Id: Ia9afdf620cd538b2aa420593277d6403a45c996b
2017-06-30 06:25:36 -06:00
Henry Gessau d8c1e153f8 Stop using CommonDbMixin
Now that CommonDbMixin is just a shim we can stop using it.

Instead, use the model_query and resource_extend functions directly.

Related-Blueprint: neutron-lib

Change-Id: If1252c42c49cd59dba7ec7c02c9b887fdc169f51
2017-04-26 10:37:36 -04:00
Henry Gessau b3c0d5f239 Eliminate lookup of "resource extend" funcs by name
By registering functions directly we cut off the dependency of the
"resource extend" functions on the plugin. This is a step towards
the goal of removing the CommonDbMixin mixin class.

Also, we register all "resource extend" functions at plugin create
(in __new__) instead of in the class definition (which caused the
hooks to be registered on import). This ensures the "resource
extend" functions are only registered for the plugins/mixins that
are actually used.

Note that decorators are used to register "resource extend" methods,
similar to the callback receiver decorators.

Related-Blueprint: neutron-lib

Change-Id: I128cfda773d5f9597df9cd61261fdc05f2a174aa
2017-04-21 14:48:42 -04:00
Henry Gessau 844033a5d1 Eliminate lookup of model query hooks by name
By registering functions directly we cut off the dependency of the
query hooks on the plugin. This is a step towards the goal of
removing the CommonDbMixin mixin class.

Also, we register all query hooks at plugin create (in __new__)
instead of in the class definition (which caused the hooks to be
registered on import). This ensures the query hooks are only
registered for the plugins/mixins that are actually used.

Since the query hooks are decoupled from the plugin, we remove them
from the extension mixins (make them global in their module). This is
a step towards refactoring all extension mixins for removal.

Extra: In this patch we also remove the CommonDbMixinHooksFixture test
fixture and instead just clear out the hooks after each test.

Related-Blueprint: neutron-lib

Change-Id: Ib6c2134d29e1764de627c3355f6cdee789d6301e
2017-04-16 10:33:36 -04:00
Jenkins 038597e794 Merge "Use correct retry mechanism in tags" 2017-03-17 08:40:32 +00:00
Kevin Benton 44b6fcb4d2 Use correct retry mechanism in tags
This replaces wrap_db_retry with
neutron.db.api.retry_if_session_inactive() in the tags
plugin.

wrap_db_retry is missing a bunch of exception types we
can encounter and are expected to retry in normal database
operations in Neutron (e.g. staledataerror in the bug report).

This patch doesn't include a unit test because there is already
quite a bit of coverage ensuring the decorator handles these types
of exceptions.

Closes-Bug: #1673243
Change-Id: I65b10ee54301401cd4525152a82a604ac8744582
2017-03-15 12:46:23 -07:00
Ihar Hrachyshka 0cb8fd6374 On update_tags, clean up tags from the requested resource only
There was a bug in I0179a3616689f39d93c337c730283e21a01677cf that made
the service plugin to clean up removed tags from all resources, not just
the one requested.

Change-Id: Ifbe13102ebd903e01eb28a00d97e7e94d1a0e0b1
Closes-Bug: #1673086
2017-03-15 15:11:12 +00:00
Jenkins 6ed307eb98 Merge "Decouple hook and func registration from CommonDbMixin" 2017-03-15 01:46:04 +00:00
Henry Gessau e7cd868c20 Decouple hook and func registration from CommonDbMixin
Move the model query hook registration and resource extend funcs
registration methods out of the CommonDbMixin class and make them
regular utility functions.

This is a step in refactoring the CommonDbMixin class.

Change-Id: Iec1bb7f7098c83640ae695fd7cf2f4736f414ad2
2017-03-11 18:04:11 -05:00
Aradhana Singh 7fa7e1b915 OVO for Tag
This patch introduces and integrates Oslo-Versioned Object for
Tag Model class.

Change-Id: I0179a3616689f39d93c337c730283e21a01677cf
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
2017-03-07 23:06:00 +00:00
Jenkins df7de345fc Merge "Enhance tag mechanism" 2017-02-06 08:56:38 +00:00
Hirofumi Ichihara b56f008f3a Enhance tag mechanism
This patch enhances the tag mechanism for subnet, port, subnetpool,
router resources. The tag-ext as new extension is added so that
tag supports their resources.

APIImpact: Adds tag support to subnet, port, subnetpool, router
DocImpact: allow users to set tags on some resources

Change-Id: I3ab8c2f47f283bee7219f39f20b07361b8e0c5f1
Closes-Bug: #1661608
2017-02-04 11:07:04 +09:00
Kevin Benton faf80b950f Use weakrefs for common_db_mixin callbacks
This will prevent the common_db_mixin dictionary
extension functions and query hooks from stopping
the GC of plugins in tests and causing resource leaks.

Change-Id: I7576851a44abd14cbc337a3d3e28690c7316ec81
2017-01-26 07:10:06 -08:00
Kevin Benton 6bd3ad2bb3 Bump revision of resource on tag add/remove
This updates the tag to bump the revision of the standard
attr record it's associated with. This required a small change
to include a bump revision method directly on the standard
attr records.

Closes-Bug: #1643879
Change-Id: Ia096cd342ed3eeec33a8ae64efe13d469c375dd6
2016-12-19 11:20:54 -08:00
Ann Kamyshnikova 53ad48002c Use new enginefacade for tag
Use reader and writer for db operations with tags.

Partially-Implements blueprint: enginefacade-switch

Change-Id: I64b72c9ea7f8594e7958f5a521d7283376a368da
2016-11-14 08:28:02 +00:00
Aradhana Singh b6a296edf6 Relocate Tag DB model
This patch relocates Tag db model from neutron/db to neutron/db/models

Change-Id: Ibb9325f30af85300afe62bb5415388271cf13833
Partial-Bug: #1597913
2016-10-03 10:20:05 -05:00
zhufl 80c3a7aba0 Remove unused LOG
This is to remove unused LOG to keep code clean.

Change-Id: I5623fb0b22464c39a28c6e8f28878e6db4504e24
2016-07-05 15:22:13 +08:00
Hirofumi Ichihara 7fb8d542ef Add filter for resource tag
Introduce a generic mechanism to allow the user to get
Neutron resources with tag filter.

APIImpact

Change-Id: I1e5b25fea268e188cc9620c72b3c71004b197512
Partial-Implements: blueprint add-tags-to-core-resources
Related-Bug: #1489291
2016-03-01 20:47:12 +00:00
Hirofumi Ichihara ec1457dd75 Add tag mechanism for network resources
Introduce a generic mechanism to allow the user to set tags
on Neutron resources. This patch adds the function for "network"
resource with tags.

APIImpact
DocImpact: allow users to set tags on network resources

Partial-Implements: blueprint add-tags-to-core-resources
Related-Bug: #1489291
Change-Id: I4d9e80d2c46d07fc22de8015eac4bd3dacf4c03a
2016-03-02 05:43:14 +09:00