Merge "Remove block flow when port UP"

This commit is contained in:
Zuul 2022-04-20 12:21:52 +00:00 committed by Gerrit Code Review
commit 0355ea6f37
2 changed files with 43 additions and 0 deletions

View File

@ -1380,6 +1380,17 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
if not lvm.vif_ports:
self.reclaim_local_vlan(net_uuid)
def port_alive(self, port, log_errors=True):
cur_tag = self.int_br.db_get_val("Port", port.port_name, "tag",
log_errors=log_errors)
# Port normal vlan tag is set correctly, remove the drop flows
if cur_tag and cur_tag != constants.DEAD_VLAN_TAG:
self.int_br.uninstall_flows(
strict=True,
table_id=constants.LOCAL_SWITCHING,
priority=2,
in_port=port.ofport)
def port_dead(self, port, log_errors=True):
'''Once a port has no binding, put it on the "dead vlan".
@ -1871,6 +1882,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
vif_port, network_id, network_type,
physical_network, segmentation_id,
fixed_ips, device_owner, provisioning_needed)
self.port_alive(vif_port)
else:
LOG.info("VIF port: %s admin state up disabled, "
"putting on the dead VLAN", vif_port.vif_id)

View File

@ -1128,6 +1128,37 @@ class TestOvsNeutronAgent(object):
self.agent.context, details['port_id'], self.agent.agent_id,
self.agent.conf.host)
def test_treat_vif_port_wake_up_port(self):
details = mock.MagicMock()
vif_port = type('vif_port', (object,), {
"vif_id": "12",
"iface-id": "407a79e0-e0be-4b7d-92a6-513b2161011b",
"vif_mac": "fa:16:3e:68:46:7b",
"port_name": "qr-407a79e0-e0",
"ofport": 10,
"bridge_name": "br-int"})
with mock.patch.object(
self.agent, 'int_br', autospec=True
) as int_br, mock.patch.object(
self.agent, '_set_port_vlan'
) as set_vlan, mock.patch.object(
self.agent, "port_alive"
) as port_alive:
int_br.db_get_val.return_value = {}
int_br.set_db_attribute.return_value = True
port_needs_binding = self.agent.treat_vif_port(
vif_port, details['port_id'],
details['network_id'],
details['network_type'],
details['physical_network'],
details['segmentation_id'],
True,
details['fixed_ips'],
details['device_owner'], True)
self.assertTrue(port_needs_binding)
set_vlan.assert_called_once_with(vif_port, 1)
port_alive.assert_called_once_with(vif_port)
def test_bind_port_with_missing_network(self):
vif_port = mock.Mock()
vif_port.name.return_value = 'port'