Merge "Add physical_network to binding:vif_details dictionary"

This commit is contained in:
Jenkins 2014-05-26 17:41:47 +00:00 committed by Gerrit Code Review
commit b53c094d83
2 changed files with 24 additions and 0 deletions

View File

@ -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)

View File

@ -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()))