Commit Graph

60 Commits

Author SHA1 Message Date
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
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
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
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 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
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 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
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 839e575fa6 use plugin utils from neutron-lib
The remainder of the neutron.plugins.common.utils were rehomed into
neutron-lib with [1][2]. This patch consumes them by using the functions
from neutron-lib, and removing the neutron.plugins.common.utils module
all together as it's fully rehomed now.

NeutronLibImpact

[1] https://review.openstack.org/#/c/560950/
[2] https://review.openstack.org/#/c/554546/

Change-Id: Ic0f7b37861f078ce8c5ee92d97e977b8d2b468ad
2018-07-12 08:13:05 -06:00
Boden R 6a89dd2feb use db utils from lib
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
2018-07-02 08:24:36 -06:00
Boden R 537bfb9a1c use callback payloads for PRECOMMIT_UPDATE events
This patch switches callbacks over to the payload object style events
[1] for PRECOMMIT_UPDATE based notifications. To do so a DBEventPayload
object is used with the publish() method to pass along the related data.
In addition a few UTs are updated to work with the changes. Finally
a few shims are put into place to allow PRECOMMIT_UPDATE based events to
use payloads while still supporting the existing kwarg style events.

NeutronLibImpact

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

Change-Id: Ie6d27df01cd7b87894efc80946d41eb1ebe25bef
2018-03-13 11:38:19 -06:00
Hongbin Lu 8c6512fab4 Use constant 'IS_DEFAULT' from neutron-lib
Change-Id: I51cf78cfd681acca5888fa29cb3e24a4207abd7e
2018-01-08 09:14:17 +00:00
Boden R 54444407f4 use l3 api def from neutron-lib
Commit I81748aa0e48b1275df3e1ea41b1d36a117d0097d added the l3 extension
API definition to neutron-lib and commit
I2324a3a02789c798248cab41c278a2d9981d24be rehomed the l3 exceptions,
while Ifd79eb1a92853e49bd4ef028e7a7bd89811c6957 shims the l3
exceptions.

This patch consumes the l3 api def by:
- Removing the code from neutron that's now in lib.
- Using lib's version of the code where applicable.
- Tidying up the related unit tests as now that the l3 api def from lib
is used the necessary fixture is already setup in the parent chain when
setting up the unit test class.

NeutronLibImpact

Change-Id: If2e66e06b83e15ee2851ea2bc3b64ad366e675dd
2017-12-15 07:03:14 -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
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 0a1405794f use service type constants from neutron_lib plugins
The well known service type constants are in
neutron_lib.plugins.constants, but for legacy reasons a few still exist
and are referenced from neutron_lib.constants that we'd like to remove.
This patch switches references over to neutron_lib's plugin constants.

Change-Id: I1861448cec303725b30cef8f42029f467f9e03a3
2017-06-27 15:16:05 -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
Kevin Benton 59589929e5 Use NETWORK callbacks in get-me-a-network code
This adjusts the get-me-a-network code to just
rely on the regular NETWORK precommit events rather
than the EXTERNAL_NETWORK events that the following
patch eliminates.

Partial-Bug: #1678041
Change-Id: Id2db458f4688e4aa4c70ccdb09867b9a66de28ea
2017-04-18 18:25:51 -07: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
Armando Migliaccio ea27e1aa1e Update is_default field only when specified in the request
Closes-bug: 1670524

Change-Id: Ie46fe7126693bcf6732332a479f4b2609c402c5d
2017-03-07 18:57:33 -08:00
Ankur Gupta 55090400ad OVO External Networks
This patch introduces and implements Olso-Versioned Objects for
network extension External Networks.

There were joined performed to order the fetching of external
networks by standard attribute which seems useless because,
in networks/services/auto_allocated/db.py while fetching
external networks it logs error when multiple networks are
returned. Expected default external network there is one, so
ordering does not make much sense.

Co-Authored-By: Manjeet Singh Bhatia <manjeet.s.bhatia@intel.com>
Co-Authored-By: Victor Morales <victor.morales@intel.com>

Change-Id: Iad609f72945b84df7881b43d1fdf9a188e5816bc
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
2017-03-07 20:03:30 +00:00
Kevin Benton 5dabde032f Switch external network create event to precommit
This addresses a TODO to convert the notification event to
PRECOMMIT_CREATE instead of BEFORE_CREATE and AFTER_CREATE since
both of these are occuring in a transaction which violates the AFTER
semantics.

Change-Id: Idba21275ade85a1a4afadee00de9ccbaec49b2f9
2017-03-01 13:02:45 +00:00
Mohit Malik 39c74b0533 Add OVO for AutoAllocatedTopology
This patch integrates and implements Oslo-Versioned Objects for Auto
Allocated Topology.

Change-Id: I478af7aa118a947cc9eab36b047cecea6ddd5170
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Co-Authored-By: Anindita Das <anindita.das@intel.com>
2017-01-17 14:24:10 -06:00
Armando Migliaccio 17563a802e Adopt neutron-lib plugin directory
Neutron Manager is loaded at the very startup of the neutron
server process and with it plugins are loaded and stored for
lookup purposes as their references are widely used across the
entire neutron codebase.

Rather than holding these references directly in NeutronManager
this patch refactors the code so that these references are held
by a plugin directory.

This allows subprojects and other parts of the Neutron codebase
to use the directory in lieu of the manager. The result is a
leaner, cleaner, and more decoupled code.

Usage pattern [1,2] can be translated to [3,4] respectively.

[1] manager.NeutronManager.get_service_plugins()[FOO]
[2] manager.NeutronManager.get_plugin()
[3] directory.get_plugin(FOO)
[4] directory.get_plugin()

The more entangled part is in the neutron unit tests, where the
use of the manager can be simplified as mocking is typically
replaced by a call to the directory add_plugin() method. This is
safe as each test case gets its own copy of the plugin directory.
That said, unit tests that look more like API tests and that rely on
the entire plugin machinery, need some tweaking to avoid stumbling
into plugin loading failures.

Due to the massive use of the manager, deprecation warnings are
considered impractical as they cause logs to bloat out of proportion.

Follow-up patches that show how to adopt the directory in neutron
subprojects are tagged with topic:plugin-directory.

NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I7331e914234c5f0b7abe836604fdd7e4067551cf
2016-11-23 04:45:33 -07:00
Henry Gessau 8f80a52b01 Refactor/prepare db common utils for neutron-lib
Extract all the common utils from common_db_mixin.py in preparation
for moving them to neutron-lib.

This is a preliminary step in preparation for refactoring the
CommonDbMixin class and moving it to neutron-lib also.

Partial Blueprint: neutron-lib

Change-Id: I3cba375a8162cb68e8f988f22f5c8b1ce7915180
2016-10-28 10:53:11 -04:00
Manjeet Singh Bhatia 276015788a Relocate external network db models
This patch will relocate external network db models
and separate it from mixins for OVO implementation.

Change-Id: I83e2c7bbab3bd59cc9d2af71c66c0662c7724ecc
Partial-Bug: #1597913
2016-09-29 17:51:39 +00:00
Jenkins 8a03808ebc Merge "Demote error trace to debug level for auto allocation operations" 2016-09-16 21:14:02 +00:00
Jenkins 27eccafa5b Merge "Make DHCP notifier use core resource events" 2016-09-14 21:11:53 +00:00
Kevin Benton 181bdb374f Make DHCP notifier use core resource events
This makes the notifier subscribe to core resource events
and leverage them if they are available. This solves the
issue where internal core plugin calls from service plugins
were not generating DHCP agent notifications.

Closes-Bug: #1621345
Change-Id: I607635601caff0322fd0c80c9023f5c4f663ca25
2016-09-14 00:40:09 -07:00
Armando Migliaccio 42b574edb8 Demote error trace to debug level for auto allocation operations
Based on how Nova calls into this extension, it is clear that this
'error' shows during normal conditions of booting  multiple VMs for
the same tenant. Plus, there is nothing the operator can do as the
plugin hopefully takes care of it all.

Change-Id: I6747e64903f8e57ddadcf2d1c74d223fb4fdf97d
2016-09-13 14:54:15 -07:00
Kevin Benton a4ccc0ce1c Move retry decorator in auto allocate
No longer necessary on cleanup since individual plugin operations
are protected but it should be on _ensure_network_default_value
callback since it can happen outside of a transaction.

Partial-Bug: #1612798
Change-Id: Iab4f2216e6b138296e8245eb0b1e3e6b5e46561b
2016-09-09 09:00:48 +00:00
Jenkins c73db63af8 Merge "Ensure UnknownProvisioningError can be printed" 2016-09-08 15:29:07 +00:00
Armando Migliaccio 047c0b5293 Ensure UnknownProvisioningError can be printed
Implement __str__ to show the underlying error during log
traces.

Change-Id: I829d787ba0d8666b09abc0307abb47fe9699c247
Related-bug: #1612798
2016-09-08 12:50:48 +00:00
Kevin Benton fef301979e Don't return ext net DB object in auto allocate
Returning a DB object for the external network and passing
that to the create_router operation makes the life of the
DB object transition many operations. If any of those operations
detech it from the session or expire it, it can result in
an exception down in the router operations.

This patch just returns the network ID since that's all we need.

Closes-Bug: #1616126
Change-Id: Ib9c4ba9f00ca7f7a713a89be4f75a230b086ac38
2016-09-07 18:18:28 -07:00
Armando Migliaccio e2fdeefd37 Deal with unknown exceptions during auto allocation
Uncaught exceptions in the core or L3 plugin layers can cause the
auto_allocate plugin to fail unexpectedly. This patch ensures that
any unexpected error is properly handled by cleaning up half
provisioned deployment.

Related-bug: #1612798
Closes-bug: #1619497

Change-Id: I3eb9efd33363045f7b2ccd97fe4a48891f48b161
2016-09-02 15:37:23 +00:00
Henry Gessau 61cc14fd67 Switch to neutron-lib for model_base
Change-Id: If5b2b4cc0346515ddef3da1255ab49327c8e5732
2016-08-31 11:12:18 -04:00
Gary Kotton 8fdc430e62 Auto allocation: ensure that networks and subnets are cleaned up
In the event of a router create failure we need to make sure that
the allocated resources are cleaned up.

When router allocation fails it is difficult for an admin to
understand the root cause. Adding the exception here will provide
a little additional information.

Closes-bug: #1617707

Change-Id: I41940bea0327ee31494bd95867d0e60d9b5a24b8
2016-08-29 08:42:03 -07:00
Kevin Benton bdd7298284 Move standard attr out of model_base
The model_base file is going to move to Neutron lib in
I2087c6f5f66154cdaa4d8fa3d86f5e493f1d24d9. This will mainly leave
behind only the standard attributes related stuff so the name
'model_base' won't make much sense. This moves the standard attribute
related things into its own module so model_base can conceivably be
eliminated entirely.

Change-Id: Icaf3220fbc5723f2b5421a494371ef274d7073c7
2016-08-27 17:46:38 -04:00
Armando Migliaccio 960eae574b Catch SubnetAllocationError during auto-allocated-topology provisioning
When uncaught, the auto_allocated_network stays behind. This patch
ensures the error is handled properly and the network is indeed
cleared when the subnetpool runs out of space.

Closes-bug: #1616250

Change-Id: Ic6e06d3e6c16a58977e84b371c3faaba66c9603b
2016-08-23 16:55:52 -07:00
Armando Migliaccio dfa702fac8 Implement the DELETE method for get-me-a-network
Review [1] showed how tricky it can be to let the client
side deal with auto-network-topology cleanups. Rather than
pushing this complexity to the client, we should implement
the DELETE method for this extension, as it's rather
trival to do on this server side.

Since the DELETE method is exposed, but it fails with 500,
it is reasonable to deal with this as a bug fix, rather than
having to go through yet another extension. The neutronclient
side support should be added, but since the first user of this
is Tempest, we can safely assume they can leverage this directly
without depending on a python-neutronclient version bump.

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

Closes-bug: #1614872

Change-Id: I2fba51bdf8c781fcc0449e1e9947de976c96eec4
2016-08-22 17:59:34 -07:00
Kevin Benton 11849b7279 Make auto allocate cleanup retry
This adds a retry decorator to the auto allocate cleanup logic
so it can handle retriable errors during cleanup. It also adds
catches for notfound errors to make the function idempotent so
it works on retries.

Change-Id: I3d62af3018fb834ec85771d8bc8e7379cc80b72a
Closes-Bug: #1615710
2016-08-19 21:04:15 -07:00
Armando Migliaccio aa42906143 Make auto-allocate plugin handle sneaky DB errors
DB errors or retry exceptions that bubble up to the
plugin may get masked by integrity violation errors
due to partial provisioning of resources. When that
happens, we should make sure any pending resource
is cleaned up before reattempting the operation.

Closes-bug: #1612615

Change-Id: I76e9f8e4b61fb3566d70af4236c19e4c5a523646
2016-08-12 15:27:41 -07:00
Dariusz Smigiel df9411dc11 Rename DB columns: tenant -> project
All occurences of ``tenant_id`` across the database are renamed
to ``project_id``. Both options are equally valid, but ``project_id``
is preferred.
To inform external users about the change, HasTenant class was
deprecated.

UpgradeImpact
Partially-Implements: blueprint keystone-v3

Change-Id: I87a8ef342ccea004731ba0192b23a8e79bc382dc
2016-08-03 14:34:37 +00:00
Jenkins 6e3b453ebb Merge "Fix simple typos" 2016-06-28 01:30:19 +00:00
karimb d1a0945f0a Fix simple typos
This commit fixes simple typos.

Change-Id: Ia90452f113e9e8a38b0bb27cd106b84afc8a78d1
2016-06-24 16:41:46 +02:00
Armando Migliaccio d91a4e1930 Create auto allocated networks in disabled state
Under particular circumstances, multiple requests to the
auto-allocated-topology extension may lead to the transient
creation of duplicated resources. This is dealt with by the
service plugin code, which cleans them up once the condition
is detected. However the client may accidentally be impacted
and potentially left in error (recoverable on retry).

In order to address this error condition, the logic to
provision the network for any given tenant is tweaked
slightly so that the network is created in disabled state
and re-enabled when it is safe to do so. A Neutron client
should check the network status to see if the network is
ready for use before getting its hands on it.

Closes-bug: #1591766

Change-Id: Ia6ff5ad975673875216eb470080dfc0dcf6b9ab2
2016-06-24 00:42:42 -07:00
Brandon Logan c40403eee0 Make service plugins' get_plugin_type classmethods
Any service plugin that implements the get_plugin_type method should
make it a classmethod.  It should not need to be instantiated to
retrieve the simple constant it returns in every case.

Change-Id: Ia3a1237a5e07169ebc9378b1cd4188085e20d71c
Closes-Bug: #1590117
2016-06-07 15:33:07 -05:00