router_id != device_id)
if update_required:
with session.begin(subtransactions=True):
+ try:
+ orig_port = super(Ml2Plugin, self).get_port(context, id)
+ except exc.PortNotFound:
+ LOG.debug("DVR Port %s has been deleted concurrently", id)
+ return
if not binding:
binding = db.ensure_dvr_port_binding(
session, id, host, router_id=device_id)
- orig_port = super(Ml2Plugin, self).get_port(context, id)
network = self.get_network(context, orig_port['network_id'])
mech_context = driver_context.DvrPortContext(self,
context, orig_port, network,
mech_context._binding.router_id)
self.assertEqual(host_id, mech_context._binding.host)
+ def test_update_dvr_port_binding_on_non_existent_port(self):
+ plugin = manager.NeutronManager.get_plugin()
+ port = {
+ 'id': 'foo_port_id',
+ 'binding:host_id': 'foo_host',
+ }
+ with mock.patch.object(ml2_db, 'ensure_dvr_port_binding') as mock_dvr:
+ plugin.update_dvr_port_binding(
+ self.context, 'foo_port_id', {'port': port})
+ self.assertFalse(mock_dvr.called)
+
class TestMl2PortBindingNoSG(TestMl2PortBinding):
HAS_PORT_FILTER = False