After updating pylint, it started emitting additional "R"
warnings in some cases, fix some of them.
use-a-generator,
unnecessary-lambda-assignment,
consider-using-max-builtin,
consider-using-generator,
consider-using-in,
use-list-literal,
consider-using-from-import
Trivialfix
Change-Id: Ife6565cefcc30b4e8a0df9121c9454cf744225df
Some files are using strings access_as_shared or access_as_external
instead of using defined constants ACCESS_SHARED and ACCESS_EXTERNAL.
This commit is doing the cleaning it does not bring any functional
change.
Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@industrialdiscipline.com>
Change-Id: Ib75326c762776c5259740cb2f0abc1163842f95d
Running with a stricter .pylintrc generates a lot of
C0330 warnings (hanging/continued indentation). Fix
the ones in neutron/db.
Trivialfix
Change-Id: I9311cfe5efc51552008072d84aa238e5d0c9de60
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
With [1] gateway is no longer set for subnet created
with prefix delegation, but when adding the subnet
to the router it fails as it expects gateway to be
set.
This patch ensures gateway is set temporary to the first IP
of the subnet as it used to be just like the temporary CIDR.
Also need to ensure dhcp configuration is skipped to avoid the
original issue[2].
[1] https://review.opendev.org/c/openstack/neutron/+/699465
[2] https://bugs.launchpad.net/neutron/+bug/1856675
Closes-Bug: #1962306
Related-Bug: #1856675
Change-Id: I512f7d98ac99bb0ef06fd2acba09482e3436d18d
Don't eagerly load several fields which are not used in
port list and show.
Port list and show speed-up is ~10-25%.
Depends on neutron-lib change:
https://review.opendev.org/c/openstack/neutron-lib/+/788729
Change-Id: I4bfcac16a54b766e0dc97f58ba4048eb709fa88f
There is no need to fetch the whole net object
(which leads to several heavy DB requests according
to OSProfiler stats) when only need to check net existence
This speeds up port creation up to 15%
Closes-Bug: #1917866
Change-Id: I75db7c713a17a0f1b1b5aecc6eec93e636a71827
Use case: many trunk ports (300+) each with many subports.
Issue: get_ports takes much time.
Solution: apply trunk resource extend func for a full list of ports,
not for each port individually, thus avoiding a DB query for each
trunk port.
The approach will be extended for other resource extenders, like QoS,
and probably for other resources as well.
QoS: https://review.opendev.org/c/openstack/neutron/+/764454
Change-Id: Ic08e4049f6156c0700ca3c7aee251b6eb0eb97da
Closes-Bug: #1905268
Included standard attributes ID in some OVO dictionaries to improve
the OVN revision numbers operation. Having this ID, there is no need
to retrieve it from the database.
The following OVOs have been updated:
- port
- network
- subnet
- security group
- security group rule
- router
Closes-Bug: #1904188
Change-Id: Ia16335a2fc8f9324b9489692c76a73e4ef5bef96
Since the mtu is already non-nullable, the writer context
can be switched to a reader context. In addition, the redundant
reader context can be removed.
Change-Id: I482a3892dee8ee94ab70142cf734f71e766178ed
Closes-Bug: #1859258
Implements Conntrack Helper service plugin for conntrack
helper resources. Supports create, update and delete
conntrack helper for l3 routers.
A new configuration option:
[l3-conntrack-helpers]/allowed_conntrack_helpers
introduced to allow the operator to configure CT
helpers, and the helper protocol constraints.
Related-Bug: #1823633
Depends-On: https://review.opendev.org/663446
Change-Id: I58193955261f50b18b1946261fe662da6b20f0f5
Save order by in port query when not require fixed_ips,
and save some useless query for dvr subnet mac.
Closes-Bug: #1834308
Change-Id: I6836840edcaa5a21fd2ba9f65ffd24f7e5038fa3
Bulk ports were not binding correctly when they were created. This is
due to a few inconsistencies between the create_port code and the
create_port_bulk code, mostly a result of the use of the Port object in
the bulk code.
Change-Id: I3bcd3cec12b1b6f6a568cda4bfeb569f636efb98
Closes-Bug: #1835209
Use netaddr.IPNetwork to convert CIDRs in a query
into proper subnets.
When creating subnets the CIDR is converted into
a proper subnet. i.e a subnet can be created with
cidr=10.0.0.11/24 in the create request. On create
the cidr is turned into a proper subnet resulting
in a subnet with cidr=10.0.0.0/24.
This change does the same to CIDRs when used as
query filters during a list subnet request, so
that the same value that was used to create the
subnet can be used to find the subnet.
Closes-Bug: #1831811
Change-Id: I8ae478a03ceedc6c3b1ae1d40081b5e5158813e6
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
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
The bulk port code uses the Port OVO object, which encodes MAC address
as a netaddr.EUI object. The default string representation for a
netaddr.EUI object is the standard IEEE EUI-48 format
("XX-XX-XX-XX-XX-XX") [1]. Having MAC addresses in that format breaks
the midonet gate, so revert to UNIX standard mac addresses
("xx:xx:xx:xx:xx:xx").
[1] https://netaddr.readthedocs.io/en/latest/tutorial_02.html#formatting
Change-Id: I2d2727335c347accdeb39cbac5151722e8a3339c
Closes-Bug: #1822999
Rather than iterating through all ports and leveraging the heavyweight
ml2 method, use a set of optimized functions that attempts to make bulk
port operations as speedy as possible.
The test test_bulk_ports_before_and_after_events_outside_of_txn is
deleted because with the change to using port OVO, the session will
not be closed, and it is not correct to check for it.
Change-Id: Ieea0e6074cd31a2d09ae92f1f3c8d375c6d8ecc2
Implements: blueprint speed-up-neutron-bulk-creation
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>
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
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
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
The bulk port creation scenario requires the ability to generate
multiple MAC addresses for the bulk added ports. This change leverages
the code added in [1] to make bulk MAC creation available.
[1] https://review.openstack.org/510830
Implements: blueprint speed-up-neutron-bulk-creation
Depends-On: https://review.openstack.org/613149
Change-Id: Ia769dadf69781ba511a19c52998949b668963a19
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
The APIs our consumers are using from neutron.db_utils were rehomed into
neutron-lib with https://review.openstack.org/#/c/540161/
This patch consumes them by removing the rehomed APIs and using lib's
implementation where applicable.
NeutronLibImpact
Change-Id: I7ee53bce917feae8e37bf278eb3121a5af47131c
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
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
This patch switch to use Subnet OVO in
ipam_backend_mixin.IpamBackendMixin._save_subnet
method.
To use Subnet OVO there, additional changes in _make_subnet_args()
method are also required. Now this method returns:
* 'project_id' instead of 'tenant_id',
* 'cidr' as instance of netaddr.IPNetwork,
* 'gateway_ip' as instance of netaddr.IPAddress
Change-Id: I9fb284e98394b1a41ec8af919b65dc512663ff6a
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
This reverts commit 1470baf02b.
As Neutron uses own objects registry this commit should be safe
to merge again and it shoudn't break projects like midonet.
Change-Id: I51833eebb4b24207f395e1d4095b1809f191a480
This patch integrates Port OVO in db/db_base_plugin_common.py and
other two files, except for _get_port() which results in changes
in a large scale and will be taken care of in following patches.
Change-Id: Ia19996d7fb3f09a63ed0f392e013bed422b5eebe
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Automatically allocated fixed IP addresses were not reflected on cached
port records, which triggered FlushError if the allocating method failed
and triggered a retry.
Change-Id: Ia7725094827b554aa6d928c7daa026959a237991
Closes-Bug: #1706750
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
This patch integrates the Oslo-Versioned Object created for
IPAllocation model class.
Change-Id: Ibb731c4635d89c848081fac73f216d2ecf10b599
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
This refactoring is a step towards the goal of removing the
CommonDbMixin mixin class.
Related-Blueprint: neutron-lib
Change-Id: I1e2da0687310cc2da767dc2a6d13500307bba1ee
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