From c70c2719d700902854ef0381cb725722ac2da05e Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Tue, 1 Apr 2014 01:05:29 -0700 Subject: [PATCH] Stop using portbindings_db in BSN ML2 driver 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 | 6 +++++- neutron/plugins/ml2/drivers/mech_bigswitch/driver.py | 7 ------- neutron/tests/unit/ml2/drivers/test_bigswitch_mech.py | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/neutron/plugins/bigswitch/plugin.py b/neutron/plugins/bigswitch/plugin.py index a5ba32081..703338e78 100644 --- a/neutron/plugins/bigswitch/plugin.py +++ b/neutron/plugins/bigswitch/plugin.py @@ -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) diff --git a/neutron/plugins/ml2/drivers/mech_bigswitch/driver.py b/neutron/plugins/ml2/drivers/mech_bigswitch/driver.py index d73ae8021..24f0567e6 100644 --- a/neutron/plugins/ml2/drivers/mech_bigswitch/driver.py +++ b/neutron/plugins/ml2/drivers/mech_bigswitch/driver.py @@ -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 diff --git a/neutron/tests/unit/ml2/drivers/test_bigswitch_mech.py b/neutron/tests/unit/ml2/drivers/test_bigswitch_mech.py index d8cd797f8..257b0165c 100644 --- a/neutron/tests/unit/ml2/drivers/test_bigswitch_mech.py +++ b/neutron/tests/unit/ml2/drivers/test_bigswitch_mech.py @@ -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) -- 2.45.2