Commit Graph

28 Commits (0634dcc6d0f08c18c69a2c360a2c5c0581ec7bb6)

Author SHA1 Message Date
Nurmatov Mamatisa 129b823a8b use payloads for PORT AFTER_UPDATE events
This patch switches over to callback payloads for PORT
AFTER_UPDATE events.

Change-Id: I5c00eae155afa6c0fc8e3956bc39edbeca3ea1e7
2 years ago
Nurmatov Mamatisa 69ef824069 Use payloads for TRUNK and SUBPORTS callbacks
This patch switches the code over to the payload style of callbacks [1]
for TRUNK and SUBPORTS events. As needed existing callbacks are shimmed
to support both payload and kwarg style callbacks. These shims will be
removed once all callbacks are switched over to payloads.
Also the neutron.services.trunk.callback module is removed as consumers
will no longer need the TrunkPayload therein.

NeutronLibImpact

[1]
https://docs.openstack.org/neutron-lib/latest/contributor/callbacks.html

Change-Id: Ie302b48b283f8780072b5c9e2bc8787d87c11794
2 years ago
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
3 years ago
Bence Romsics a90654ae5a Revert "Subcribe trunk & subport events to set subport id"
This reverts commit 8ebc635a18.

The reverted commit does mass update on all subports of a trunk.
This is not in line with the original design since it causes huge
api-side performance effects.

I think that's the reason why we started seeing gate failures of
rally_openstack.task.scenarios.neutron.trunk.CreateAndListTrunks
in neutron-rally-task.

Change-Id: I6f0fd91c62985207af8dbf29aae463b2b478d5d2
Closes-Bug: #1870110
Related-Bug: #1700428
3 years ago
ZhaoBo 8ebc635a18 Subcribe trunk & subport events to set subport id
Introduce a callback function in trunk plugin to receive after_create
and after_delete events for the trunk and subport resources This
function will set the subport device_id to trunk_id to prevent nova and
neutron from reusing it.

Closes-Bug: #1700428
Co-Authored-By: Nate Johnston <nate.johnston@redhat.com>
Change-Id: I97fe59752f9ef2cbe0376cd6ee0739660f5937ad
3 years ago
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
4 years ago
Boden R 88cca4cabe use trunk constants from neutron-lib
The trunk constants now live in neutron-lib. This patch consumes them
by removing neutron.services.trunk.constants and using them from
neutron-lib instead.

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

NeutronLibImpact

Change-Id: I4445c44c7e321d0fc35976d4d855c148bb9a3b18
4 years ago
Boden R ff70e20acc use neutron-lib trunk resource names
The trunk callback resource names now live in neutron-lib [1].
This patch switches over to use those constants from lib and they
will be removed from neutron in a later patch once consumers switch
over to lib as well.

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

Change-Id: I79dfe76c1b698fe634393e469157014f1914cc8e
4 years ago
Doug Wiegley 8914f8247f Update neutron files for new over-indentation hacking rule (E117)
Change-Id: I594e2d1238f6ffa3c1039624e3b3ed6569485837
4 years ago
Huifeng Le 6b54669694 Enable delete bound trunk for linux bridge agent
For agent such as linux bridge which allows creating trunk on
bound port, this patch provides a fix to allow deleting trunk
without unbound port first. And it will help to keep the port
(trunk's parent port) working while deleting the trunk.

Co-Authored-By: Allain Legacy <Allain.legacy@windriver.com>

Closes-Bug: #1794424
Story: 2003889

Change-Id: Iae2ae535bf3ba1548136bf3fe4306a42bad4e635
5 years ago
Boden R 537bfb9a1c use callback payloads for PRECOMMIT_UPDATE events
This patch switches callbacks over to the payload object style events
[1] for PRECOMMIT_UPDATE based notifications. To do so a DBEventPayload
object is used with the publish() method to pass along the related data.
In addition a few UTs are updated to work with the changes. Finally
a few shims are put into place to allow PRECOMMIT_UPDATE based events to
use payloads while still supporting the existing kwarg style events.

NeutronLibImpact

[1] https://docs.openstack.org/neutron-lib/latest/contributor/callbacks.html#event-payloads

Change-Id: Ie6d27df01cd7b87894efc80946d41eb1ebe25bef
5 years ago
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
6 years ago
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
6 years ago
Armando Migliaccio 1e36e9beb8 Reuse plugin's update method for changing trunk status
This has the effect of triggering notifications,
which may turn out to be useful to some drivers.

Change-Id: I02e268a413bfa7fe9f36fcece16886840a6fb0c6
7 years ago
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
7 years ago
Jenkins 252830bb6c Merge "Revisit support for trunk segmentation types" 7 years ago
Armando Migliaccio fb5c043d0d Revisit support for trunk segmentation types
This patch improves how the trunk plugin supports future
segmentation types and how it can handle multi-driver
deployments where each driver may have its own set of
supported segmentation types. It does so by:

a) removing the existing segmentation type registration mechanism;
   this has become superseded by how drivers advertise their
   capabilities and register themselves with the plugin.
b) introducing a new compatibility check that makes the plugin
   fails to load in case of conflicts: for multi-drivers environments
   a common set of segmentation types must be found for the plugin
   to load successfully. In case of single driver deployments,
   a driver can bring its own segmentation type.

Partially-implement: blueprint vlan-aware-vms

Change-Id: I0bd8b479c07945c65e14d4b59dfbcc1bc9a85a88
7 years ago
Ryan Tidwell dc4c8ab7c1 Set trunk status to DOWN when parent port is unbound
This patch ensures that trunk status is set to DOWN when its
parent port is unbound. This typically occurs when the instance
using the parent port is deleted in Nova.

Change-Id: I2673d2dd2d1dfd8eaabab66c009311cf4c143734
Partially-implements: blueprint vlan-aware-vms
7 years ago
Ryan Tidwell c3f1308ec6 Implement state management for trunks
This implements state management for trunks, allowing the trunk
state machine to be driven by the various events in the
lifecycle of a trunk. All events are handled here with the exception
of the unbinding of the parent port of a trunk.

Change-Id: I08341317f2cf6f4d1fc798773448ca0a79b242f5
Partially-implements: blueprint vlan-aware-vms
7 years ago
Armando Migliaccio 42f2ba88a5 Allow bound ports to be trunked if the driver can support it
Some drivers, like the Open vSwitch one, may restrict the creation of a
trunk from a bound port (i.e. prevents from creating trunks after a VM
is already booted on the port).

This limitation frees us from worrying about dataplane migrations for OVS
as trunk ports and regular ports are wired differently.

However, other drivers, like the Linux Bridge one, may not be affected by
this limitation, and the existing rule should be relaxed to allow the
operation based on whether not the driver can support it.

Partially-implements: blueprint vlan-aware-vms

Change-Id: Ia938eb7cc845f6f144924acdb0e333d23516fcca
7 years ago
Armando Migliaccio 46b6e129ff Add scaffolding for trunk plugin/server-side driver integration
This patch introduces a framework and enhancements that allow the trunk
plugin to support multiple trunk drivers that integrate with Neutron core
technologies. A mechanism to validate the deployment configuration is
provided so that the trunk plugin can verify that it can start correctly.
Fail fast is desired to give prompt feedback to the operator in case of
configuration inconsistencies.

The OVS driver is developed as a proof of concept and the Linux Bridge
driver will be added as a follow up patch.

Partially-implements: blueprint vlan-aware-vms

Change-Id: I5f9f8845e4108754748be3b64cce250c06e20f1f
7 years ago
Armando Migliaccio dee5544446 Introduce state management for trunk resources
A trunk is a complex resource. This patch introduces the
states and documents the state machine for the trunk resource.

Only user initiated state transitions are introduced in this
patch. Driver-initiated state transitions will be introduced
as follow up.

Partially-implements: bp/vlan-aware-vms

Change-Id: I0446e26f9ee5193a3270336ac64d0186fe5a6c7b
7 years ago
Rawlin Peters 6877b47105 Add notifications for trunk CRUD and standardize payload
Registry notifications should be added for trunk create/update/delete,
and SDN controllers as subscribers will need more callbacks as PRECOMMIT
events.

A standardized notification payload will consist of the following:
- context
- trunk_id
- current_trunk
- original_trunk
- subports

This standardized payload will be used in all trunk-related
notifications (trunk create/update/delete and subport add/remove) and
represents the maximum possible amount of information that can be given
in order to future-proof them.

As a bug fix, AFTER_REMOVE event on subport shouldn't be called
during the db transaction, but after the db commit.

Partially-implements: blueprint vlan-aware-vms
Change-Id: Ic1f44fa53cf9f10bd029ea47824e8ba91a8ab485
Co-Authored-By: Isaku Yamahata <isaku.yamahata@intel.com>
7 years ago
Jenkins dcb43cf85e Merge "Prohibit deletion of ports currently in use by a trunk" 7 years ago
Rawlin Peters 620f8a66f9 Prohibit deletion of ports currently in use by a trunk
A port that is currently in use as a trunk port or a subport cannot be
deleted. The trunk or subport that the port is owned by must be deleted
first.

Partially-implements: blueprint vlan-aware-vms
Change-Id: I35aec716b44b85a686c9d0f8f591d7d1ec21a794
7 years ago
Armando Migliaccio b8f870d007 Revisit (add|remove)_subports request body
The neutronclient [1] expects to serialize a dictionary any
time there is a body in the request. The (add|remove)_subports
methods were expecting a list of dicts instead.

This patch rectifies the issue by assuming a dict in the
body of the format {'sub_ports': [<my-subports]}. This is
indeed the most conventional way to pass request data to
Neutron server, and it was overlooked during a past review.

This was discovered during development of the client side
patch [2].

[1] https://github.com/openstack/python-neutronclient/blob/master/neutronclient/v2_0/client.py#L292
[2] https://review.openstack.org/#/c/340624/

Partially-implements: blueprint vlan-aware-vms
Change-Id: I8d36c61dd877d0ccb73c18702ed64897b71f001b
7 years ago
Rawlin Peters 9d04f187db Emit registry events on subport addition/removal
When a list of subports has been added or removed from a trunk, the
registry should emit a corresponding event and pass the list of added or
removed SubPort objects as the payload.

Trunk agent RPC callbacks can then be subscribed to these events in
order to relay subport information to the agents.

Partially-implements: blueprint vlan-aware-vms
Change-Id: Icb8da23cdd2244da5183058c31d8acef22d78eaa
7 years ago
Ryan Tidwell 9cda319687 Enable CRUD for trunk ports
This patch enables basic CRUD operations on trunk ports and defines
related API extensions. Trunk ports and sub-ports can be persisted
in the Neutron model and are made visible through the API, but the
L2 agent is not notified and no trunk ports or subports are actually
instantiated on compute hosts.

This one of the main patches in the series that implement the end
to end functionality.

Partially-implements: blueprint vlan-aware-vms

Co-Authored-By: Armando Migliaccio <armamig@gmail.com>
Change-Id: I26453eb9a1b25e116193417271400994ac57e4c1
7 years ago