From c5f7694b0debf9f48e95d798d3f0006be8da246a Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Fri, 15 Oct 2021 13:18:00 +0000 Subject: [PATCH] [OVN] Add the VIF details "connectivity" parameter In [1], the parameter was included in the mech driver "vif_details" member, instead of adding it in each defined VIF type, "ovs" and "vhostuser". [1]https://review.opendev.org/c/openstack/networking-ovn/+/678599 NOTE: this patch differs from the master one (in "Y" release) due to LP#1959125. Because the fix for this bug implies a change in neutron-lib, this patch addresses the issue by leaving the connectivity parameter in the OVN mech driver "vif_details" dictionary, thus "_check_drivers_connectivity" can properly check it. Conflicts: neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py Closes-Bug: #1947378 Change-Id: Ie9676fb2869cbf5b5cba9a7b27f2bfbbe0eab458 (cherry picked from commit b871dabdf433d2393551de6597d43774ed6cf1e4) (cherry picked from commit 6be2df7eb5969e0b5440ccd53a1fe19029870fe7) --- .../drivers/ovn/mech_driver/mech_driver.py | 13 +++++++-- .../ovn/mech_driver/test_mech_driver.py | 28 +++++++++++-------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py b/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py index 9011035a0a1..075e9e7675c 100644 --- a/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py +++ b/neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py @@ -163,14 +163,23 @@ class OVNMechanismDriver(api.MechanismDriver): portbindings.VNIC_MACVTAP] self.vif_details = { portbindings.VIF_TYPE_OVS: { - portbindings.CAP_PORT_FILTER: self.sg_enabled + portbindings.CAP_PORT_FILTER: self.sg_enabled, + portbindings.VIF_DETAILS_CONNECTIVITY: + portbindings.CONNECTIVITY_L2, }, portbindings.VIF_TYPE_VHOST_USER: { portbindings.CAP_PORT_FILTER: False, portbindings.VHOST_USER_MODE: portbindings.VHOST_USER_MODE_SERVER, - portbindings.VHOST_USER_OVS_PLUG: True + portbindings.VHOST_USER_OVS_PLUG: True, + portbindings.VIF_DETAILS_CONNECTIVITY: + portbindings.CONNECTIVITY_L2, }, + # NOTE(ralonsoh): for stable releases, this parameter is left here + # to allow "_check_drivers_connectivity" to check the OVN mech + # driver connectivity correctly. This addresses LP#1959125, that + # in master branch ("Y") was solved by adding a "connectivity" + # property to the "MechanismDriver" class. portbindings.VIF_DETAILS_CONNECTIVITY: portbindings.CONNECTIVITY_L2, } diff --git a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py index 3633449a1dc..5ee1ea8ea1e 100644 --- a/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py +++ b/neutron/tests/functional/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +import copy import functools import re @@ -36,6 +37,16 @@ from neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb import ovn_client from neutron.tests import base as tests_base from neutron.tests.functional import base +VHU_MODE = 'server' +OVS_VIF_DETAILS = { + portbindings.CAP_PORT_FILTER: True, + portbindings.VIF_DETAILS_CONNECTIVITY: portbindings.CONNECTIVITY_L2} +VHOSTUSER_VIF_DETAILS = { + portbindings.CAP_PORT_FILTER: False, + 'vhostuser_mode': VHU_MODE, + 'vhostuser_ovs_plug': True, + portbindings.VIF_DETAILS_CONNECTIVITY: portbindings.CONNECTIVITY_L2} + class TestPortBinding(base.TestOVNFunctionalBase): @@ -44,7 +55,6 @@ class TestPortBinding(base.TestOVNFunctionalBase): self.ovs_host = 'ovs-host' self.dpdk_host = 'dpdk-host' self.invalid_dpdk_host = 'invalid-host' - self.vhu_mode = 'server' self.add_fake_chassis(self.ovs_host) self.add_fake_chassis( self.dpdk_host, @@ -101,12 +111,10 @@ class TestPortBinding(base.TestOVNFunctionalBase): def test_port_binding_create_port(self): port_id = self._create_or_update_port(hostname=self.ovs_host) self._verify_vif_details(port_id, self.ovs_host, 'ovs', - {'port_filter': True}) + OVS_VIF_DETAILS) port_id = self._create_or_update_port(hostname=self.dpdk_host) - expected_vif_details = {'port_filter': False, - 'vhostuser_mode': self.vhu_mode, - 'vhostuser_ovs_plug': True} + expected_vif_details = copy.deepcopy(VHOSTUSER_VIF_DETAILS) expected_vif_details['vhostuser_socket'] = ( utils.ovn_vhu_sockpath(cfg.CONF.ovn.vhost_sock_dir, port_id)) self._verify_vif_details(port_id, self.dpdk_host, 'vhostuser', @@ -114,7 +122,7 @@ class TestPortBinding(base.TestOVNFunctionalBase): port_id = self._create_or_update_port(hostname=self.invalid_dpdk_host) self._verify_vif_details(port_id, self.invalid_dpdk_host, 'ovs', - {'port_filter': True}) + OVS_VIF_DETAILS) def test_port_binding_update_port(self): port_id = self._create_or_update_port() @@ -122,13 +130,11 @@ class TestPortBinding(base.TestOVNFunctionalBase): port_id = self._create_or_update_port(port_id=port_id, hostname=self.ovs_host) self._verify_vif_details(port_id, self.ovs_host, 'ovs', - {'port_filter': True}) + OVS_VIF_DETAILS) port_id = self._create_or_update_port(port_id=port_id, hostname=self.dpdk_host) - expected_vif_details = {'port_filter': False, - 'vhostuser_mode': self.vhu_mode, - 'vhostuser_ovs_plug': True} + expected_vif_details = copy.deepcopy(VHOSTUSER_VIF_DETAILS) expected_vif_details['vhostuser_socket'] = ( utils.ovn_vhu_sockpath(cfg.CONF.ovn.vhost_sock_dir, port_id)) self._verify_vif_details(port_id, self.dpdk_host, 'vhostuser', @@ -137,7 +143,7 @@ class TestPortBinding(base.TestOVNFunctionalBase): port_id = self._create_or_update_port(port_id=port_id, hostname=self.invalid_dpdk_host) self._verify_vif_details(port_id, self.invalid_dpdk_host, 'ovs', - {'port_filter': True}) + OVS_VIF_DETAILS) class TestPortBindingOverTcp(TestPortBinding):