Commit Graph

25 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
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
gugug 62729d4e74 Replace assertItemsEqual with assertCountEqual
assertItemsEqual was removed from Python's unittest.TestCase in
Python 3.3 [1][2]. We have been able to use them since then, because
testtools required unittest2, which still included it. With testtools
removing Python 2.7 support [3][4], we will lose support for
assertItemsEqual, so we should switch to use assertCountEqual.

NOTE(dmllr): added hacking check

[1] - https://bugs.python.org/issue17866
[2] - https://hg.python.org/cpython/rev/d9921cb6e3cd
[3] - testing-cabal/testtools#286
[4] - testing-cabal/testtools#277

Change-Id: I7c20fec08e5dc9f67b34100c925ea6724bbd25f0
2020-11-30 10:21:57 +01: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 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
Hongbin Lu 12bb26fd0e Use constant IP_VERSION_4/6 in unit tests
Change-Id: I54bec2c06940b0b1362fecacef7860361d081601
2018-08-27 21:45:39 +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
Boden R 72b6db9379 use dns api def from neutron-lib
neutron-lib contains the dns API definition and associated exceptions,
constants, etc. This patch moves all references over to use the API
def from neutron-lib.

NeutronLibImpact

Change-Id: If180cf92d8ae31a0857080239e8233095cd6c768
2017-10-20 16:38:33 -06:00
Aradhana Singh d00a50aad1 Refactoring config options for ml2 config opts
Refactoring neutron ml2 config opts to be in neutron/conf/plugins/ml2.
This would allow centralization of all configuration options and
provides an easy way to import.

NeutronLibImpact

Change-Id: Ibc5a9ab268578c243ef13f7e0041bacd6c0c410b
Partial-Bug: #1563069
Needed-By: Id0a97dda7718f06e33b2d30ce01cdcb3e9a46f7d
2017-09-08 15:34:49 -04:00
Hirofumi Ichihara 2873bb3acf Fix call a method of extension class
Some UTs have wrong method call about extension class.
This patch fixes the call.

TrivialFix

Change-Id: I86adc31dac5b4e56edb200b9c7c369112c7d8977
2017-03-30 16:37:23 +09: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
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
Gary Kotton 9f09f27c5d Fix deprecation warnings
Remove deprecation warnings for various constants
and exceptions that have moved to neutron_lib.

Fix miscellaneous other deprecations.

Uses constants instead of l3_constants when importing
neutron-lib constants.

Co-Authored By: Henry Gessau <gessau@gmail.com>
Co-Authored By: Gary Kotton <gkotton@vmware.com>

Change-Id: Ib0e8ff5c3e23677c1009241a1818cbc8a3430c38
2016-08-26 22:16:06 -04:00
Bin Yu 64f5fc8259 Refactor DNS integration out of DB core plugin
This patch set aims to move all the code related to DNS integration
from the DB core plugin to the DNS ML2 extension module.

By doing this, this patchset removes the dns related code in
db_base_plugin_v2 and the dns exteions module talks with core plugin
only through the method extension_manager and apply_dict_extend_functions

By properly implementing the generation of the dns_assignment attribute
for ports in the DNS ML2 extension module, this patchset also fixes
https://bugs.launchpad.net/neutron/+bug/1579977

Change-Id: I63afb1a1bfeeb14eefb54681dc64959144deeb25
Closes-Bug: #1579601
Closes-Bug: #1579977
2016-07-26 07:33:50 +00:00
Ryan Tidwell cbc15d2e1d Ensure unit tests don't assume an IP address allocation strategy
These unit tests initially asserted sequential allocation of IP
addresses, even though they have no need to specifically assert
that a specific IP was allocated. This made it difficult to
change out the IP allocation algorithm in the future and made
these tests fragile and poorly isolated.

This change breaks the dependency these unit tests have on a
specific IP allocation strategy and isolates them from any
changes that may be made to the order in which IP addresses
are allocated on a subnet.

Change-Id: Idc879b7f1e6496aa96b4f7ae6c3eaca6079bdcac
Partial-Bug: #1543094
2016-05-17 09:50:25 -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
Davanum Srinivas a94e1b410b Fix test failure against latest oslo.* from master
Looks like there's a lot of places in Neutron tests we are
using res.json['NeutronError']['message'] to look at the
exact message and we missed a spot

Closes-Bug: #1561151
Change-Id: I8e62ae9f16a2b239520f79ac53401e596f781b64
2016-03-23 14:53:02 -04:00
James Anziano e0b3665280 Stops update_network handling updates it shouldn't
Currently update_network() attempts to update the network table with
any parameters that belong to a network, even if those attributes are
stored in a separate database table. This was causing certain update
commands to fail (such as updating dns_domain). The actual update to
dns_domain is handled by extensions called by the ml2 plugin, but this
function was also trying to process it and causing an error.

This patch ensures the network variable is only updated with
attributes that are actually in the networks table by filtering out
any parameters that don't match fields in the Network class model.

Change-Id: I54a736d91de52dda85c559b9e6103199f914abdf
Closes-bug: 1541560
2016-03-11 11:57:19 -06:00
Ihar Hrachyshka 4398f14a9a Postpone heavy policy check for ports to later
When a port is validated, we check for the user to be the owner of
corresponding network, among other things. Sadly, this check requires a
plugin call to fetch the network, which goes straight into the database.
Now, if there are multiple ports to validate with current policy, and
the user is not admin, we fetch the network for each port, f.e. making
list operation on ports to scale badly.

To avoid that, we should postpone OwnerCheck (tenant_id) based
validations that rely on foreign keys, tenant_id:%(network:...)s, to as
late as possible. It will make policy checks avoid hitting database in
some cases, like when a port is owned by current user.

Also, added some unit tests to avoid later regressions:

DbOperationBoundMixin now passes user context into API calls. It allows
us to trigger policy engine checks when executing listing operations.

Change-Id: I99e0c4280b06d8ebab0aa8adc497662c995133ad
Closes-Bug: #1513782
2016-02-05 10:07:03 +01: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
armando-migliaccio 5ccfbb5b25 Fix required extensions mix-up
These features have their required extensions mixed up. There is
no reason why subnet pools (a core extension) depends on a non
core extension like router. On the other end, DNS does indeed
depends on it.

Related-bug: #1538623

Change-Id: If7e3566159919f1178373e3425310d457983f8ac
2016-01-28 15:42:58 -08:00
Bhagyashri Shewale 88e899f7a0 Fix module's import order
Made corrections in import order for built-in, third party and
project specific modules as per OpenStack import standards [1].

[1] http://docs.openstack.org/developer/hacking/#import-order-template

Change-Id: I899deefd6ee4732d6c0afd17a5afbe42b0fa37ba
2016-01-22 06:38:42 -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
check.

This code was taken from commit 0bea84ac20fe498bd08f7212a0017196c8cb0812
in Nova.

Change-Id: I36d07cade687690dc02a8f6cc3d70f5d00caf112
Co-Authored-By: ChangBo Guo(gcb) <glongwave@gmail.com>
2015-10-29 07:57:31 -07:00
Miguel Lavalle 2d68a0ed42 Eliminate autoaddress check for DNS integration
The autoaddress check for DNS integartion is not required anymore. It is
removed from the DB plugin. This check was being performed to reflect
incorrect functionality in the DHCP agent as indicated in bug
https://bugs.launchpad.net/neutron/+bug/1498665

Change-Id: I4b00618c328567f998765ed9a023c4c50d950b2b
Closes-Bug: #1497450
2015-09-22 18:14:34 -05:00
Miguel Lavalle 3d28fc0bfc Add dns_label processing for Ports
Functionallity is added to enable users to specify a dns_label field during
port creation and update. This dns_label field will be used for DNS resolution
of the hostname in dnsmasq and also will be used when Neutron can integrate
with external DNS systems.

Change-Id: I6beab336dfd9b70b1af6e975939c602047faa651
DocImpact
APIImpact
Closes-Bug: #1459030
Implements: blueprint internal-dns-resolution
2015-08-24 17:26:35 -05:00