summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentina Krasnobaeva <valentina.krasnobaeva@6wind.com>2018-05-31 18:25:40 +0200
committerValentina Krasnobaeva <valentina.krasnobaeva@6wind.com>2018-06-04 13:41:19 +0200
commit3076b4097f28cd7cd2464292c5cb016754f1244c (patch)
tree0be8795765ca0fe1bca748b4720dac204f0279e6
parentaa764eaafef41fd0ce28d3d8dbfd4283582d1671 (diff)
ml2_drivers/mech_ovs_fp: update get_vif_* function signatures
* Update signatures for get_vif_type and get_vif_details methods according to its prototypes from neutron/plugins/ml2/drivers/openvswitch/mech_driver/mech_openvswitch.py * Update portbindings library path in drivers modules and in its unit-tests. * Update import of mechanism drivers common API: module driver_api was renamed to api and replaced in neutron_lib.plugins.ml2 submodule. * test_mech_ovs_fp: * add portbindings.OVS_DATAPATH_TYPE with value 'system' in expected VIF_DETAILS dict, because now base mech_openvswitch.OpenvswitchMechanismDriver class adds this info for all vifs with type VIF_TYPE_OVS; * update expected values for portbindings.CAP_PORT_FILTER and portbindings.OVS_HYBRID_PLUG attributes because of according changings in mech_openvswitch.OpenvswitchMechanismDriver.VIF_DETAILS. Change-Id: I7e72e6e42f7077725768eaabaa3b19104d2e5db4 Signed-off-by: Valentina <valentina.krasnobaeva@6wind.com> Acked-by: Maxime Leroy <maxime.leroy@6wind.com>
Notes
Notes (review): Code-Review+2: Maxime Leroy <maxime.leroy@6wind.com> Workflow+1: Maxime Leroy <maxime.leroy@6wind.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 05 Jun 2018 07:45:16 +0000 Reviewed-on: https://review.openstack.org/571729 Project: openstack/networking-6wind Branch: refs/heads/master
-rw-r--r--networking_6wind/ml2_drivers/linuxbridge/mech_driver/mech_lb_fp.py14
-rw-r--r--networking_6wind/ml2_drivers/openvswitch/mech_driver/mech_ovs_fp.py16
-rw-r--r--networking_6wind/tests/unit/ml2_drivers/linuxbridge/mech_driver/test_mech_lb_fp.py2
-rw-r--r--networking_6wind/tests/unit/ml2_drivers/openvswitch/mech_driver/test_mech_ovs_fp.py12
4 files changed, 24 insertions, 20 deletions
diff --git a/networking_6wind/ml2_drivers/linuxbridge/mech_driver/mech_lb_fp.py b/networking_6wind/ml2_drivers/linuxbridge/mech_driver/mech_lb_fp.py
index 552848e..2cc3ae5 100644
--- a/networking_6wind/ml2_drivers/linuxbridge/mech_driver/mech_lb_fp.py
+++ b/networking_6wind/ml2_drivers/linuxbridge/mech_driver/mech_lb_fp.py
@@ -19,10 +19,10 @@ import datetime
19from networking_6wind.common import constants 19from networking_6wind.common import constants
20from networking_6wind.common.utils import get_vif_vhostuser_socket 20from networking_6wind.common.utils import get_vif_vhostuser_socket
21 21
22from neutron.extensions import portbindings
23from neutron.plugins.ml2 import driver_api
24from neutron.plugins.ml2.drivers.linuxbridge.mech_driver import ( 22from neutron.plugins.ml2.drivers.linuxbridge.mech_driver import (
25 mech_linuxbridge) 23 mech_linuxbridge)
24from neutron_lib.api.definitions import portbindings
25from neutron_lib.plugins.ml2 import api
26 26
27 27
28LOG = log.getLogger(__name__) 28LOG = log.getLogger(__name__)
@@ -93,20 +93,20 @@ class LBFPMechanismDriver(mech_linuxbridge.LinuxbridgeMechanismDriver):
93 self._get_fp_info(context) 93 self._get_fp_info(context)
94 94
95 if self.check_segment_for_agent(segment, agent): 95 if self.check_segment_for_agent(segment, agent):
96 context.set_binding(segment[driver_api.ID], 96 context.set_binding(segment[api.ID],
97 self.get_vif_type(agent), 97 self.get_vif_type(context, agent, segment),
98 self.get_vif_details(agent, context)) 98 self.get_vif_details(context, agent, segment))
99 return True 99 return True
100 else: 100 else:
101 return False 101 return False
102 102
103 def get_vif_type(self, agent): 103 def get_vif_type(self, context, agent, segment):
104 if self.fp_info is not None and self.fp_info['active']: 104 if self.fp_info is not None and self.fp_info['active']:
105 return portbindings.VIF_TYPE_VHOST_USER 105 return portbindings.VIF_TYPE_VHOST_USER
106 106
107 return self.vif_type 107 return self.vif_type
108 108
109 def get_vif_details(self, agent, context): 109 def get_vif_details(self, context, agent, segment):
110 VIF_BRIDGE = portbindings.VIF_TYPE_BRIDGE 110 VIF_BRIDGE = portbindings.VIF_TYPE_BRIDGE
111 if self.fp_info is not None and self.fp_info['active']: 111 if self.fp_info is not None and self.fp_info['active']:
112 if VIF_BRIDGE in self.fp_info['supported_plugs']: 112 if VIF_BRIDGE in self.fp_info['supported_plugs']:
diff --git a/networking_6wind/ml2_drivers/openvswitch/mech_driver/mech_ovs_fp.py b/networking_6wind/ml2_drivers/openvswitch/mech_driver/mech_ovs_fp.py
index 3daefdd..0f59d73 100644
--- a/networking_6wind/ml2_drivers/openvswitch/mech_driver/mech_ovs_fp.py
+++ b/networking_6wind/ml2_drivers/openvswitch/mech_driver/mech_ovs_fp.py
@@ -19,10 +19,10 @@ import datetime
19from networking_6wind.common import constants 19from networking_6wind.common import constants
20from networking_6wind.common.utils import get_vif_vhostuser_socket 20from networking_6wind.common.utils import get_vif_vhostuser_socket
21 21
22from neutron.extensions import portbindings
23from neutron.plugins.ml2 import driver_api
24from neutron.plugins.ml2.drivers.openvswitch.mech_driver import ( 22from neutron.plugins.ml2.drivers.openvswitch.mech_driver import (
25 mech_openvswitch) 23 mech_openvswitch)
24from neutron_lib.api.definitions import portbindings
25from neutron_lib.plugins.ml2 import api
26 26
27 27
28LOG = log.getLogger(__name__) 28LOG = log.getLogger(__name__)
@@ -93,22 +93,22 @@ class OVSFPMechanismDriver(mech_openvswitch.OpenvswitchMechanismDriver):
93 self._get_fp_info(context) 93 self._get_fp_info(context)
94 94
95 if self.check_segment_for_agent(segment, agent): 95 if self.check_segment_for_agent(segment, agent):
96 context.set_binding(segment[driver_api.ID], 96 context.set_binding(segment[api.ID],
97 self.get_vif_type(agent), 97 self.get_vif_type(context, agent, segment),
98 self.get_vif_details(agent, context)) 98 self.get_vif_details(context, agent, segment))
99 return True 99 return True
100 else: 100 else:
101 return False 101 return False
102 102
103 def get_vif_type(self, agent): 103 def get_vif_type(self, context, agent, segment):
104 if self.fp_info is not None and self.fp_info['active']: 104 if self.fp_info is not None and self.fp_info['active']:
105 return portbindings.VIF_TYPE_VHOST_USER 105 return portbindings.VIF_TYPE_VHOST_USER
106 106
107 return self.vif_type 107 return self.vif_type
108 108
109 def get_vif_details(self, agent, context): 109 def get_vif_details(self, context, agent, segment):
110 self.vif_details = super(OVSFPMechanismDriver, 110 self.vif_details = super(OVSFPMechanismDriver,
111 self).get_vif_details(agent, context) 111 self).get_vif_details(context, agent, segment)
112 112
113 VIF_OVS = portbindings.VIF_TYPE_OVS 113 VIF_OVS = portbindings.VIF_TYPE_OVS
114 if self.fp_info is not None and self.fp_info['active']: 114 if self.fp_info is not None and self.fp_info['active']:
diff --git a/networking_6wind/tests/unit/ml2_drivers/linuxbridge/mech_driver/test_mech_lb_fp.py b/networking_6wind/tests/unit/ml2_drivers/linuxbridge/mech_driver/test_mech_lb_fp.py
index 9d3a603..ce2e1be 100644
--- a/networking_6wind/tests/unit/ml2_drivers/linuxbridge/mech_driver/test_mech_lb_fp.py
+++ b/networking_6wind/tests/unit/ml2_drivers/linuxbridge/mech_driver/test_mech_lb_fp.py
@@ -19,8 +19,8 @@ from networking_6wind.common import constants
19from networking_6wind.common.utils import get_vif_vhostuser_socket 19from networking_6wind.common.utils import get_vif_vhostuser_socket
20from networking_6wind.ml2_drivers.linuxbridge.mech_driver import mech_lb_fp 20from networking_6wind.ml2_drivers.linuxbridge.mech_driver import mech_lb_fp
21 21
22from neutron.extensions import portbindings
23from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base 22from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base
23from neutron_lib.api.definitions import portbindings
24 24
25 25
26class LBFPMechanismBaseTestCase(base.AgentMechanismBaseTestCase): 26class LBFPMechanismBaseTestCase(base.AgentMechanismBaseTestCase):
diff --git a/networking_6wind/tests/unit/ml2_drivers/openvswitch/mech_driver/test_mech_ovs_fp.py b/networking_6wind/tests/unit/ml2_drivers/openvswitch/mech_driver/test_mech_ovs_fp.py
index a9f71eb..086e389 100644
--- a/networking_6wind/tests/unit/ml2_drivers/openvswitch/mech_driver/test_mech_ovs_fp.py
+++ b/networking_6wind/tests/unit/ml2_drivers/openvswitch/mech_driver/test_mech_ovs_fp.py
@@ -20,10 +20,12 @@ from networking_6wind.common import constants
20from networking_6wind.common.utils import get_vif_vhostuser_socket 20from networking_6wind.common.utils import get_vif_vhostuser_socket
21from networking_6wind.ml2_drivers.openvswitch.mech_driver import mech_ovs_fp 21from networking_6wind.ml2_drivers.openvswitch.mech_driver import mech_ovs_fp
22 22
23from neutron.extensions import portbindings 23from neutron.plugins.ml2.drivers.openvswitch.agent.common import (
24 constants as a_const)
24from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base 25from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base
25from neutron.tests.unit.plugins.ml2.drivers.openvswitch.mech_driver import ( 26from neutron.tests.unit.plugins.ml2.drivers.openvswitch.mech_driver import (
26 test_mech_openvswitch as test_ovs) 27 test_mech_openvswitch as test_ovs)
28from neutron_lib.api.definitions import portbindings
27 29
28mode = portbindings.VHOST_USER_MODE_SERVER 30mode = portbindings.VHOST_USER_MODE_SERVER
29socket = get_vif_vhostuser_socket(constants.VIF_VHOSTUSER_SOCKET_PREFIX, 31socket = get_vif_vhostuser_socket(constants.VIF_VHOSTUSER_SOCKET_PREFIX,
@@ -37,8 +39,9 @@ class OVSFPMechanismBaseTestCase(test_ovs.OpenvswitchMechanismBaseTestCase):
37 39
38 VIF_BRIDGE = portbindings.VIF_TYPE_BRIDGE 40 VIF_BRIDGE = portbindings.VIF_TYPE_BRIDGE
39 41
40 VIF_DETAILS = {portbindings.CAP_PORT_FILTER: True, 42 VIF_DETAILS = {portbindings.OVS_DATAPATH_TYPE: a_const.OVS_DATAPATH_SYSTEM,
41 portbindings.OVS_HYBRID_PLUG: True, 43 portbindings.CAP_PORT_FILTER: False,
44 portbindings.OVS_HYBRID_PLUG: False,
42 constants.VIF_VHOSTUSER_FP_PLUG: True, 45 constants.VIF_VHOSTUSER_FP_PLUG: True,
43 portbindings.VHOST_USER_OVS_PLUG: True, 46 portbindings.VHOST_USER_OVS_PLUG: True,
44 portbindings.VHOST_USER_MODE: mode, 47 portbindings.VHOST_USER_MODE: mode,
@@ -91,7 +94,8 @@ class OVSFPMechanismBaseTestCase(test_ovs.OpenvswitchMechanismBaseTestCase):
91 94
92 95
93class OVSFPMechanismSGDisabledBaseTestCase(OVSFPMechanismBaseTestCase): 96class OVSFPMechanismSGDisabledBaseTestCase(OVSFPMechanismBaseTestCase):
94 VIF_DETAILS = {portbindings.CAP_PORT_FILTER: False, 97 VIF_DETAILS = {portbindings.OVS_DATAPATH_TYPE: a_const.OVS_DATAPATH_SYSTEM,
98 portbindings.CAP_PORT_FILTER: False,
95 portbindings.OVS_HYBRID_PLUG: False, 99 portbindings.OVS_HYBRID_PLUG: False,
96 constants.VIF_VHOSTUSER_FP_PLUG: True, 100 constants.VIF_VHOSTUSER_FP_PLUG: True,
97 portbindings.VHOST_USER_OVS_PLUG: True, 101 portbindings.VHOST_USER_OVS_PLUG: True,