]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Pass correct port ID back to RPC caller
authorKevin Benton <blak111@gmail.com>
Mon, 30 Mar 2015 18:49:40 +0000 (11:49 -0700)
committerKevin Benton <kevinbenton@buttewifi.com>
Tue, 14 Apr 2015 18:39:22 +0000 (18:39 +0000)
The previous response to get_device_details calls was returning
whatever the caller requested as the port_id in the response.
This was only correct in the case where the port_id was used
directly. In cases where device names were passed in, there was
no way to retrieve the full port ID.

This corrects that behavior by using the port ID from the database
and adds tests to ensure the behavior remains correct.

Closes-Bug: #1443714
Change-Id: Ibfc7b6659a29e892dfe6e83bd9340feb40e920dd

neutron/plugins/ml2/rpc.py
neutron/tests/unit/plugins/ml2/drivers/l2pop/test_mech_driver.py

index ee01bfb54177a5867efca75f39491f4d6ccd7d3d..e06d916f385b15984becc512ef3e810bfdffc64a 100644 (file)
@@ -105,7 +105,7 @@ class RpcCallbacks(type_tunnel.TunnelRpcCallbackMixin):
 
         entry = {'device': device,
                  'network_id': port['network_id'],
-                 'port_id': port_id,
+                 'port_id': port['id'],
                  'mac_address': port['mac_address'],
                  'admin_state_up': port['admin_state_up'],
                  'network_type': segment[api.NETWORK_TYPE],
index 69e3b3c50a255c9c639722e104ece1ca55ead5fc..06a9b26c608ac6bbd58a2f5bf6a5f81342cbf362 100644 (file)
@@ -781,6 +781,21 @@ class TestL2PopulationRpcTestCase(test_plugin.Ml2PluginV2TestCase):
                 self.assertFalse(mock_fanout.called)
                 fanout_patch.stop()
 
+    def test_get_device_details_port_id(self):
+        self._register_ml2_agents()
+        host_arg = {portbindings.HOST_ID: L2_AGENT['host']}
+        with self.port(arg_list=(portbindings.HOST_ID,),
+                       **host_arg) as port:
+            port_id = port['port']['id']
+            # ensure various formats all result in correct port_id
+            formats = ['tap' + port_id[0:8], port_id,
+                       port['port']['mac_address']]
+            for device in formats:
+                details = self.callbacks.get_device_details(
+                    self.adminContext, device=device,
+                    agent_id=L2_AGENT_2['host'])
+                self.assertEqual(port_id, details['port_id'])
+
     def test_host_changed(self):
         self._register_ml2_agents()
         with self.subnet(network=self._network) as subnet: