self.deleted_ports.add(port_id)
LOG.debug("port_delete message processed for port %s", port_id)
- def process_deleted_ports(self):
+ def process_deleted_ports(self, port_info):
+ # don't try to process removed ports as deleted ports since
+ # they are already gone
+ if 'removed' in port_info:
+ self.deleted_ports -= port_info['removed']
while self.deleted_ports:
port_id = self.deleted_ports.pop()
# Flush firewall rules and move to dead VLAN so deleted ports no
self.updated_ports = set()
reg_ports = (set() if ovs_restarted else ports)
port_info = self.scan_ports(reg_ports, updated_ports_copy)
- # don't try to process removed ports as deleted ports since
- # they are already gone
- self.deleted_ports -= port_info['removed']
- self.process_deleted_ports()
+ self.process_deleted_ports(port_info)
self.update_stale_ofport_rules()
LOG.debug("Agent rpc_loop - iteration:%(iter_num)d - "
"port information retrieved. "
int_br.get_vif_port_by_id.return_value = vif
self.agent.port_delete("unused_context",
port_id='id')
- self.agent.process_deleted_ports()
+ self.agent.process_deleted_ports(port_info={})
# the main things we care about are that it gets put in the
# dead vlan and gets blocked
int_br.set_db_attribute.assert_any_call(
in_port=vif.ofport,
actions='drop')
+ def test_port_delete_removed_port(self):
+ with mock.patch.object(self.agent, 'int_br') as int_br:
+ self.agent.port_delete("unused_context",
+ port_id='id')
+ # if it was removed from the bridge, we shouldn't be processing it
+ self.agent.process_deleted_ports(port_info={'removed': {'id', }})
+ self.assertFalse(int_br.set_db_attribute.called)
+ self.assertFalse(int_br.drop_port.called)
+
def test_setup_physical_bridges(self):
with contextlib.nested(
mock.patch.object(ip_lib, "device_exists"),