]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Stop using portbindings_db in BSN ML2 driver
authorKevin Benton <blak111@gmail.com>
Tue, 1 Apr 2014 08:05:29 +0000 (01:05 -0700)
committerKevin Benton <blak111@gmail.com>
Tue, 1 Apr 2014 15:48:37 +0000 (08:48 -0700)
Avoids using the portbindings_db in the Big Switch
ML2 driver since ML2 has deprecated that database for
its own version that tracks the same information.

Also eliminates unnecessary 'binding_host' field since
it is now always the same as as the 'portbinding:host_id'
field.

Closes-Bug: #1300628
Change-Id: I17d47cb446cdd2e989c3e0d01b797a81309faaa7

neutron/plugins/bigswitch/plugin.py
neutron/plugins/ml2/drivers/mech_bigswitch/driver.py
neutron/tests/unit/ml2/drivers/test_bigswitch_mech.py

index a5ba320813118a397e192a8977dc749dd7c540cb..703338e78a09768373be72f0e92288e6166b16f0 100644 (file)
@@ -363,7 +363,11 @@ class NeutronRestProxyV2Base(db_base_plugin_v2.NeutronDbPluginV2,
                           "[%s]. Defaulting to ovs."),
                         cfg_vif_type)
             cfg_vif_type = portbindings.VIF_TYPE_OVS
-        hostid = porttracker_db.get_port_hostid(context, port['id'])
+        # In ML2, the host_id is already populated
+        if portbindings.HOST_ID in port:
+            hostid = port[portbindings.HOST_ID]
+        else:
+            hostid = porttracker_db.get_port_hostid(context, port['id'])
         if hostid:
             port[portbindings.HOST_ID] = hostid
             override = self._check_hostvif_override(hostid)
index d73ae80215c993505059b2405dd46b4122e5ea3c..24f0567e690ab966f066992c5bd8e040e0cfd0f1 100644 (file)
@@ -26,7 +26,6 @@ from neutron import context as ctx
 from neutron.extensions import portbindings
 from neutron.openstack.common import log
 from neutron.plugins.bigswitch import config as pl_config
-from neutron.plugins.bigswitch.db import porttracker_db
 from neutron.plugins.bigswitch.plugin import NeutronRestProxyV2Base
 from neutron.plugins.bigswitch import servermanager
 from neutron.plugins.ml2 import driver_api as api
@@ -99,14 +98,8 @@ class BigSwitchMechanismDriver(NeutronRestProxyV2Base,
         port = copy.deepcopy(context.current)
         net = context.network.current
         port['network'] = net
-        port['binding_host'] = context._binding.host
         port['bound_segment'] = context.bound_segment
         actx = ctx.get_admin_context()
-        if (portbindings.HOST_ID in port and 'id' in port):
-            host_id = port[portbindings.HOST_ID]
-            porttracker_db.put_port_hostid(actx, port['id'], host_id)
-        else:
-            host_id = ''
         prepped_port = self._extend_port_dict_binding(actx, port)
         prepped_port = self._map_state_and_status(prepped_port)
         if (portbindings.HOST_ID not in prepped_port or
index d8cd797f87ca17f61693ef2d6d2a283b6f60df68..257b0165c0b9385df012e46c9f21fd36317d87a6 100644 (file)
@@ -117,6 +117,6 @@ class TestBigSwitchMechDriverPortsV2(test_db_plugin.TestPortsV2,
         ) as (mock_rest, p):
             # make sure basic expected keys are present in the port body
             pb = mock_rest.mock_calls[0][1][2]
-            self.assertEqual('host', pb['binding_host'])
+            self.assertEqual('host', pb['binding:host_id'])
             self.assertIn('bound_segment', pb)
             self.assertIn('network', pb)