Merge "[OvS] Handle re_added multi ports" into stable/queens

This commit is contained in:
Zuul 2020-10-30 19:26:36 +00:00 committed by Gerrit Code Review
commit d57f73932f
2 changed files with 31 additions and 19 deletions

View File

@ -1387,15 +1387,15 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
removed_ports = {p['name'] for p in events['removed']}
ports_re_added = added_ports & removed_ports
for p in ports_re_added:
if ovs_lib.BaseOVS().port_exists(p):
events['re_added'] = [e for e in events['removed']
if e['name'] == p]
events['removed'] = [e for e in events['removed']
if e['name'] != p]
else:
events['added'] = [e for e in events['added']
if e['name'] != p]
ports_re_added = [p for p in ports_re_added if
ovs_lib.BaseOVS().port_exists(p)]
events['re_added'] = [e for e in events['removed']
if e['name'] in ports_re_added]
events['removed'] = [e for e in events['removed'] if e['name']
not in ports_re_added]
ports_removed = [p['name'] for p in events['removed']]
events['added'] = [e for e in events['added'] if e['name'] not in
ports_removed]
#TODO(rossella_s): scanning the ancillary bridge won't be needed
# anymore when https://review.openstack.org/#/c/203381 since the bridge

View File

@ -476,25 +476,37 @@ class TestOvsNeutronAgent(object):
actual)
def test_process_ports_events_port_removed_and_added(self):
port_id = 'f6f104bd-37c7-4f7b-9d70-53a6bb42728f'
port_id_one = 'f6f104bd-37c7-4f7b-9d70-53a6bb42728f'
port_id_two = 'fbaf42ef-ab63-4cda-81d2-37ee55daac3a'
events = {
'removed':
[{'ofport': 1,
'external_ids': {'iface-id': port_id,
'external_ids': {'iface-id': port_id_one,
'attached-mac': 'fa:16:3e:f6:1b:fb'},
'name': 'qvof6f104bd-37'}],
'name': 'qvof6f104bd-37'},
{'ofport': 2,
'external_ids': {'iface-id': port_id_two,
'attached-mac': 'fa:16:3e:a4:42:6e'},
'name': 'qvofbaf42ef-ab'}],
'added':
[{'ofport': 2,
'external_ids': {'iface-id': port_id,
[{'ofport': 3,
'external_ids': {'iface-id': port_id_one,
'attached-mac': 'fa:16:3e:f6:1b:fb'},
'name': 'qvof6f104bd-37'}]
'name': 'qvof6f104bd-37'},
{'ofport': 4,
'external_ids': {'iface-id': port_id_two,
'attached-mac': 'fa:16:3e:a4:42:6e'},
'name': 'qvofbaf42ef-ab'}],
}
registered_ports = {port_id}
registered_ports = {port_id_one, port_id_two}
expected_ancillary = ovs_agent.PortInfo()
# port was removed and then added
expected_ports = ovs_agent.PortInfo(current={port_id}, added={port_id},
re_added={port_id})
expected_ports = ovs_agent.PortInfo(
added={port_id_one, port_id_two},
current={port_id_one, port_id_two},
re_added={port_id_one, port_id_two}
)
with mock.patch.object(ovs_lib.BaseOVS, "port_exists",
return_value=True):
self._test_process_ports_events(events.copy(), registered_ports,
@ -502,7 +514,7 @@ class TestOvsNeutronAgent(object):
expected_ancillary)
# port was added and then removed
expected_ports = ovs_agent.PortInfo(removed={port_id})
expected_ports = ovs_agent.PortInfo(removed={port_id_one, port_id_two})
with mock.patch.object(ovs_lib.BaseOVS, "port_exists",
return_value=False):
self._test_process_ports_events(events.copy(), registered_ports,