From 54219198106ce281d252bf48f994cac082e5b3d0 Mon Sep 17 00:00:00 2001 From: Irena Berezovsky Date: Sun, 27 Apr 2014 08:47:29 +0300 Subject: [PATCH] Add physical_network to binding:vif_details dictionary During port binding binding:vif_details dictionary is updated with physical_network to be used by mlnx nova vif driver. binding:profile update will be removed once nova side fix is merged to keep consistent solution. Change-Id: If9525929a1546e8d05f7923570d30dfc2eed8898 Closes-Bug: 1304872 --- neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py | 3 +++ .../tests/unit/ml2/drivers/test_mech_mlnx.py | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py b/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py index fd91020e49..97eb03a4c1 100644 --- a/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py +++ b/neutron/plugins/ml2/drivers/mlnx/mech_mlnx.py @@ -69,6 +69,9 @@ class MlnxMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase): if self.check_segment_for_agent(segment, agent): vif_type = self._get_vif_type( context.current[portbindings.VNIC_TYPE]) + if segment[api.NETWORK_TYPE] in ['flat', 'vlan']: + self.vif_details['physical_network'] = segment[ + 'physical_network'] context.set_binding(segment[api.ID], vif_type, self.vif_details) diff --git a/neutron/tests/unit/ml2/drivers/test_mech_mlnx.py b/neutron/tests/unit/ml2/drivers/test_mech_mlnx.py index f1c2863ba1..343af4233e 100644 --- a/neutron/tests/unit/ml2/drivers/test_mech_mlnx.py +++ b/neutron/tests/unit/ml2/drivers/test_mech_mlnx.py @@ -116,3 +116,24 @@ class MlnxMechanismProfileTestCase(MlnxMechanismBaseTestCase): self.driver.try_to_bind_segment_for_agent(context, segment, agent) self.assertEqual('{"physical_network": "fake_physical_network"}', context._binding.profile) + + +class MlnxMechanismVifDetailsTestCase(MlnxMechanismBaseTestCase): + def setUp(self): + super(MlnxMechanismVifDetailsTestCase, self).setUp() + + def test_vif_details_contains_physical_net(self): + VLAN_SEGMENTS = [{api.ID: 'vlan_segment_id', + api.NETWORK_TYPE: 'vlan', + api.PHYSICAL_NETWORK: 'fake_physical_network', + api.SEGMENTATION_ID: 1234}] + + context = base.FakePortContext(self.AGENT_TYPE, + self.AGENTS, + VLAN_SEGMENTS, + portbindings.VNIC_DIRECT) + segment = VLAN_SEGMENTS[0] + agent = self.AGENTS[0] + self.driver.try_to_bind_segment_for_agent(context, segment, agent) + set({"physical_network": "fake_physical_network"}).issubset( + set(context._bound_vif_details.items()))