Commit Graph

34 Commits

Author SHA1 Message Date
Rodolfo Alonso Hernandez ddd5832323 Remove "six" library
Last step to remove "six" library usage in Neutron.

Change-Id: Idd42e0c51c8c3bd598c9cf91602596be238bccae
2020-07-28 16:55:52 +00:00
Michael Johnson d1d0a04c37 Remove Neutron LBaaS
Neutron-LBaaS has now been retired and there will be no Train
release[1]. This patch removes neutron-lbaas references from
neutron.

[1] https://review.opendev.org/658494

Closes-Bug: #1833125
Change-Id: I0fe3fbaf4adf7fb104632fd94cd093e701e12289
2019-09-20 07:46:06 +00:00
Brian Haley fc95db987d Fix flake8 N534 untranslated exception message
Fix N534 untranslated exception message warnings and
enable enforcement.

Trivialfix

Change-Id: I9e2b51c768cbb6fcf5588070d1b9e9835775b374
2018-10-19 15:46:04 -04:00
Doug Hellmann 2530ccff8f Upgrade pylint to a version that works with python3
Also fixed some six.moves errors as well.

Change-Id: I9783ee588de1ec4b91a665b9dc89fdba3e2d90df
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2018-10-04 18:03:25 +00:00
Max 6e6166bda4 Replace assert to raise AssertionError
This patch is a fix for the issue B101 assert_used found by bandit
scanner:
https://docs.openstack.org/bandit/latest/plugins/b101_assert_used.html
As assert functionality could be turned off by the -O option for python
interpreter, assert statements were replaced to raise AssertionError.

The main reasoning for that is rest code after assert could be not
ready for values that assert filters.

Change-Id: I92a871b1b496c96c0c76cb37e4dda51bfc007e38
Related-Bug: #1759250
2018-04-10 16:01:48 +04:00
Boden R 44292f4c9a consume neutron-lib resources attr map
Today we shim the RESOURCE_ATTRIBUTE_MAP in neutron; it references the
equivelant in neutron-lib named RESOURCES.

This patch removes neutron's RESOURCE_ATTRIBUTE_MAP and cleans up
neutron.api.v2.attributes in prep to delete it.
To do so:
- CORE_RESOURCES and RESOURCE_FOREIGN_KEYS are moved to the single
module that references them respectively and the are made private (no
consumers use them).
- get_collection_info is removed and instead the 2 uses in neutron
just use the get() method of the RESOURCES map. There are no external
uses of get_collection_info.
- References using RESOURCE_ATTRIBUTE_MAP are switched over to
neutron-lib's RESOURCES.
- The neutron.api.v2.attributes module is removed as it's empty now.
- A few api attribute UTs are removed; there's nothing to test as per
this patch.

NeutronLibImpact

Change-Id: Iaacee584d499c4d33d6d2dd9609c7ac0f2cfc386
2018-03-09 13:37:28 -07: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
fpxie 574312165b Replace six.iteritems with dict.items(Part-2)
according to https://wiki.openstack.org/wiki/Python3, 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
tonytan4ever 5da865c1a8 Pecan: /v2.0/ views response with resources
The legacy framework return a list of resources as the response to:

GET /v2.0/

Current pecan 2.0 controller seems return the same as root controller
content. This patch will make it return the same response as legacy
framework

Change-Id: Icae8c1b417d4d5a65a98eeafe80a26886aa254a3
2017-04-12 17:19:31 -07:00
tonytan4ever ebc7e1fb2f Pecan: Get loaded by paste deploy
This sets up the factory methods needed to have paste deploy create the
pecan app and return it.  It also changes the legacy factory methods to
conditionally use the pecan factory methods if the web_framework config
option is set to 'pecan'.  This way, all deployments of neutron will not
need to change their api-paste.ini files to get pecan toggled on.  It
should just happen without notice once pecan becomes the default.

Also, by moving this to be loaded by paste deploy, there is a good chunk of
code that has been removed because it is no longer necessary.

Co-Authored-By: Brandon Logan <brandon.logan@rackspace.com>
Change-Id: I8b1bbea8d90fdc62715cd8b6738ad955df53d7cd
2017-02-17 14:54:27 -06: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
Kevin Benton 21825d6cbe Pecan: Allow unauthenticated version listing
The current API allows listings of the neturon server
version without authentication. Because pecan was treating
this like a normal controller, it was requiring keystone
authentication.

This adjusts the version listing to behave as a wrapper so
it can be placed outside of the keystone authentication
wrapper to allow anonymous queries.

Closes-Bug: #1556038
Change-Id: I9f5aa3bea0e11c5e179fc286f9fa350b3930364f
2016-03-11 16:45:28 -08:00
LiuNanke 83ef6b5677 Using LOG.warning replace LOG.warn
Python 3 deprecated the logger.warn method, see:
https://docs.python.org/3/library/logging.html#logging.warning
so we prefer to use warning to avoid DeprecationWarning.

Closes-Bugs: #1529913

Change-Id: Icc01ce5fbd10880440cf75a2e0833394783464a0
Co-Authored-By: Gary Kotton <gkotton@vmware.com>
2016-03-10 11:02:45 -08:00
Brandon Logan 6659428669 Pecan routing for agent schedulers
For pecan to support existing agent scheduler controllers, a couple of shim
pecan controllers need to be added.  These shim controllers will be used if
there are extensions that have legacy controllers that have not been
registered.  The shim controller is just a passthrough to those legacy
controllers.  This may have the added benefit of support existing out of
tree extensions that have defined their legacy extension controllers the
same way.

Changes to how the router(s) controllers determines whether something
is a member action has been changed a bit to support this.

Closes-Bug: #1552978
Co-Authored-By: Kevin Benton <kevin@benton.pub>
Change-Id: Icec56676d83b604c3db3377838076d6429d61e48
2016-03-08 06:35:49 +00:00
Salvatore Orlando a47f4d1726 Pecan: replace dashes with underscores on controller lookup
This is needed for extensions like security-groups as resource
names do not use dashes but underscores.

Change-Id: I952abd261a3cf8ac964463dd50377905f08830c8
Closes-Bug: #1537929
2016-02-19 00:54:32 -08:00
Salvatore Orlando cf8f60e5f3 Pecan: Controller and test refactor
This patch refactors the pecan controllers and functional tests
by spliting the code in several modules in order to avoid excessive
growth and ensure some level of consistency as regards function
and classes defined in each module.

To this aim:
- The generic resource controllers are moved into their own module
- Other controllers, such as extension and quotas, are moved into
  their own module
- Functional tests are split into 3 modules: one for generic tests,
  one for request processing tests, and the latter for testing hooks.

Related blueprint wsgi-pecan-switch

Change-Id: Id76cd88208dfd273bccadc15a1c6febbcc4fc030
2016-02-09 23:27:25 +00:00
Jenkins 831c2da944 Merge "Pecan controller loads service plugins" 2016-01-15 17:39:16 +00:00
Salvatore Orlando 5fe6f8015a Pecan: fix quota management
This patch fixes quota management APIs in the Pecan framework.
To this aim:

1) an ad-hoc pair of collection/item controllers are introduced
   for the quota resource; as the new controllers have been added
   in a separate module, the neutron.pecan_wsgi.controllers.utils
   module has been added as well for helpers, routines and classes
   used by all pecan controllers;
2) the quota API extension is made pecan-aware, meaning that it
   simply returns a Pecan controller instance rather than deferring
   the task to the startup process that builds controllers using the
   home-grown WSGI framework ext manager;
3) the quota resource is now "almost" a standard neutron resource;
   unfortunately since it does not yet have its own service plugin a
   special provision is made in the attribute population hook in
   order to ensure the object is loaded for allowing correct
   policy enforcement.
4) Functional tests for the quota controller have been added.

Closes-Bug: #1505843

Change-Id: I44a1fd73f678e493d5b1163e5f183d9efdc678ac
2016-01-13 09:10:25 -08:00
Brandon Logan a6ab3badd1 Pecan controller loads service plugins
The pecan controllers were not parsing out the case when a service
plugin is being used that changes the URI to
/v2.0/service_plugin/resource

This will check to see if the first resource after v2.0 is an
extension to a service plugin, and if it is it'll check the next
resource for a controller.

Change-Id: I9b6bd7afbbe91f1c8f0c1835b320dc41bfccff3f
2016-01-12 12:28:54 -08:00
Salvatore Orlando 0f9a607cf6 Pecan: Streamline request body processing
This patch simplifies the process for validating the request body for
POST and PUT requests and preparing it for dispatching to plugins.

In particular it removes the need for parsing the URL to find the
resource identifier, and instead leverages Pecan's routing engine
to extract it. As a result the attribute population hook now simply
deals with request body validation, and has been renamed accordingly.

The logic for loading the current state of the object from the plugin
in order to enforce authZ policy on PUT requests has been moved to
the appropriate hook, PolicyEnforcementHook.

The logic for managing plural/singular names for resource has also been
improved, and two helper functions to retrieve a resource's attributes
have been added to neutron.api.v2.attributes

The logic for aborting requests with unsupported HTTP methods has also
been moved to the REST controllers. It used to be in PolicyEnforcementHook,
which was probably not the right thing to do.

This patch also unskips a functional test concerning ownership checks,
and add functional tests for verifying correct request processing.
Unit tests for the newly added helper functions are also provided.

Related blueprint wsgi-pecan-switch

Change-Id: Ib26998b37bdeec8af7a97f77b66d421b8cd271da
2016-01-11 04:07:34 -08:00
Akihiro Motoki 2d8632e412 Use _ from neutron._i18n
Partial-Bug: #1520094
Change-Id: I874a4aa1d71d1f7034a1ff0b7450b419ef5c6864
2015-12-06 19:39:04 +09: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 _i18n.py to the latest pattern defined by oslo_i18n
- Guidance and template are from the reference:
  http://docs.openstack.org/developer/oslo.i18n/usage.html

Partially-Closes-Bug: #1519493
Change-Id: I1aa3a5fd837d9156da4643a367013c869ed8bf9d
2015-12-01 19:29:10 -07: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
  resource
- add a common NeutronPecanController base class for the classes
  CollectionsController and ItemaController
- Fixes the way in which plurals and singulars are handled in
  neutron.api.v2.resource_heper

Change-Id: I4ec0d2276c3974117b497228d289c3fb0dc5a140
2015-09-18 06:00:14 -07:00
Jenkins ad0d4e0833 Merge "Set expected HTTP codes for create and delete" into feature/pecan 2015-09-16 17:23:53 +00:00
Jenkins a599349721 Merge "Add basic bulk support to collection controller" into feature/pecan 2015-09-16 17:20:54 +00:00
Jenkins f5bb72eb40 Merge "Return version info on version controller" into feature/pecan 2015-09-16 11:01:43 +00:00
Jenkins d576872267 Merge "Clarify and add a TODO in the controller" into feature/pecan 2015-09-16 11:01:17 +00:00
Salvatore Orlando 6f585ca08a Return version info on version controller
Just like the global root controller "/" returns info for
all versions, with this change the version root controller
"/<version>" will return info about the selected version.

The patch also ensures the root version controller only
accepts GET requests.

Change-Id: I183c6ff67597fe93e394fc8f07d7229112d4e215
2015-09-15 12:10:28 -07:00
Kevin Benton 3b8fdf4eaa Add missing resource discriminator in update resp
The update method of the pecan itemcontroller was not returning
the response encapsulated correctly in a dictionary with the resource
type identifier. This was discovered via the standard API tests.

Change-Id: Ie2217972c75b14a0867477f26f434055b33a9ae6
2015-09-15 11:21:49 -07:00
Kevin Benton 1a87e36c61 Clarify and add a TODO in the controller
This clarifies and adds a TODO regarding the filters and fields
API parameters.

Change-Id: I01cfd45b99dcfca4e320900caebdc68f6562ddd8
2015-09-15 11:20:28 -07:00
Kevin Benton 5d8735e158 Set expected HTTP codes for create and delete
Our API tests have HTTP code assertions that our controller
was not honoring in the create and delete cases.

Change-Id: I3b00348c854b5d887d74c115d06984222f20ccc1
2015-09-15 11:15:21 -07:00
Kevin Benton cbc7cd6cc4 Add basic bulk support to collection controller
This patch adds very basic bulk support to the
collection controller for bulk operations. TODOs
are inline for the things that still need to be
done. Functionality was verified with api tests.

Change-Id: I2c2e6f6e449a51ea60de75325855affa62869692
2015-09-15 11:05:29 -07:00
Salvatore Orlando 4e4a6cff5d Allow only GET on Root controller
This patch simply ensures a 405 error is returned when a HTTP
method different from GET is invoked on '/'.
This differs from the eventlet WSGI server behaviour; however
returning the same response as for a GET for any method, even
made up ones - like 'meh' - is a mistake that should not be
repeated in the Pecan WSGI server.

Change-Id: I4305f374e4aacab718daa6f131f278cc69e8d699
2015-09-05 07:21:01 +00:00
Kevin Benton be9bff66be Rename 'newapi' to 'pecan_wsgi'
'newapi' was too generic and not really descriptive of the conversion
to pecan. Since there isn't any ambiguity, we will just keep all of
the pecan components in a directory called 'pecan_wsgi'.

Change-Id: I61f1cfcad4ff00582e0a481400642dd656d5245e
2015-09-02 15:53:34 +00:00