diff --git a/neutron/plugins/bigswitch/db/porttracker_db.py b/neutron/plugins/bigswitch/db/porttracker_db.py index b2e3ec8079..845516b1c8 100644 --- a/neutron/plugins/bigswitch/db/porttracker_db.py +++ b/neutron/plugins/bigswitch/db/porttracker_db.py @@ -47,4 +47,4 @@ def put_port_hostid(context, port_id, host_id): return with context.session.begin(subtransactions=True): location = PortLocation(port_id=port_id, host_id=host_id) - context.session.add(location) + context.session.merge(location) diff --git a/neutron/tests/unit/bigswitch/test_restproxy_plugin.py b/neutron/tests/unit/bigswitch/test_restproxy_plugin.py index 13caebb6d9..4748114725 100644 --- a/neutron/tests/unit/bigswitch/test_restproxy_plugin.py +++ b/neutron/tests/unit/bigswitch/test_restproxy_plugin.py @@ -190,6 +190,16 @@ class TestBigSwitchVIFOverride(test_plugin.TestPortsV2, with self.port(**kwargs) as port: self.assertEqual(port['port']['binding:vif_type'], self.VIF_TYPE) + def test_port_move(self): + kwargs = {'name': 'name', 'binding:host_id': 'ivshost', + 'device_id': 'override_dev'} + with self.port(**kwargs) as port: + data = {'port': {'binding:host_id': 'someotherhost', + 'device_id': 'override_dev'}} + req = self.new_update_request('ports', data, port['port']['id']) + res = self.deserialize(self.fmt, req.get_response(self.api)) + self.assertEqual(res['port']['binding:vif_type'], self.VIF_TYPE) + def _make_port(self, fmt, net_id, expected_res_status=None, **kwargs): res = self._create_port(fmt, net_id, expected_res_status, ('binding:host_id', ), **kwargs)