Commit Graph

37 Commits

Author SHA1 Message Date
Slawek Kaplonski 670cc383e0 [S-RBAC] Switch to new policies by default
As part of the Secure RBAC community goal, we should switch options
"enforce_new_defaults" and "enforce_scope" to be True by default.
It will be still possible to fallback to old policy rules by configuring
those config options to False in Neutron config.

Change-Id: I09c0026ccf87e6c0bb1fa59165c03dc508fba6fa
2023-04-21 16:22:42 +02:00
Rodolfo Alonso Hernandez 15b826a05f [OVN] Implement GW IP network QoS inheritance
This patch enables the gateway IP network QoS inheritance in
the OVN backend driver. The OVN QoS extension will use the
router external network (GW network) QoS policy if the gateway
IP port has no QoS policy assigned.

Partial-Bug: #1950454

Change-Id: I5ee51dc124ae464b9e9fd366cf7bf85176376c25
2022-04-15 01:10:31 +00:00
yangjianfeng e4c168b1fc Improve Router callback system's publish events
When I writing 'ndp_proxy' service plugin, I found I couldn't get enough
informations about router from the callback system (Such as: the origin
request body of user send). So, for write service plugin that related
router plugin more concisely I commit this patch.

This patch proposal two changes about router callback publish events:
1. Add 'request_body' parameter to some event's payload
2. add 'BEFORE_UPDATE' event for router gateway

Related-bug: #1877301
Change-Id: I5f6a4e6f0b7c5feb794ddb7efbd07d01bad91af8
2021-12-05 04:36:36 +00:00
Slawek Kaplonski 042de7e6bb Deprecate 'allow_overlapping_ips' config option
Config option allow_overlapping_ips is deprecated to removal now and
will be removed in the Z cycle.
Default value for that option is now set to True as this is supported by
IPAM module in Neutron.

Related-Bug: #1942294
Change-Id: I17bf5e4483025e9cc4ee04dd3e7c925f7bddc3db
2021-10-21 10:56:33 +00:00
Brian Haley 7594bb0627 Remove the dependency on the "mock" package
Now that we are python3 only, we should move to using the built
in version of mock that supports all of our testing needs and
remove the dependency on the "mock" package.

This patch moves all references to "import mock" to
"from unittest import mock". It also cleans up some new line
inconsistency.

Fixed an inconsistency in the OVSBridge.deferred() definition
as it needs to also have an *args argument.

Fixed an issue where an l3-agent test was mocking
functools.partial, causing a python3.8 failure.

Unit tests only, removing from tests/base.py affects
functional tests which need additional work.

Change-Id: I40e8a8410840c3774c72ae1a8054574445d66ece
2020-04-28 18:05:37 -04: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 39c7ac3ffe use AuthenticIPNetwork and AuthenticEUI from neutron-lib
This patch switches over to neutron-lib's version of the the
_AuthenticBase, AuthenticEUI and AuthenticIPNetwork classes by
deleting them from neutron and using lib's version instead.

Depends-On: https://review.opendev.org/#/c/659881/

NeutronLibImpact

Change-Id: Ia3d3db401d6abcb9c9965b945bcd4c199f8e812b
2019-06-25 08:47:48 -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
Doug Wiegley 8914f8247f Update neutron files for new over-indentation hacking rule (E117)
Change-Id: I594e2d1238f6ffa3c1039624e3b3ed6569485837
2019-01-29 15:36:20 -05:00
Hongbin Lu 12bb26fd0e Use constant IP_VERSION_4/6 in unit tests
Change-Id: I54bec2c06940b0b1362fecacef7860361d081601
2018-08-27 21:45:39 +00:00
Boden R 6fe35c8039 use get reader/writer session from neutron-lib
The get_reader_session and get_writer_session functions are available
in neutron-lib. This patch consumes them by removing the functions
from neutron and using lib's instead.

NeutronLibImpact

Change-Id: I4055172799a0d9a0ceb387b6d47e421e1c270ada
2018-07-06 14:43:31 -06: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
Lujin 9566810b38 Integration of Floating IP OVO
This patch integrates floating IP OVO.

Co-Authored-By: Shashank Kumar Shankar <shashank.kumar.shankar@intel.com>
Change-Id: I543669ed3bd59a1f7d5b999e3113bcea7b3c52a8
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
2017-12-04 19:30:02 +09:00
Boden R ebe013bcab use l3 ext gw mode api def from neutron-lib
The l3 ext gw mode extension's API defintion was rehomed into
neutron-lib with commit I2fbef43f076652758476f988d868e1d47c8cf713
This patch consumes the API definition by removing the rehomed code
and using APIExtensionDescriptor for the extensions parent class.

NeutronLibImpact

Change-Id: Ifb924d6a700f068465e60a85729fb1cdbc28c9fc
2017-11-17 07:02:45 -07:00
Boden R 277996b68d cleanup unit test usage of api extension maps
Today our unit test code uses various ways to "patch" the global
RESOURCE_ATTRIBUTE_MAP as well as extension specific maps in some cases.
This patch consolidates such patching whereby tests should use neutron's
AttributeMapMemento in their setup() chain (only once) if they update
the global map and they should individually handle backup/restore of per
extension map updates. This change will simplify the code and make it
easier to phase-in API definition usage with neutron-lib where we have
some as API definitions and others not. Longer term the
AttributeMapMemento will be replace with neutron-lib's fixture as we
move all extension maps to API definitions in neutron-lib.

Change-Id: I2586f0b11b107d7f57214a0d65bcf7c38a5f0ebb
2017-10-24 10:38:52 -06:00
Victor Morales 6670954de3 Integration of IPAllocation
This patch integrates the Oslo-Versioned Object created for
IPAllocation model class.

Change-Id: Ibb731c4635d89c848081fac73f216d2ecf10b599
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
2017-06-21 17:33:41 +09:00
Kevin Benton b02bbf8ba5 Fix relationship event handler for flushes and nested
Handle interim flushes by tracking 'new' objects in session.info
until commit time. This is necessary because new objects will no
longer be in 'session.new' during the before_commit event if flushes
have occurred.

Don't load relationships until final commit in nested commits. This
ensures we are on the outermost commit that will end the session
before loading up all of the relationships.

Partially-Implements: blueprint enginefacade-switch
Change-Id: Id0f79ebaafc446bb28363d281249f02eacd1e28d
2017-03-30 01:26:40 -07: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
Armando Migliaccio ca751a1486 Spin off context module
NeutronLibImpact

Partially-implements: blueprint neutron-lib

Change-Id: I48cf45dc1b07035d952152eac2548a3bd9fc2832
2017-03-06 16:25:29 +00:00
Cedric Brandily c88debc44f Use addCleanup instead of tearDown
We should use addCleanup instead of tearDown because:
- tearDown is executed only if the test succeeds
- cleanups (defined with addCleanup) are executed even if the test fails

This change removes useless tearDown and transforms remaining ones into
addCleanup.

Change-Id: I44bd26dcb5c8456126a35cb807f0bafc772c0ab0
2017-02-02 22:07:26 +01:00
Ann Kamyshnikova 4f17f70089 Stop using legacy facade
Introduce get_reader_session() and get_writer_session()
and replace get_session() with them.
Mark get_session as depricated.

Stop using get_engine from legacy facade. Use writer engine for
places where it is required.

Partially-Implements blueprint: enginefacade-switch

Change-Id: I28b741bfa27bf04cbe273586e6e3e00e14fbe683
2017-01-19 13:02:33 +04:00
Manjeet Singh Bhatia d49b6f5607 Use Port OVO object in test_l3_ext_gw_mode
Port object is already merged. This patch uses it for the unit test.

Change-Id: I4bb5918ea09325f012783b06b49906590c412882
Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
2016-12-02 12:37:48 +00: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
Manjeet Singh Bhatia b7fad985cc Replace a test with use of network object
This patch is replacing some occurences of network and
subnet creation in a test with oslo versioned object use.
The scope of change is limited to extensions/test_l3_ext_gw_mode.py,
rest integrations would be done in separate patches

Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db

Change-Id: I533d941fd74acc173f53a06a19cd33fa45b0d309
2016-11-03 05:25:35 +00: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
Manjeet Singh Bhatia 2b66c6a2ed Relocate L3 DB Models
As we have started oslo versioned objects implementations. There
would be issue of cyclic import while implementation for objects
which have db models definitions and mixins in same file. This patch
will move routers models as discussed in [1].

For example DNS models and some queries are in same file [2]. for object
implementation I have separate models definitions and mixins where
queries were being done [3].

[1]. https://www.mail-archive.com/openstack-dev@lists.openstack.org/msg88910.html
[2]. https://review.openstack.org/#/c/334695/15/neutron/db/dns_db.py
[3]. https://review.openstack.org/#/c/334695/15/neutron/db/models/dns_models.py

Change-Id: I9b9a44da5d28252be58cea1a920a64e18d8bbf32
Partial-Bug: #1597913
2016-09-27 16:58:55 +00:00
Kevin Benton fbd3578d64 Delete gw port on exceptions
Clean up related core plugin ports on routers when there is a failure
creating the record for the router port.

The two partial bugs will be fixed after
I476d3e03c8ee763cc4be6d679fe9f501eb3a19b5 has merged.

Closes-Bug: #1600344
Partial-Bug: #1535225
Partial-Bug: #1535226
Change-Id: I8dd832f35e20d1ee090ebab921f0deea533b6fc8
2016-07-11 06:07:03 -07:00
Kevin Benton 5109d16bc5 Make deepcopy of update body in API layer
This adjusts the update handler in the API layer to pass a deepcopy
of the original update body to ensure that the original is used on
any generated retry requests.

Without this update handlers that modified the body as they processed
it (e.g. the external gateway update for routers) would be missing
data on a retry request.

This adds a test case for the bug that was caused by this.

Closes-Bug: #1584920
Change-Id: I88fb9d45eb82ef48e0d865decdcc7fad1c5fb361
2016-05-15 00:19:38 -07:00
Henry Gessau 4148a347b3 Use constants from neutron-lib
With this we enable the deprecation warnings by default.

Related-Blueprint: neutron-lib

Change-Id: I5b9e53751dd164010e5bbeb15f534ac0fe2a5105
2016-04-23 21:23:56 -04:00
Yatin Kumbhare 6b4be76e14 Fix params order in assertEqual
Fix params order to correspond to real signature:
assertEqual(expected, actual)

Change-Id: I722b998f6eae47076f3d10213073296a0a9a2081
Closes-Bug: #1277104
2016-02-03 11:54:29 +05:30
Bo Chi d3701f001d Remove 'validate' key in 'type:dict_or_nodata' type
In resource_map dict, if the 'validate' section of type:dict_or_nodata
contains 'validate' key, the validation will not be performed correctly,
because in _validate_dict_item(), it checks key name that starts with
'type:', and perform the validation.

This patch removed 'validate' key in 'external_fixed_ips' section in
neutron/extensions/l3_ext_gw_mode.py

Change-Id: I1ee49f8313bddef6f41b133f49830a8fbbe4769e
Closes-Bug: #1533518
2016-01-14 00:07:19 -05:00
Ihar Hrachyshka fb2a5bd4cf Use DEVICE_OWNER_COMPUTE constant everywhere
Now that we have the constant defined, we should reuse it from other
code to avoid potential typos.

Change-Id: Iebb270be46b116df3441370dc1a6784571311aa9
2015-11-14 18:54:17 +01:00
Brandon Palm 2503dfb239 Fixed a bunch of typos throughout Neutron
Went through all of the docstrings in Neutron and did
some cleanup.  I'm sure there are bunch more that I have missed.

Change-Id: Ib29d2de1c580880c89ed4fd069e1515d0977a3e7
2015-10-30 08:54:41 -05:00
ChangBo Guo(gcb) c3d65a0ed9 Switch to oslo_utils.uuidutils
Get rid of oslo-incubator uuidutils

Closes-Bug: #1467020
Depends-On: I2df519965883b05d5d58cdc4785c850b0685dc2c
Depends-On: I9f8e98ad9517864a9ffdacf01c0a9a5aab554edb
Depends-On: Ied0faac809a5b72b1cd466c8babc9ca5418692c3
Change-Id: Iebe491b981b4b7c02785412fadd27678bb5e47de
2015-06-22 11:06:18 +00:00
Cedric Brandily cf84ec4c10 Allow to define enable_snat default value
Currently neutron resets enable_snat attribute to True when enable_snat
is not provided in router external_gateway_info. But in some deployments
(private/enterprise clouds) such behavior is not the expected default
one as snat/nat/floating-ips is not used (at least by default).

This change defines the option enable_snat_by_default which allows
deployers to set enable_snat default value when neutron resets it. The
option default value is True for backward compatibility.

DocImpact
APIImpact
Closes-Bug: #1388858
Change-Id: I455a552230ec89fe907a087c1de8c8144b5d086e
2015-05-07 00:10:50 +02:00
Cedric Brandily ccd30a8cab Correct inconsistent enable_snat management
Neutron resets enable_snat attribute when external_gateway_info is
cleared but not when external_gateway_info is only updated which
implies the following sets of actions have different behaviors:

  neutron router-gateway-set router1 pub1 --disable-snat
  neutron router-gateway-set router1 pub2

enable_snat is False after the last command

  neutron router-gateway-set router1 pub1 --disable-snat
  neutron router-gateway-clear router1
  neutron router-gateway-set router1 pub2

enable_snat is True after the 2nd command resets the gateway AND
enable_snat.

This change proposes to always reset the attribute enable_snat when
enable_snat is not provided in external_gateway_info on POST/PUT for
consistency.

APIImpact
Change-Id: Ibab289936c55b1cf9614b44a4f18f54c959ee9e8
Closes-Bug: #1384146
2015-04-21 00:02:36 +02:00
Maru Newby 1105782e39 Reorganize unit test tree
This change ensures that the structure of the unit test tree matches
that of the code tree to make it obvious where to find tests for a
given module.  A check is added to the pep8 job to protect against
regressions.

The plugin test paths are relocated to neutron/tests/unit/plugins
but are otherwise ignored for now.

Change-Id: If307593259139171be21a71c58e3a34bf148cc7f
Partial-Bug: #1440834
2015-04-06 23:28:31 +00:00