Commit Graph

85 Commits (b79842f289f0c9b9fdce9d6cc689538ec61216e7)

Author SHA1 Message Date
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.


Change-Id: I9704f20eb21da85d2cf024d83338b3d94593671e
2019-02-01 14:35:00 -07:00
Brian Haley 90cd939047 Fix W503 pep8 warnings
Fix W503 (line break before binary operator) pep8 warnings
and no longer ignore new failures.


Change-Id: I7539f3b7187f2ad40681781f74b6e05a01bac474
2018-04-17 14:22:58 +00:00
Thomas Morin 605364ad78 Support that an extension extends a sub-resource
The neutron.api.extensions code assumes that the resource to update are
base resources and updates its dictionary. When the resource
is a sub-resource, ie. a {'parent': ... , 'parameters': {..} } dictionary,
the result of the update is that the content of 'parameters' is

The correct thing to do here, in the case where the extended resource is
a sub-resource, is to update the content of parameters with the new/changed

This change also removes a workaround that was made in
the qos-bw-limit-direction extension, and which after the change in API
extension code, is not needed anymore.

Needed-By: I263e1ee6cf4e1a91be91a4a78f4a160f64d33cc6
Change-Id: I4cb61481205c3689c41e62670cec113adb2a0362
Closes-Bug: 1722842
2017-11-15 08:59:45 +01: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
Kevin Benton 355dab604a Reduce extension logging on init
Reduce from 4 separate lines into 1


Change-Id: I137944fe4c6cfbb1e27ad4e4a233d4220642f3e4
2017-06-14 02:03:08 -07:00
fpxie 574312165b Replace six.iteritems with dict.items(Part-2)
according to, now we should avoid
using six.iteritems and replace it with dict.items.

Change-Id: I58a399baa2275f280acc0e6d649f81838648ce5c
Closes-Bug: #1680761
2017-04-18 18:56:46 +08:00
Boden R a6a344c7b5 Consume ServicePluginBase from neutron-lib
Neutron lib now contains ServicePluginBase [1]. In accordance
with the discussion in [2], this patch:
- Removes ServicePluginBase from neutron and replaces all uses
with neutron-lib.
- Removes PluginInterface; the plugin interface for extensions
is ServicePluginBase; that's what's used by everyone today.
- Updates a few UTs, based on the above.

NB: A subsequent patch will address the WorkerSupportServiceMixin
so its untouched herein.


[1] I2b1131ac53e9bfeb42a92f9ef134be6ff4cfe5a3

Change-Id: I1e8f2ee6a96df9ba07dae37f1a80e61ad20693cc
2017-03-17 12:06:57 -06:00
Shaohe Feng fa04ab0fcf tiny refine: capitalize mod_name with string capitalize function
string capitalize can return a copy of the string S with only its first
character capitalized.

Change-Id: If76b63e0b6c1c9ab957afdf66d3e7c76367afb2c
2017-02-25 05:48:12 +00:00
Jenkins 97af096727 Merge "Use ExtensionDescriptor from neutron-lib" 2016-12-06 02:04:42 +00:00
Jenkins 57f94f3cf1 Merge "Pecan: Remove get_resources() from get_pecan_resources()" 2016-12-05 19:28:11 +00:00
Henry Gessau dfe738a83f Use ExtensionDescriptor from neutron-lib
Adopt the class rehomed in

This change impacts subprojects that use ExtensionDescriptor from
neutron core. All subprojects should switch to using the class
directly from neutron-lib.


Change-Id: I0da90fb9d27a0a2008b60e56ed69bc9b9ae63c3e
2016-12-02 14:16:06 -05:00
Mohit Malik 958c093d26 Pecan: Remove get_resources() from get_pecan_resources()
This is not required anymore.
Change-Id: I4794033fe23304de767e0b0ad7b16d27b2527c77
2016-11-30 20:40:54 +00:00
Henry Gessau 8b0bdbea83 Redirect ExtensionDescriptor to neutron-lib
Preliminary step in adopting ExtensionDescriptor from neutron-lib.

This switches to using the ExtensionDescriptor class from
neutron-lib. In this step we provide a redirector so that subprojects
do not break. In follow-up patches, all subprojects will switch to
using neutron-lib directly, and then the redirector will be removed
from neutron core.

Change-Id: I5a111e0033e518e39b3042f047ee9eebba77a0d5
2016-11-25 21:31:53 -05: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.


Partially-implements: blueprint neutron-lib

Change-Id: I7331e914234c5f0b7abe836604fdd7e4067551cf
2016-11-23 04:45:33 -07:00
Armando Migliaccio 0db052d218 Reduce log level for extensions not being supported
Some in-tree extensions may only work if their respective service
plugin is loaded. This should not be treated at warning level, as
the configuration may be intended.

Change-Id: I898b8958c944af025a880dc95d5d40f28039b5f3
2016-09-20 16:12:04 -07:00
Armando Migliaccio 720a8b3ff0 Broken extensions should not show up in the extension list
This patch ensures that invalid extensions are not exposed to
the user and thus allow clients that rely on them to fail
fast rather than unexpectedly.

Closes-bug: #1547678

Change-Id: Iaace8a9e41562cb16b8c4b475eea01956eb6aab7
2016-08-12 18:20:46 +00:00
Ihar Hrachyshka 5e0878f476 Added API extensions to detect sorting/pagination features
Those features are available only when allow_sorting and
allow_pagination options are enabled (the current default is False).

They don't depend on plugin support, because when plugins don't
implement them natively, emulated mode is applied by API router itself.
So to make it plugin agnostic, we introduce a way to register custom
per-extension checks to override support detection for cases like that

Now that we have a way to detect support for those features via API,
there is little reason to keep tempest configuration options to enable
those features. Instead, just inspect [network-feature-enabled]
api_extensions option in tempest.conf.

used in a single place only (in allow_sorting/allow_pagination
definitions), removed them and replaced with a literal.

Added first in-tree API tests for /extensions entry point.

DocImpact Update API documentation to cover new extensions.
APIImpact Document the new extensions.
Related-Bug: #1566514
Change-Id: I0aaaa037a8ad52060a68dd75c0a1accc6add238e
2016-08-01 22:57:15 +02:00
Brandon Logan cbae3e0de0 Pecan: Backwards compatible/cleaner init
Previously the pecan controller creation was based on the
attributes.RESOURCE_ATTRIBUTE_MAP's keys after it had been fully
populated by all active extensions.  The problem with the problem
with this strategy is that those keys did not necessarily define
the actual URI path, and if any extensions ever had subresources
(.i.e. /qos/policies/{policy_id}/bandwidth_limit_rules), the
attributes.RESOURCE_ATTRIBUTE_MAP was never populated with those.
Getting those subresources would require some very unsightly code
and strategies.

What this does is it grabs the resources that every extension
returns in the get_resources method.  The get_resources method
returns a list of ResourceExtensions that do infact define the
URI, and does have a clear linkage to subresources.  With this
in mind, the pecan initializer can now translate what get_resources
returns into pecan controllers with the correct paths.

The subresource work still needs to be done and will be done in a
follow-up patch.  Also, there is an issue with the
auto-allocate-topology tests, but this too can be solved in
another patch so this review does not get bloated.

Change-Id: I3b42b4b603af97538f08b401d2740d3049276a43
2016-05-20 03:58:02 -05:00
Cedric Brandily c6efa6292c Support Routes==2.3
SubMapper.connect allows in Routes<=2.2 to define routes with/without a

 map.connect(route_name, route_path)

Routes==2.3 SubMapper.connect now requires a route name (but not
Mapper.connect). This change adds a route name when needed to support
Routes<=2.2 and Routes==2.3.

Closes-Bug: #1563028
Change-Id: I655bfe7f047945896d63dd94c584acfe60d81b38
2016-03-29 23:36:55 +02:00
LiuNanke 83ef6b5677 Using LOG.warning replace LOG.warn
Python 3 deprecated the logger.warn method, see:
so we prefer to use warning to avoid DeprecationWarning.

Closes-Bugs: #1529913

Change-Id: Icc01ce5fbd10880440cf75a2e0833394783464a0
Co-Authored-By: Gary Kotton <>
2016-03-10 11:02:45 -08:00
Jenkins 8a9b514c0a Merge "Add a description field to all standard resources" 2016-03-06 04:56:54 +00:00
Jenkins 8450a197d5 Merge "Fix some inconsistency in docstrings" 2016-03-06 04:46:03 +00:00
Kevin Benton 5dacbba701 Add a description field to all standard resources
In order to give users and operators more flexibility in
annotating the purpose of various Neutron resources, this patch
adds a description field limited to 255 chars to all of the
Neutron resources that reference the standard attribute table.
The resource that reference the table are the following:
security_group_rules, security_groups, ports, subnets,
networks, routers, floatingips, subnetpools

This patch adds a description table related to standard attributes
and migrates over the existing security group description to the new
table as well.

Co-Authored-By: James Dempsey <>

DocImpact: Adds a description field to all resources outline in
           commit message.
Closes-Bug: #1483480
Change-Id: I6e1ef53d7aae7d04a5485810cc1db0a8eb125953
2016-03-05 02:29:35 +00:00
Hirofumi Ichihara 0ae3c172ae Make API framework more flexible for various extensions
This patch adds a function to Neutron extension mechanism
so that we can add API methods to "/resources" path rather than
"/resources/action" path.

This patch also allow extentions to control correspondences
between action and status in API request.

Change-Id: I862086f7528583e65d7bee794f011ddff6ae8901
Partial-Implements: blueprint add-tags-to-core-resources
Related-Bug: #1489291
2016-03-02 05:39:04 +09:00
Jenkins d51a18c4d0 Merge "Pecan: Fix association of plugins with resources" 2016-02-15 09:47:02 +00:00
armando-migliaccio aadf2f30f8 Add the ability to load a set of service plugins on startup
Service plugins are a great way of adding functionality in a
cohesive way. Some plugins (e.g. network ip availability or
auto_allocate) extend the capabilities of the Neutron server
by being completely orthogonal to the core plugin, and yet may
be considered an integral part of functionality available in
any Neutron deployment. For this reason, it makes sense to
include them seamlessly in the service plugin loading process.

This patch, in particular, introduces the 'auto_allocate' service
plugin for default loading, as we'd want this feature to be enabled
for Nova to use irrespective of the chosen underlying core plugin.

The feature requires subnetpools, external_net and router, while
the first is part of the core, the others can be plugin specific
and they must be explicitly advertised. That said, they all are
features that any deployment can hardly live without.

DocImpact: The "get-me-a-network" feature simplifies the process
for launching an instance with basic network connectivity (via an
externally connected private tenant network).

Once leveraged by Nova, a tenant/admin is no longer required to
provision networking resources ahead of boot process in order to
successfully launch an instance.

Implements: blueprint get-me-a-network

Change-Id: Ia35e8a946bf0ac0bb085cde46b675d17b0bb2f51
2016-02-10 10:04:15 -06:00
Salvatore Orlando 517aa03da3 Pecan: Fix association of plugins with resources
The process was leveraing the supported_extension_aliases
attribute, which might not provide a complete list of extension

With this patch now Pecan leverages helper methods available
in the extension manager, which have been slightly refactored in
order to allow for retrieving aliases for a single plugin.

Closes-Bug: #1542277

Change-Id: Id944b27dcd84a92bf15242f5797408bf83b0d317
2016-02-05 04:36:31 -08:00
Jenkins 1efa5f1da7 Merge "Fail if required extensions are missing" 2016-01-30 17:21:25 +00:00
armando-migliaccio b14c06b5ed Fail if required extensions are missing
If the required extensions are missing, we currently log an error
that is going to be practically ignored. That said, the unfulfilled
requirement will most definitely going to lead to other failures,
so we might as well fail fast.

This patch also cleans up some <barf>dns-integration nonsense</barf>
within the ML2 framework: the extension must not be declared statically
as it's being loaded by the extension manager, and this fixes the lousy
unit tests we have to live with. As for the db base plugin, some cleanup
is still overdue, but it will have to be taken care of in a follow-up

Closes-bug: #1538623

Change-Id: Id50eeb52c5d209170042b48821a29af3421c2f5c
2016-01-29 16:20:07 -08:00
Gerard Braad 6f0cadc380 Decorate methods in ExtensionDescriptor with abstractmethod
Change-Id: I1cbde0c622d5595664f8547284c2c765de2f4c70
2016-01-22 09:01:24 +00:00
Jenkins 0399f8383f Merge "Simplify extension processing" 2016-01-10 11:19:24 +00:00
Akihiro Motoki 2d8632e412 Use _ from neutron._i18n
Partial-Bug: #1520094
Change-Id: I874a4aa1d71d1f7034a1ff0b7450b419ef5c6864
2015-12-06 19:39:04 +09:00
lei zhang fd2aad9e0f Fix some inconsistency in docstrings
According to

Change-Id: I833e0ef58fb12f8e4c57331706f270fd83341911
2015-12-06 01:57:41 +08:00
Doug Wiegley dd726ed494 Move i18n to _i18n, as per oslo_i18n guidelines
- This does NOT break other projects that rely on neutron.i18n,
  as this change includes a debtcollector shim to maintain those
  older entry points, until they can migrate.
- Also updates to the latest pattern defined by oslo_i18n
- Guidance and template are from the reference:

Partially-Closes-Bug: #1519493
Change-Id: I1aa3a5fd837d9156da4643a367013c869ed8bf9d
2015-12-01 19:29:10 -07:00
Salvatore Orlando e6672fda49 Remove misplaced copyright attribution
the module neutron.api.extension has a copyright attribute to a user
who never contributed a line to this module. It was probably copied
over in the initial commit for the module.

This commit is probably quite pointless; however it removes a little
oddity and does no harm to anyone.

Change-Id: I985bf2cb0538a795464dfe783108f218f821d762
2015-11-20 09:52:16 -08:00
Gary Kotton 2b7fb6ff08 Removes the use of mutables as default args
Passing mutable objects as default args is a known Python pitfall.
We'd better avoid this. This commit changes mutable default args with
None, then use 'arg = arg or {}', 'arg = arg or []'. For unit code which
doesn't use the args , just set with None. This commit also adds hacking

This code was taken from commit 0bea84ac20fe498bd08f7212a0017196c8cb0812
in Nova.

Change-Id: I36d07cade687690dc02a8f6cc3d70f5d00caf112
Co-Authored-By: ChangBo Guo(gcb) <>
2015-10-29 07:57:31 -07:00
Jenkins 97d17ec05b Merge "Consume ConfigurableMiddleware from oslo_middleware" 2015-10-09 12:16:28 +00:00
Elena Ezhova ed729862eb Consume ConfigurableMiddleware from oslo_middleware
Middleware class in neutron/ can be replaced with
ConfigurableMiddleware from oslo_middleware.

Remove the Debug helper class as it doesn't seem to be used
anywhere. Instead, one can use oslo_middleware.debug.Debug.

Added a note about possible implications for out-of-tree plugins
to neutron_api.rst.

Change-Id: If7360608f94625b7d0972267b763f3e7d7624fee
2015-10-08 17:59:43 +00:00
Ihar Hrachyshka 2758739847 Cleaned up remaining incorrect usage for LOG.exception
- callers should not explicitly pass exceptions into LOG.exception
  because it's already implicitly included in the message by stdlib
  logging module.
- callers should not call to LOG.exception when there is no exception to
  log about (known to fail in Python 3.x < 3.5).

Change-Id: I58e7e01ed152028ad43bb3ada87d719caa2ab08d
Related-Bug: #1504053
2015-10-08 16:45:18 +02:00
YAMAMOTO Takashi d952cfa8b0 Simplify extension processing
Now ExtensionDescriptor defines the contract for extensions,
don't bother to check existence of attributes which exists in

Also, reject extensions not derived from ExtensionDescriptor.

Closes-Bug: #1501186
Change-Id: I48e179b8739b61f336f5180a22fc66283b9b6991
2015-09-30 15:29:06 +09:00
Salvatore Orlando 2c40310584 Use pecan controllers for routing
Pecan defines several efficient mechanism for routing requests to
the appropriate controller, but the current code for Neutron's
Pecan WSGI server basically uses Pecan hooks to route requests.

This patch partially fixes that, removing the 'resource_identifier'
pecan hook and replacing it with explicit pecan routes between
controllers added at resource registration time.

All the remaining hooks, like attribute_population and
policy_enforments, which were relying on finding the resource
name in the pecan.request threadlocal variable have been updated.

This patch also:
- ensures the appropriate plugin is always selected for a given
- add a common NeutronPecanController base class for the classes
  CollectionsController and ItemaController
- Fixes the way in which plurals and singulars are handled in

Change-Id: I4ec0d2276c3974117b497228d289c3fb0dc5a140
2015-09-18 06:00:14 -07:00
Doug Wiegley 6f2849c916 Merge remote-tracking branch 'origin/master' into merge-master-into-pecan
Change-Id: I28d09f217464c1abef6fc38907071a65c17da86c
2015-09-02 15:40:51 -06:00
armando-migliaccio 61121c5f2a Decentralize the managemement of service providers
After the service split, some of the configuration, parsing and
validation was kept in the neutron core; ultimately this needs to
get closer to the services where it belongs.

This patch starts from ProviderConfiguration and ServiceTypeManager
classes, and aims at removing the hard-coded elements, like the list
of known advanced services, so that in the long run we can make
Neutron easier to plug with external services.

Partial-bug: #1473110

Depends-on: I44edcceba37ac58efcc0a53c9d1f835d9530344a
Depends-on: I8924234aadf786801ffc100d7daa27acc145a195
Change-Id: Ia4cad678e6c722ca05821dbdbf05d61523246a86
2015-09-01 03:27:13 +00:00
Doug Wiegley 2c5f44e1b3 Merge remote-tracking branch 'origin/master' into merge-branch
Change-Id: I9c29ad9564671ae5a2db35835bc4a30e75482cb2
2015-08-30 21:23:59 -06:00
Kevin Benton 4595899f7f Neutron RBAC API and network support
This adds the new API endpoint to create, update, and delete
role-based access control entries. These entries enable tenants
to grant access to other tenants to perform an action on an object
they do not own.

This was previously done using a single 'shared' flag; however, this
was too coarse because an object would either be private to a tenant
or it would be shared with every tenant.

In addition to introducing the API, this patch also adds support to
for the new entries in Neutron networks. This means tenants can now
share their networks with specific tenants as long as they know the
tenant ID.

This feature is backwards-compatible with the previous 'shared'
attribute in the API. So if a deployer doesn't want this new feature
enabled, all of the RBAC operations can be blocked in policy.json and
networks can still be globally shared in the legacy manner.

Even though this feature is referred to as role-based access control,
this first version only supports sharing networks with specific
tenant IDs because Neutron currently doesn't have integration with
Keystone to handle changes in a tenant's roles/groups/etc.


Change-Id: Ib90e2a931df068f417faf26e9c3780dc3c468867
Partially-Implements: blueprint rbac-networks
2015-08-20 20:00:17 -07:00
Kevin Benton 5a5a880743 Add extensions listing to the controller
Extensions aren't like normal resources handled by the
core plugin or a service plugin so they need special code
to handle them. The resource identifier hook also had to
be tweaked to let the request slip through without having
an entry in the attributes map.

Change-Id: I5f42bdd7aa3c103b2ff3550ce1b0d9a3baf35a35
Co-Authored-By: Brandon Logan <>
Partially-Implements: blueprint wsgi-pecan-switch
2015-08-01 18:57:38 +00:00
Kevin Benton c5cb76315f Alter unit test to match bug and cleanup ext logic
The unit test for bug #1443342 was only testing that a side effect
leading to the bug didn't occur (comparing object identities). This
patch updates the unit test to fully assert that the bug itself
doesn't occur without checking implementation details.

This also eliminates the branching that led to the original issue by
using setdefault to always return a dict to update.

Related-Bug: #1443342
Change-Id: I6c48681aa49c17bbadffa12bad1eea272c483437
2015-07-16 19:01:25 -07:00
Wei Wang 75859529cf Fix bug that resources in attr_map may point to same object
The assignment of attr_map may cause resources' attr_map point
to a same object. So once one resource's attr_map update, it maybe
affecte others.

Change-Id: Ica2c3082f9579b297f8c6323e04f8fd17c4da222
Closes-Bug: #1443342
2015-07-12 00:48:51 +08:00
Jenkins 9d9684a1ab Merge "Remove get_namespace from API extensions" 2015-06-24 14:54:12 +00:00
Jenkins 9b829760a3 Merge "API Extensions: inherit from the ExtensionDescriptor" 2015-06-18 22:54:25 +00:00