Commit Graph

61 Commits

Author SHA1 Message Date
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 3cae410b30 use payloads for PORT AFTER_DELETE events
This patch switches over to callback payloads for PORT
AFTER_DELETE events.
Some shims were removed.

Change-Id: If69e37b84fe1b027777b1d673b3d08a6651a979e
2021-07-11 06:00:08 +00:00
Nurmatov Mamatisa 129b823a8b use payloads for PORT AFTER_UPDATE events
This patch switches over to callback payloads for PORT
AFTER_UPDATE events.

Change-Id: I5c00eae155afa6c0fc8e3956bc39edbeca3ea1e7
2021-07-07 21:01:24 +00:00
Nurmatov Mamatisa cd8c4f7e30 use callback payloads for SUBNET
This patch switches over to callback payloads for
SUBNET events.

Change-Id: Ic4c3490aed4f899293be993d4663bb537c34ab8b
2021-06-24 00:14:52 +03:00
Zuul df94641b43 Merge "use payloads for PORT AFTER_CREATE events" 2021-06-07 14:19:26 +00:00
Nurmatov Mamatisa c9fce3a8b6 use payloads for PORT AFTER_CREATE events
This patch switches the code over to the payload style of callbacks [1]
for PORT AFTER_CREATE events. In addition it adds a branch/shim to the
dhcp_rpc_agent_api to support both payload and kwarg style callbacks.

NeutronLibImpact

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

Change-Id: I25d43d4f8f2390b07e0d11c631f894d88669bbe0
2021-06-03 18:43:30 +00:00
Oleg Bondarev f52280287f Improve Subnet create performance
- pass network dict from ml2 plugin to _create_subnet_postcommit
- skip ipam subnet fetch for non ipv6 auto-address subnets
- don't count subnets (DB request) if subnet has no segment

Change-Id: Iaecfda2700c5316cb25a93496d24ece366e40a4a
2021-05-21 15:03:52 +00:00
Rodolfo Alonso Hernandez 7f40e626d6 Delete segment RPs when network is deleted
When a network is deleted, only one Placement call per segment
is done to remove the associated (if existing) resource provider.

Before this patch, each time a subnet was deleted, the segment
resource provider was updated. When no subnets were present in the
related segment, the associated resource provider was deleted.

This optimization improves the network deletion time (see Launchpad
bug). E.g.: a network with two segments and ten subnets, the Neutron
server processing time dropped from 8.2 seconds to 4.4 seconds (note
that the poor performance was due to the modest testing environment).

Along with the segment RP optimization during the network deletion,
this patch also skips the router subnet update. Because all subnets
in the network are going to be deleted, there is no need to update
them during the network deletion process.

Change-Id: Ifd50027911a9ca3508e80e0de9a6cc45b67006cf
Closes-Bug: #1878916
2020-05-25 09:10:41 +00:00
Zuul 41835d8462 Merge "Improve port retrieval when validating auto address" 2020-04-20 17:46:44 +00:00
Rodolfo Alonso Hernandez 2ccddef913 Improve port retrieval when validating auto address
Improve port retrieval in method
"_validate_auto_address_subnet_delete". Instead of requesting each
port individually, a single DB query is executed to retrieve all
the ports with IP allocation in a in a subnet.

Change-Id: I7875142ebecd17663e17847fb14997200d7ae5c8
Related-Bug: #1865138
2020-04-14 12:50:49 +00:00
Brian Haley 07b015d789 Use dict .get() to avoid a KeyError in the segment plugin
On subnet delete, the supplied subnet in the post hook
could contain a subnet without certain items, leading to
a KeyError in the segment plugin.  Fix a number of these
occurences so this cannot happen.

Also fixed similar code in the segment tests.

Change-Id: I645610febde446b78ed6edd868e699673648a4de
Closes-bug: #1868724
2020-03-24 14:10:38 -04:00
Harald Jensås f987486feb Deny delete last slaac subnet with allocation on segment
When a port has only one IP allocation on auto-allocation
subnet which is associated with a segment, do not allow
the delete of the subnet. Raise SubnetInUse exception instead.

Related: rhbz#1803989
Related-Bug: #1864225
Related-Bug: #1864333
Closes-Bug: #1865138
Change-Id: I9fb0f05ede42afa1a349635b1936028edf540a1f
2020-03-17 22:02:33 +01:00
Brian Haley b46dbce219 Fix logging call in the segment plugin
Arguments should be separate, not a tuple, else we'll
get a traceback.

Change-Id: I142fa1119c15076708a64991adfe30cb8ce38ea3
Closes-bug: #1865098
2020-02-28 09:49:29 -05:00
Bence Romsics c5b7817fd0 Follow up to change of exception raised
The patch in the Depends-On line changed the class of an exception
raised in neutron-lib. This change adapts neutron code where we expected
the exception changed.

Change-Id: I34f7d2aab0af0b985d9165465fe9e7c656041745
Depends-On: https://review.opendev.org/695205
2020-01-21 14:24:25 +01:00
elajkat 12ab7c4cb1 segments: fix rp inventory update
The patch https://review.opendev.org/663980 made resource provider
inventory update failing with the assumption that inventory update
expects a dict with a key of the resource class, like resource provider
inventories update.
See the placement API-ref:
https://developer.openstack.org/api-ref/placement/#update-resource-provider-inventory
https://developer.openstack.org/api-ref/placement/#update-resource-provider-inventories

Change-Id: I7de1a947b864eb5ac57ebaca895f827d2e667443
Closes-Bug: #1836037
Related-Bug: #1828543
2019-07-10 17:20:22 +02:00
elajkat 95023227b7 segments: Fix resource provider inventories update
Related-Bug: #1828543
Depends-On: https://review.opendev.org/663978
Change-Id: I4275779bd8d353fbaa80c646515819b0a34edebb
2019-06-11 16:49:31 +02:00
elajkat 62f55a12b0 Force segments to use placement 1.1
By documentation segments plugin was designed to use placement
microversion 1.1, force to use that.

Change-Id: Ibb8d6bcce7f0fe1070b9eeb2ad632dfb58a3a015
Depends-On: https://review.opendev.org/663978
Related-Bug: #1828543
2019-06-07 17:23:03 +02:00
Boden R 99e3999975 use publish for SEGMENT_HOST_MAPPING callback events
This patch switches over to payload style callbacks for all
SEGMENT_HOST_MAPPING events.

NeutronLibImpact

Change-Id: I71888b2b72b486c32991d651cdc608adb2149500
2019-05-06 10:40:03 -06: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
Dirk Mueller 04f23958e6 Avoid iterating over all of the segment data just for counting
getting the full collection (which includes iterating over it
and populating attributes) just to gather the count of it
is wasteful. we can just use the count api.

Change-Id: I1b216cb2c8c5b612f12554454d5721a14975f138
Closes-Bug: #1821708
2019-03-26 11:20:16 +01: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 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 24eb49c55b segments use neutron_lib placement client
Originally segments extension used it's own placement client.
Now in neutron-lib there is a working actively designed and  tested
client for placement, thus we can change segments to use that, and
remove the old placement client from neutron.

Change-Id: I2e7b53fdedb1837ddb0d685718d9a811ddac5733
Depends-On: https://review.openstack.org/580665
2018-11-20 08:33:59 +00:00
Boden R ddc72ebd41 use payloads for SEGMENT BEFORE_DELETE callbacks
This patch switches over to the payload style of callbacks for SEGMENT
BEFORE_DELETE events. It does so by using the publish callback function
with DBEventPayload payloads. Corresponding listener callbacks are
updated where necessary.

NeutronLibImpact

Change-Id: I64031129ad458d4468a316a9385288ced091d333
2018-11-16 10:57:21 -07: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
Harald Jensås 8361b8b5ae Routed Networks - peer-subnet/segment host-routes (2/2)
Ensure that host routes are maintained for each subnet within
a network. Subnets associated with different segments on the
same network get host_routes entries added/removed as subnets
are created, deleted or updated.

This change handle the host_routes for the peer subnets on the
same network when a subnet is created or deleted.

Also adds a shim api extension.

APIImpact: Host routes are now calculated for routed networks.
Closes-Bug: #1766380
Change-Id: Iafbabe6352283e7f1a535a7b147bd81fb32f0ed1
2018-06-28 10:48:06 +02:00
Harald Jensås 8d580dc037 Routed Networks - peer-subnet/segment host-routes (1/2)
Ensure that host routes are maintained for each subnet within
a network. Subnets associated with different segments on the
same network get's host_routes enties added/removed as
subnets are created, deleted or updated.

This change handle the host_routes for the subnet that is
created or updated.

Partial-Bug: #1766380
Change-Id: If6792d121e7b8e1ab4c7a548982a42e69023da2b
2018-06-26 23:47:14 +02:00
Harald Jensas b6d117fcd5 Allow setting network-segment on subnet update
To enable the possibility to migrate a non-routed network to a
routed network allow updating the segment_id of a subnet.

Only allow the operation if:
 - The network only has one segment
 - The network only has one subnet
 - The current segment_id == None

APIImpact: The segment_id attribute of subnets now allows put operation.
Closes-Bug: #1692490
Depends-On: Iffda823a149a1143f46ee9a05e9640b34bf42c51
Change-Id: I1aee29dfb59e9769ec0f1cb1f5d2933bc5dc0dc5
2018-05-24 01:09:02 +02:00
Zuul 805359d9a2 Merge "Fix all pep8 E129 errors" 2018-05-04 00:16:32 +00: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
Hongbin Lu 07b0dbf550 Convert Segment db model to OVO
Depends-On: Ia05df925eccf3c9d397748f282e995203a058de9
Change-Id: I1c2066e41d3b542ab44aaf9af4e4765f88738b2d
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
2018-04-27 15:36:05 +00:00
Hongbin Lu e36a2bd65c Move standard-attr-segment to service plugin
Standard attributes was added to segment resource at [1].
In [2], a shim extension standard-attr-segment was added to ml2
plugin to indicate this change, but this extension should be
placed to segment service plugin instead. This commit fixes it.

[1] https://review.openstack.org/#/c/558318/
[2] https://review.openstack.org/#/c/562320/

Change-Id: I5b0a6bafd1e3f4552e32809a449868d7a5868739
Closes-Bug: #1765008
2018-04-24 14:59:23 +00:00
Zuul 331b4f3425 Merge "Enable sorting and pagination for segments" 2018-04-23 12:56:57 +00: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
Hongbin Lu 43d451d86f Enable sorting and pagination for segments
It looks the sorting and pagination are natively supported in
segment db layer but the segment controller doesn't mark these
features as supported. This patch fixes it.

Change-Id: I325396bb0256196ee6c6fc42cc812a0c75ae3827
Closes-Bug: #1763161
2018-04-13 21:51:18 +00:00
Boden R 2b3fdc871c remove unused common exceptions
This patch removes a handful of unused exceptions from
neutron.common.exceptions as follows:

The following exceptions already live in neutron-lib and are thus
duplicates in neutron:
PlacementEndpointNotFound
PlacementResourceProviderNotFound
PlacementInventoryNotFound
PlacementAggregateNotFound
PlacementInventoryUpdateConflict
NetworkVlanRangeError
PhysicalNetworkNameError
MacAddressGenerationFailure

The following exception is not used anywhere today:
TenantNetworksDisabled

NeutronLibImpact

Change-Id: Ie8227954681292ead1da0dedc950c54028ce84f1
2018-04-09 15:08:05 -06:00
Ryan Bridges 0f4d7ff527 Catch Errors When Nova API Microversions Are Not Supported
Currently, errors related to lack of microversion support are completely
masked because of the way eventlet.spawn_n() works. These changes
improve error handling so that deployers are explicitly notified when
Nova API microversions are not supported. This is useful because without
microversion support, the entire flow will break and hosts will not be
associated with segments properly. Deployers will have no idea why
because errors are not printed to log files setup by the standard Python
logging framework.

Related-Bug: #1759004
Change-Id: I9c6151ffa90394612e7f81ededd4a309dd8ab7fb
2018-03-27 08:11:54 -07:00
Boden R 7a722159f3 use ip allocation api def from neutron-lib
The IP allocation extension's API definition was rehomed into
neutron-lib with commit Ifebe1d5e623a16ae46598c19b7d904fe913ce2d3
This patch consumes the API definition by removing the rehomed code and
using the APIExtensionDescriptor for the extension class.

NeutronLibImpact

Change-Id: Ic44c55f6aa2c6ea8f67f9d17e904ad695ff655df
2017-11-09 13:02:01 -07:00
Boden R 4dce3f5dbb use l2 adjacency api def from neutron-lib
The l2 adjacency extension's API definition was rehomed into neutron-lib
with commit Iecc36b68693cc6f69765e31ed37292b4690a9b75. This patch
consumes the API definition removing the rehomed code from neutron
and updating references to use lib's code.

NeutronLibImpact

Change-Id: I55af489b4f95720d5bfac015ff454eca02609545
2017-11-03 13:10:48 -06:00
Inessa Vasilevskaya 7322bd6efb Make code follow log translation guideline
Since Pike log messages should not be translated.
This patch removes calls to i18n _LC, _LI, _LE, _LW from
logging logic throughout the code. Translators definition
from neutron._i18n is removed as well.
This patch also removes log translation verification from
ignore directive in tox.ini.

Change-Id: If9aa76fcf121c0e61a7c08088006c5873faee56e
2017-08-14 02:01:48 +00: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
Boden R 0e2b667bf1 use neutron-lib callbacks
The callback modules have been available in neutron-lib since commit [1]
and are ready for consumption.

As the callback registry is implemented with a singleton manager
instance, sync complications can arise ensuring all consumers switch to
lib's implementation at the same time. Therefore this consumption has
been broken down:
1) Shim neutron's callbacks using lib's callback system and remove
existing neutron internals related to callbacks (devref, UTs, etc.).
2) Switch all neutron's callback imports over to neutron-lib's.
3) Have all sub-projects using callbacks move their imports over to use
neutron-lib's callbacks implementation.
4) Remove the callback shims in neutron-lib once sub-projects are moved
over to lib's callbacks.
5) Follow-on patches moving our existing uses of callbacks to the new
event payload model provided by neutron-lib.callback.events

This patch implements #2 from above, moving all neutron's callback
imports to use neutron-lib's callbacks.

There are also a few places in the UT code that still patch callbacks,
we can address those in step #4 which may need [2].

NeutronLibImpact

[1] fea8bb64ba7ff52632c2bd3e3298eaedf623ee4f
[2] I9966c90e3f90552b41ed84a68b19f3e540426432

Change-Id: I8dae56f0f5c009bdf3e8ebfa1b360756216ab886
2017-04-26 12:12:53 -06: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
Ann Kamyshnikova cf34df8572 New enginefacade for networks, subnets.
Usage reader and writer for db operations.

In Neutron code we have common situation like:

with context.session.begin():
   context.session.add(obj)

self._make_obj_dict(obj)

With new enginefacade we change context.session.begin() for
db.context_manager.writer(reader).using(context).

When object leaves this with-block, its reference to session is
cleared because session is discarded. To use this object later to
load some data from its dependencies, we have to provide different
session to work in. To solve this obj either can be moved under
with-block or we have to do context.session.add(obj) one more time
to be able to load relations.

This change also switches to usage of new enginefacade for some db
operations with ports, in order to pass unit and functional tests.

Partially-Implements blueprint: enginefacade-switch

Change-Id: Ia15c63f94d2c67791da3b65546e59f6929c8c685
2017-03-30 01:26:45 -07:00
Cedric Brandily e4495bfe0a Use @registry.receives in neutron.services.segments.plugin
Switch to registry.receives decorator in neutron.services.segments.plugin.

Change-Id: Ic9b5a2ce2b1dac2ed912a72c9698d19c2cf4ce9d
Partial-Bug: #1668262
2017-03-15 04:32:20 +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
Ihar Hrachyshka 88e99f6f28 Clean up deprecated sqla model import paths
Those were moved under neutron.db.models start of Ocata. We should be
able to clean them up now.

NeutronLibImpact

Change-Id: Iadbf44d52ee8e30712807384152a29ce1a8b8f72
2017-02-25 03:42:34 +00:00
Jenkins c9f83dcaa8 Merge "Skip segment checks during network delete operations" 2017-02-22 09:29:24 +00:00
Kevin Benton dbadf7b2ed Skip segment checks during network delete operations
These checks aren't necessary when triggered as part of a
network delete operation since any remaining subnets and ports
will be removed from the network. Additionally, they can race
with the auto cleanup methods for ports and subnets if segment
deletion is moved to BEFORE_DELETE where it should be.

Change-Id: I996f5b22f5179f5540760cc05c9f091bb3f3069b
2017-02-06 16:12:20 -08:00
Miguel Lavalle 5cbdd10b21 Routed networks IPv4 inventory in Nova GRP
Using Nova's generic resource pools (GRP) API, publish routed networks
IPv4 inventory. This inventory is then used by the Nova scheduler to
place instances based on the availability of IPv4 addresses in
routed networks segments.

Change-Id: Ib6b00c4889d6a34765844ce46280819dff0108c5
Partially-Implements: blueprint routed-networks
2017-01-20 15:32:35 -06:00