Commit Graph

169 Commits

Author SHA1 Message Date
Takashi Kajinami 6a5859fc07 Fix python shebang
The current shebang requires /usr/bin/python which is not available in
Ubuntu Jammy by default.

This also fixes some unnecessary/missing shebangs.

Change-Id: Ib25a0a7f39f68f43622609391710dd3b1abc2d00
2023-10-17 16:02:25 +00:00
Brian Haley 10ff1caaca Fix some new pylint "C" warnings
After updating pylint, it started emitting additional "C"
warnings in some cases, fix some of them.

  use-implicit-booleaness-not-comparison,
  use-maxsplit-arg,
  unnecessary-dunder-call

Trivialfix

Change-Id: I53558e6bc52aaea590f6c147aacc062c08099464
2023-05-18 21:54:38 -04:00
Takashi Kajinami 17106dc6f5 ml2: Use the base module to register common ml2 agent config
The neutron.plugins.ml2.drivers.agent.config module registers options
commonly used by the ml2 agents but in fact it is used only by linux
bridge agent and macvtap agent.

This change makes all ml2 agents use that base module consistently in
individual config modules.

Change-Id: Ib3ec8a8eaf347721bb06f092a0887e62f3a6bffd
2022-06-24 12:58:31 +00:00
Jakub Libosvar 4d3a274765 Don't register config options on imports
Importing some modules lead to registering config options that may
collide with config options from a project that calls the import. This
patch wraps the side effect that registers config options into a
function that needs to be called in case the caller wants to register
the options.

This solution is also not perfect as it guards the common options to be
registered only once even if the function is called multiple times. This
is to solve problems in unittests, ideally we should always call the
function just once even in our testing suites.

Resolves-Bug: #1968606
Change-Id: Ic1532eb8de887ff1b1085206df11f53e22f7f524
Signed-off-by: Jakub Libosvar <libosvar@redhat.com>
2022-04-13 05:49:15 +00:00
Rodolfo Alonso Hernandez 16a793af19 When creating a VXLAN interface, a device is mandatory
"IPWrapper.add_vxlan" method must have "dev" parameter as possitional
argument. A VXLAN interface must be always created on top of an existing
network device:
  https://www.kernel.org/doc/Documentation/networking/vxlan.txt

Closes-Bug: #1954316
Change-Id: Ia082f8531ffcc1599206124774599dcdb500274a
2021-12-10 12:15:18 +00:00
Anthony Timmins 4cd11f4dee Use local and ip address to create vxlan interface
Attempting to terminate a vxlan on the lo interface with
multiple ip addresses fails. This seems to be because only
the first ip address on the interface is used. If this address
is invalid for vxlan creation (ie. 127.0.0.1), the vxlan
interface will be created, but will not have a source ip
address, and will therefore be non-functional. To remedy this
issue, when L2population is used, we can set the local
argument to the local_ip, thus ensuring the intended ip
address is configured.

Closes-Bug: 1929998
Change-Id: I9c54a268fc4ef9705637556ecba161bd6523a047
Signed-off-by: Anthony Timmins <atimmins@datto.com>
2021-06-01 11:02:21 -04:00
Rodolfo Alonso Hernandez 3df21ee472 Implement "FdbInterface" with Pyroute2
Change-Id: I4b03151ed10b1c5af36fd803e96e9d2f95e88247
Story: #2007686
Task: #41494
2020-12-24 17:00:06 +00:00
Rodolfo Alonso Hernandez b9e725ed72 Change the logic of "catch_exceptions"
Changed the logic of decorator "catch_exceptions" to provide a
Pythonic output: if succeeds, returns True; if fails, returns False.

Change-Id: Idbf2ffb4ef403f343973bde3b3599f9cd3aaddf2
Story: #2007686
Task: #39975
2020-12-24 16:27:13 +00:00
Brian Haley 055036ba2b Improve terminology in the Neutron tree
There is no real reason we should be using some of the
terms we do, they're outdated, and we're behind other
open-source projects in this respect. Let's switch to
using more inclusive terms in all possible places.

Change-Id: I99913107e803384b34cbd5ca588451b1cf64d594
2020-08-19 16:47:53 -04:00
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
Bernard Cafarelli 5ce0595803
Set process name for agents
Now that we use setproctitle for neutron-server workers (and
neutron-keepalived-state-change), this has the side effect of changing
the process name for agents, impacting some monitoring systems. More
details in launchpad bug.

This patch fixes it by setting the name with setproctitle to:
agent name (original process name).

Also use the newly introduced name constants to replace existing
hardcoded uses.

Change-Id: I74c3a4d3e9f833752571a75f196560cd45529385
Closes-Bug: #1881297
2020-07-01 12:28:29 +02:00
Tamerlan Abu edfe7daf04 No rpc_response_max_timeout in LB-agent
Adds support for rpc_response_max_timeout in LB-agent.
Change-Id: I1c5dcd1642019cb8c327722819f753b2b5b7137c
Closes-Bug: #1880934
2020-06-01 15:25:20 +00:00
Rodolfo Alonso Hernandez 7593f95a74 Set a default IP route metric in ip_lib.list_ip_routes
By default, if no metric is defined, the kernel interprets the
highest value (0).

The current implementation, using pyroute2, is a translation from
the CLI command "ip route". This command uses the netlink API to
communicate with the kernel. In IPv6, when the metric value is not
set is translated as 1024 as default [1].

[1]https://access.redhat.com/solutions/3659171

Change-Id: I0c5f9e320bbbf314a2d6a22c515bf903de84cdaf
Related-Bug: #1855759
2020-02-17 15:09:00 +00:00
Rodolfo Alonso Hernandez b99765df8f Use "via" in gateway dictionary in Linux Bridge agent
The gateway IP address in the gateway dictionary returned by
"ip_lib.list_ip_routes" is stored in "via".

"priority" parameter is changed to "metric", to match input and
output parameters.

Change-Id: I67ae473dca8d706f963c3b55b9410f9a79d7f32b
Closes-Bug: #1855759
2019-12-12 10:30:58 +00: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 e9e76ce4b7 use rpc agent topics from neutron-lib
There are a few places in neutron that are not yet using the agent
topics module from neutron-lib. This patch address them by:
- Removing neutron.agent._topics
- Switching all uses of topics over to use neutron-lib

NeutronLibImpact

Change-Id: Ic9699ca93cd6fe59ed575ab444c4a4f9456323b2
2019-04-15 09:02:55 -06:00
Brian Haley eaf990b2bc Fix pep8 E128 warnings in non-test code
Reduces E128 warnings by ~260 to just ~900,
no way we're getting rid of all of them at once (or ever).
Files under neutron/tests still have a ton of E128 warnings.

Change-Id: I9137150ccf129bf443e33428267cd4bc9c323b54
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
2019-03-12 21:22:33 +00:00
Boden R 68fd13af40 remove neutron.common.exceptions
Today the neutron common exceptions already live in neutron-lib and are
shimmed from neutron. This patch removes the neutron.common.exceptions
module and changes neutron's imports over to use their respective
neutron-lib exception module instead.

NeutronLibImpact

Change-Id: I9704f20eb21da85d2cf024d83338b3d94593671e
2019-02-01 14:35:00 -07:00
Yang Youseok aaf215b5a5 Convert instance method to staticmethod in linuxbridge_neutron_agent
Convert unnessary instance method to staticmethod so that any plugin
API can use the methods.

Closes-Bug: #1805356
Change-Id: Ic568f470b813b85cfa46aa46308480e2579f779c
2018-11-27 19:01:40 +09:00
Miguel Lavalle f7064f2b6c Add binding activation to the Linuxbridge agent
As part of the implementation of multiple port bindings [1], add binding
activation support to the linux bridge agent. This will enable the
execution with linux bridge agents of the complete sequence of steps
outlined in [1] during an instance migration:

1) Create inactive port bindings for destination host
2) Migrate the instance to the destination host and plug its VIFs
3) Activate the port bindings in the destination host
4) Delete the port bindings for the source host

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

Change-Id: I2c937cc0a551e5ce0e8534c4dd4384ec2ca92da1
Partial-Bug: #1580880
2018-07-19 15:12:20 -05:00
Miguel Lavalle f374697760 Add binding_deactivate method to Linux bridge agent
This commit adds a binding_deactivate method to the Linux bridge agent
to receive messages from the ML2 plugin when a binding is de-activated
for a port. After receiving that message, the agent un-plugs the
corresponding tap interface from the port's network bridge.

To support this, a binding_deactivate method is also added to the agents
notifier. Finally, the activate method in the ML2 plugin is updated to
use the binding_deactivate method in the agents notifier.

Change-Id: I3f4e34766791c472a2c81842190094f697baa05c
Partial-Bug: #1580880
2018-07-14 16:46:01 -05: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
Sławek Kapłoński 60d62d3103 [Linuxbridge] Handle properly too big VXLAN MTU values
In case when MTU value configured for VXLAN network is
higher than physical device's MTU - VXLAN overhead
then Linuxbridge agent will not be able to create properly
vxlan interface with desired MTU value.
In patch [1] there was introduced validation if MTU of
physical device is big enough to create MTU with required
MTU value but it was working only for IPv4 tunnels as
for IPv6 overhead is bigger.

This patch changes this validation a bit and now it will
works properly for both IPv4 and IPv6  VXLAN tunnels.

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

Change-Id: Ib707312adb45dae7295884aba4ece6538d330d56
Related-Bug: #1744101
2018-04-24 12:16:43 +02:00
Zuul 7786f398fe Merge "Fix W503 pep8 warnings" 2018-04-18 05:58:39 +00:00
Boden R 410a83c89d use plugin common utils from neutron-lib
A bulk of the public APIs that are part of neutron.plugins.common.utils
were rehomed into neutron-lib with [1] and the remaining with [2].

This patch consumes [1] by:
- Removing the rehomed code from neutron.
- Removing the UTs that are no longer applicable.
- Leaving the functions in [2][3] in neutron.plugins.common.utils until
we release [2][3] and can consume it at which point we should be able to
remove the utils module.

NeutronLibImpact

[1] Iabb155b5d2d0ec6104ebee5dd42cf292bdf3ec61
[2] I2c0e4ef03425ba0bb2651ae3e68d6c8cde7b8f90
[3] I73f5e8ad7a1a83392094db846d18964d811b8bb2

Change-Id: I1d63cbea463e92e1d2e053f8e1a564ed52cb84f8
2018-04-17 12:06:28 -06:00
Brian Haley 90cd939047 Fix W503 pep8 warnings
Fix W503 (line break before binary operator) pep8 warnings
and no longer ignore new failures.

Trivialfix

Change-Id: I7539f3b7187f2ad40681781f74b6e05a01bac474
2018-04-17 14:22:58 +00:00
Zuul b6a984003d Merge "Have LB agent use ip_lib.ensure_device_is_ready()" 2018-04-03 01:47:49 +00:00
Sławek Kapłoński b6b23a8f77 Enable mutable config in Neutron
New releases of oslo.config support a 'mutable' parameter to Opts.
This is only respected when the new method mutate_config_files is
called instead of reload_config_files. Neutron delegates making this
call to oslo.service. This was provided in patchset
Icec3e664f3fe72614e373b2938e8dee53cf8bc5e

Further patches will be needed to make select config options be
marked as mutable. This change enables support for oslo provided
config options to be updated via SIGHUP such as log level.

Task: 6389
Story: 2001545

Change-Id: I9442965607f3248706464643c6d87a04edcae24e
2018-03-21 20:35:19 +00:00
Brian Haley b4f68ff211 Have LB agent use ip_lib.ensure_device_is_ready()
The linuxbridge agent was using its own version of
ensure_device_is_ready() called _bridge_exists_and_ensure_up(),
just use the one in ip_lib since it does an additional MAC
address check.

Trivialfix

Change-Id: I02cdbe40fddb220623e341b94edb3d8c96099581
2018-03-16 11:25:13 -04:00
Boden R ef93f7e7f0 use common agent topics from neutron-lib
The neutron.common.topics module was rehomed into neutron-lib with
commit Ie88b84949cbd55a4e7ad06341aab77b286cdc485
This patch consumes it by removing the rehomed module from neutron
and using the module from neutron-lib instead.

NeutronLibImpact

Change-Id: Ia4a4604c259ce862597de80c6deeb3d408bf0e95
2018-03-13 11:35:50 -06:00
Sławek Kapłoński e0223edf88 Switch ip addr add/del/flush commands to use pyroute2
This patch replaces usage of "ip addr add/del/flush" commands
with pyroute2 library.
This also switches from rootwrap to privsep when doing those
actions.

This patch adds also UT for _run_iproute_neigh/addr functions
from privileged module.

Change-Id: I6f4df391ec1899f8a4b10b50735dc9a79fa8483f
Related-Bug: #1492714
2018-03-09 23:09:25 +01:00
Zuul 4c2f666035 Merge "[Linuxbridge] Check if vxlan network MTU can be set" 2018-02-22 13:51:04 +00:00
Zuul 0b23d6f32e Merge "Fix a log formatting error on linuxbridge" 2018-02-22 00:30:09 +00:00
Hongbin Lu 2ac2c34eb1 Fix a log formatting error on linuxbridge
Change-Id: I76c547fdfb4b474d4c17716087215775c1539b08
2018-02-20 23:28:54 +00:00
Sławek Kapłoński db5fb02b11 [Linuxbridge] Check if vxlan network MTU can be set
In case when MTU value configured for VXLAN network is
higher than physical device's MTU - 50 (VXLAN overhead)
then Linuxbridge agent will log proper error message.

Change-Id: I2c1142877fee4ab2fa06e6e4d203c78a776d9591
Related-Bug: #1744101
2018-02-20 20:54:32 +01:00
Hongbin Lu 2a44b3fa3d Set mtu for VXLAN interface in linuxbridge
Change-Id: I169613ecf936b4484447d1ca0ed81e4cb5369ce2
Closes-Bug: #1744101
2018-02-15 23:45:22 +00:00
Ali Sanhaji 6bf0788da0 Adding DSCP mark and inheritance in OVS and LB tunnels outer header
Adding ability to set DSCP field in OVS tunnels outer header, or
inherit it from the inner header's DSCP value for OVS and linuxbridge.

Change-Id: Ia59753ded73cd23019605668e60cfbc8841e803d
Closes-Bug: #1692951
2018-01-17 10:54:46 +01:00
Zuul 569b51483b Merge "Use same instance of iptables_manager in L2 agent and extensions" 2018-01-05 19:19:57 +00:00
Sławek Kapłoński cbee0f9f88 Use same instance of iptables_manager in L2 agent and extensions
This commit adds common_agent_extension class which is agent API
for L2 extension drivers used e.g. by Linuxbridge agent.
This is necessary to be able to use instance of iptables_manager
used in firewall driver also in L2 extension drivers (like qos).

This patch refactors little bit iptables_manager code to make possible
to initialize e.g. mangle or nat table on demand, even if iptables
is created as "state_less"

Change-Id: I3b66e49b7f176124e8aea3eb96d0d465f1ab1ea0
Closes-Bug: #1736674
2018-01-05 11:07:32 +01:00
Brian Haley 7b8289253c Fix callers of get_devices_with_ip() to pass addresses
If callers of get_devices_with_ip(), or
device.addr.list(to=address) pass an ip_cidr, it
could match any ip_cidr in that range on the interface.
Callers need to pass the IP without the prefix portion in
order to match it exactly.  Added a helper utility to
strip the cidr part from a ip_cidr.

Determined the unit test for this can't actually check
this case since we are mocking the return value from
/sbin/ip, so modified it to just make sure the dict
is correct.

Added a functional test that adds two IP addresses in
the same IP range to verify that we actually filter
correctly when a 'to=IP' is specified.

Change-Id: I3a95b3bb72a43f322ad23892d8959398aac22a1c
Closes-bug: #1728080
2017-10-31 16:20:28 -04:00
Boden R 95f1e03446 use plugin constants from neutron-lib
neutron-lib contains a number of the plugin related constants from
neutron.plugins.common.constants. This patch consumes those constants
from neutron-lib and removes them from neutron. In addition the notion
of the dummy plugin service type is moved strictly into the test
package of neutron since it's not a real service plugin.

NeutronLibImpact

Change-Id: I767c626f3fe6159ab3abd6a7ae3cb9893b79bf66
2017-10-16 09:32:20 -06:00
Brian Haley bb6a9933de Remove unnecessary IPWrapper() creation
The LinuxBridgeManager class has already created a
local version of IPWrapper() at self.ip, just use it.

Trivialfix

Change-Id: I9524144c4762ab3f26c42c5dee967df5436e1a62
2017-09-29 14:12:40 -04:00
Rodolfo Alonso Hernandez bb550de3d7 Linux Bridge, remove unnecessary logic to retrieve bridge name
In [1], the function "get_existing_bridge_name" retrieves the value of a
dict using the method get. Before this, it checks if the key value used is
"True". This check is not needed using the dictionary "get" method.

[1] https://github.com/openstack/neutron/blob/11.0.0.0rc3/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py#L155

Change-Id: Iba020c6b297228ae48bbd2a19f540b0152570317
Closes-Bug: #1719275
2017-09-26 08:38:31 +00: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
Kevin Benton ca2399dbe0 Remove network_id from network_map on net delete
This removes the network_id from the network_map dict when
a network is deleted on the Linux Bridge agent.

Change-Id: I0bd3be91626fd7c4e258c35041bb92130ee23182
Closes-Bug: #1705185
2017-07-21 19:52:07 +00:00
Kevin Benton 499faa3074 Always try to delete bridge for ID on network_delete
If network_deletes are received before port creates
are processed, the agent might not have the network in
it's map even though it has a bridge to delete.

This adjusts the logic to always try to delete the bridge
corresponding to a network_id even if it's not in the
network_map yet.

Change-Id: I5e72bff2ffd9568f272ed48187ad543ab5a3d1ec
Closes-Bug: #1698271
2017-07-21 19:51:33 +00:00
Gyorgy Szombathelyi d7c4428525 Allow to set UDP ports for VXLAN in Linuxbridge agent
Introduce vxlan.{udp_srcport_min, udp_srcport_max and udp_dstport}
for setting the port range used for VXLAN communication.

Change-Id: I97999988090eee7aee9b533ac1dad2de95b29cbe
Closes-Bug: #1483853
DocImpact:  vxlan.{udp_srcport_min, udp_srcport_max and udp_dstport}
can be used to set UDP port numbers used for VXLAN in LinuxBridge
agent.
2017-07-07 10:53:44 +02:00
wlfightup ba5e846859 Linuxbridge agent: detect existing IP on bridge
If bridge IP address already exists, when we try and add
it an error will be raised.  Check for the existence of
the IP to avoid the error.

Closes-Bug: #1697926
Change-Id: I9aae3b4f0fab053e8c215887f58b983d9549582d
2017-06-15 22:01:51 -04:00
Ihar Hrachyshka 6ad51779f3 Revert "Use vif_type='tap' for LinuxBridge for consistency"
This reverts commit 1b987be2b5.

This probably triggered a race between nova and l2 agent when
hot-detaching VIFs.

Change-Id: I2fc20666d43942446878da358ccf4472e04ad94c
Related-Bug: #1696125
2017-06-08 11:27:59 -07:00
Jenkins 3c2ce67efe Merge "VXLAN multicast groups in linuxbridge" 2017-05-30 00:55:21 +00:00