Commit Graph

32 Commits

Author SHA1 Message Date
Takashi Kajinami 656028f311 Remove logic for old LBaaS(v2)
There are some logic left which checks device owner values set by
LBaaS v1 or v2, but LBaaS was already retired in favor of Octavia.

Change-Id: Ieca7a29a45f0686babe68619ff9da133edd89dec
2023-11-28 11:27:02 +00:00
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
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 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
Boden R 03ec94ce5e use test tools from neutron-lib
This patch switches the code over to use neutron-lib's test tools module
where appropriate rather than using neutron's.
This includes removing the following functions/classes from neutron and
using them from lib instead:
- get_random_EUI
- get_random_ip_network
- reset_random_seed
- OpenFixture

Change-Id: I0fbfcc7919f1b17b6bb0026fa9b98f157168255e
2019-06-05 06:21:04 -06:00
Boden R 6a24efcb70 use payloads for AGENT BEFORE_DELETE callbacks
This patch switches BEFORE_DELETE callback events for AGENT resources
over to the payload style args use a DBEventPayload object. In addition,
the _delete_mac_associated_with_agent is now refactored into it's own
method to allow the context parameter to be parsed by
retry_if_session_inactive.

NeutronLibImpact

Change-Id: I0af951f4346f9290c2eba6aad17f772fbf27bb2f
2018-10-03 09:59:24 +00:00
Boden R e4348eb1e1 use retry_db_errors from neutron-lib
The externally consumed APIs from neutron.db.api were rehomed into
neutron-lib with https://review.openstack.org/#/c/557040/

This patch consumes the retry_db_errors function from lib by:
- Removing retry_db_errors from neutron.db.api
- Updating the imports for retry_db_errors to use it from lib
- Using the DB API retry fixture from lib in the UTs where applicable
- Removing the UTs for neutron.db.api as they are now covered in lib

NeutronLibImpact

Change-Id: I1feb842d3e0e92c945efb01ece29856335a398fe
2018-07-16 08:10:54 -06:00
Boden R 2324640dd1 use DVRMacAddressNotFound exception from neutron-lib
Commit I88e1aa2acf22389f69cb7d5704c80a5eb72a9bbe rehomed the
DVRMacAddressNotFound to neutron-lib. This patch consumes it by using
lib's version and removing neutron's version.

NeutronLibImpact

Change-Id: I70d1244c3bbf7664e15534e90a9d9b47e9c6e2f1
2018-02-12 12:45:18 -07:00
Boden R 5ae7efb913 use dvr api def from neutron-lib
The dvr extension's API definition was rehomed into neutron-lib with
commit I6d98e83287833882515240d7db1faa4a1deb7da1
This patch consumes it by removing the rehomed code and using the
APIExtensionDescriptor for the extensions parent class.

NeutronLibImpact

Change-Id: Id5f0be33b036370b7545258a321830fdaa4dc0da
2017-11-13 10:27:16 -07:00
Brian Haley d0b68181a0 Remove deprecated get_random_mac()
get_random_mac() was marked for deprecation in
Queens, remove it and use the one from neutron-lib.

Change-Id: Ibcd3831a9ed419355a3d7969bd256b4b4bab6173
2017-09-22 17:38:58 -04:00
tonytan4ever 071cb905f3 DistributedVirtualRouter mac address to OVO
This patch introduces and integrates Oslo-Versioned Objects for the
DistributedVirtualRouter mac address model class.

Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
Co-Authored-By: Victor Morales<victor.morales@intel.com>
Change-Id: I3b8a213a7daf95d2492b48ae59d3ad534911e1bb
2017-07-20 17:43:55 +00: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
Boden R 7bd521e7ce use neutron_lib's portbindings api-def
Neutron-lib 1.1.0 is now out and contains the portbindings
API definition (as per commit [1]). This patch moves neutron
references over to the neutron-lib version.

NeutronLibImpact
- Consumers using the public constants within neutron's
portbindings API extension must now use the values
from neutron-lib.

[1] 87e42f993c07ae320159d5123662ee9f3bd4d903

Change-Id: I669af9b4c712877772d91a03857ab108714001d4
2017-03-31 09:16:22 -06:00
Trevor McCasland ae3b344be3 use neutron_lib's get_random_mac
Neutron-lib 1.1.0 is now out and contains the get_random_mac
definition[1]. This patch moves neutron references over to
the neutron-lib version.

NeutronLibImpact

[1] ee0f5b2ab27c828cfedb771735d237a968423da2

Change-Id: I28a2a1d85a85461f7a4344b86d18da7f68066c95
2017-03-07 09:13:47 -06: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
Jenkins 1111fc61a1 Merge "Use new enginefacade for dvr mac db" 2017-01-18 12:50:24 +00:00
Ann Kamyshnikova decbf0c958 Use new enginefacade for dvr mac db
Usage reader and writer for db operations.

Partially-Implements blueprint: enginefacade-switch

Change-Id: I6979c8d3382d8c1a97d90f7929a03a2886e2491b
2017-01-13 13:06:06 +00:00
Kevin Benton 7eba573e54 Fix some slow unit tests
- patch DB retry count for tests excercising retry decorator.
  These tests were taking 40 seconds per run (one used by 4 classes)
  by going through the full retry count with backoff. ~240 seconds of
  CPU time lost to them.
- Adjust vsctl_timeout down on ofport retry test.
  This one was taking up to 10 seconds with the default timeout.

TrivialFix
Change-Id: Iabe99c06abde81ced7e8dfa48bfe8b066c59ce70
2016-12-08 14:11:34 -08: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
Jenkins 552adc9e1c Merge "Deterministic ordering of fixed_ips" 2016-10-07 11:49:01 +00:00
Kevin Benton bd1c454c4f Deterministic ordering of fixed_ips
This adds an order_by clause to the fixed_ips relationship
on the port object to ensure that the fixed_ip ordering is
consistent between a create, an update, and a get request
for a port. Without it we were at the mercy of the sql backend
to determine how it felt like ordering them on the join condition.

Closes-Bug: #1630410
Change-Id: I523e0ab6e376f5ff6205b1cc1748aa6d546919cb
2016-10-07 00:40:01 -07:00
tonytan4ever 509bc4c2ab Relocate dvr model
As there would be issue of cyclic imports while implementation of
Oslo-Versioned Objects for DVR which has db models definition and
mixins in same file, this patch will relocate DVR models.

Change-Id: I4005570c7507ae9c28fd2910b368e4fdf5e603b0
Co-Authored-By: Victor Morales <victor.morales@intel.com>
Partial-Bug: #1597913
2016-10-04 08:41:33 +00:00
Jakub Libosvar 766abb752a Make pep8 job great again
There is a bug in pep8, when 'select' used, it omits all default checks
and runs only those specified by 'select'.  We got hit by this issue
since I2d26534230ffe5d01aa0aab6ec902f81cfba774d was merged which lead to
almost no static checks in pep8 job.

Also note that off_by_default decorator has no effect for now because
factory in hacking is triggered after ignored checks are collected.
There will be a follow-up patch for that in order to make pep8 doing
its job quickly.

[1] https://github.com/PyCQA/pycodestyle/issues/390

Related-Bug: 1594756
Change-Id: I8e27f40908e1bb4307cc7c893169a9d99f3433c4
2016-06-21 16:23:51 +00:00
Carl Baldwin 1554cee9e2 Obsolete mac_generation_retries and deprecate the option
As discussed in this patch [1] this option didn't come from any actual
user-encountered problem and is now effectively obsolete for its
original purpose anyway.  In the interest of cleaning up options that
aren't of any real use, this patch obsoletes this one immediately and
marks it deprecated for removal in Ocata.

TrivalFix

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

Change-Id: I58003d5b07e28c7254ff836dec937f699bc83112
2016-06-20 12:31:30 -06: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
Kevin Benton 92527c2de2 Clear DVR MAC on last agent deletion from host
Once all agents are deleted from a host, the DVR MAC generated
for that host should be deleted as well to prevent a buildup of
pointless flows generated in the OVS agent for hosts that don't
exist.

Closes-Bug: #1568206
Change-Id: I51e736aa0431980a595ecf810f148ca62d990d20
2016-04-09 08:17:45 -07:00
Oleg Bondarev cbc737aa18 Optimize get_ports_on_host_by_subnet() dvr rpc handler
Make one db query to get all needed ports.
No need to fetch all ports on the subnet and iterate through
them.

Change-Id: I76a8a75905a7ec4c202583f01b62f2aefb433026
2016-01-18 14:04:52 +03:00
Oleg Bondarev 0a00205c2a Fix get_subnet_for_dvr() to return correct gateway mac
Fix filters to get the right gateway port for a subnet.
Wrong filters led to random port's mac being returned which may cause
side effects. See bug for details.

Closes-Bug: #1530179
Change-Id: I8368255f00ab3e9586c8ff28dfe6739541000810
2016-01-11 09:42:29 +03:00
Assaf Muller ee6e648bf5 Remove unused delete_dvr_mac_address method
I looked backed to stable/kilo and stable/liberty,
I'm not sure this method was ever used, so there is
no upgrade concern either.

Change-Id: Id72ee9114a8c3f1e49314c03dbab0b15b327eb93
2015-11-16 15:56:47 -05:00
Ihar Hrachyshka 7a2a85623d oslo: migrate to namespace-less import paths
Oslo project decided to move away from using oslo.* namespace for all their
libraries [1], so we should migrate to new import path.

This patch applies new paths for:
- oslo.config
- oslo.db
- oslo.i18n
- oslo.messaging
- oslo.middleware
- oslo.rootwrap
- oslo.serialization
- oslo.utils

Added hacking check to enforce new import paths for all oslo libraries.

Updated setup.cfg entry points.

We'll cleanup old imports from oslo-incubator modules on demand or
if/when oslo officially deprecates old namespace in one of the next
cycles.

[1]: https://blueprints.launchpad.net/oslo-incubator/+spec/drop-namespace-packages

Depends-On: https://review.openstack.org/#/c/147248/
Depends-On: https://review.openstack.org/#/c/152292/
Depends-On: https://review.openstack.org/#/c/147240/

Closes-Bug: #1409733
Change-Id: If0dce29a0980206ace9866112be529436194d47e
2015-02-05 15:09:32 +01:00
Salvatore Orlando 9bf0e66544 Remove auto-generation of db schema from models at startup
This patch removes the Neutron capability of creating database tables
from sqlalchemy models for all those model classes for which
a table is not found in the database schema.
Migrations should be the official and only solution for creating and
managing the Neutron db schema.
This patch also adapts unit tests in order to ensure test schemas
are still correctly created.

DocImpact
Update deployment documentation accordingly.

Closes-Bug: #1207402

Change-Id: Ie4ee5507888ecad5f6dc32ce7a029c43014687a2
Co-Authored-By: Henry Gessau <gessau@cisco.com>
2014-08-15 17:21:17 -04:00
Vivekanandan Narasimhan 10579d28d7 L2 Model additions to support DVR
This patch introduces the models, the DB migrations
and the config options required by the L2 layer to
support DVR east/west traffic.

These changes will be used by the control-plane made
of ML2, L2pop and L2 agent.

Two new configuration options have been introduced:
'dvr_base_mac' is used to set DVR MAC addresses apart
from tenant ones (every distributed router will have
ports being created on compute hosts) and
'enable_distributed_routing' is used to enable dvr
support in the L2 agent. This gives the capability of
rolling out the dvr functionality in stages.

Partially-implements: blueprint neutron-ovs-dvr

DocImpact

Change-Id: Iab6505f239d2c4c9bcbf4e32a292d7b4b5320c8e
Authored-by: Vivekanandan Narasimhan <vivekanandan.narasimhan@hp.com>
Co-Authored-By: Armando Migliaccio <armamig@gmail.com>
2014-07-17 07:53:14 -07:00