Remove useless function _add_port_tag_info
This reverts commit: b83fedbd78a441cf34d53dba35a3ccff7d8f4ac5. Since port is set to dead by default after the commits of: 7aae31c9f9ed938760ca0be3c461826b598c7004 0ddca284542aed89df4a22607a2da03f193f083c And we add the local vlan tag to the port right after it is bound to aviod trunk port flood issue: c63ebef2d58e15f4388cf064066f77b503a2f841 So that _add_port_tag_info function is not necessary anymore, and we will save a large OVSDB read action which is dumping the entire table of Port, for hosts with a huge number of ports this is time-comsuming. So removed it. Related-Bug: #1968896 Related-Bug: #1952567 Change-Id: Iefd765d497c7e2d4bb093052478185125b907025
This commit is contained in:
parent
8dfb24a933
commit
c4adec924a
neutron
plugins/ml2/drivers/openvswitch/agent
tests/unit/plugins/ml2/drivers/openvswitch/agent
@ -1177,41 +1177,6 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
|
||||
port_other_config)
|
||||
return True
|
||||
|
||||
def _add_port_tag_info(self, need_binding_ports):
|
||||
port_names = [p['vif_port'].port_name for p in need_binding_ports]
|
||||
port_info = self.int_br.get_ports_attributes(
|
||||
"Port", columns=["name", "tag", "other_config"],
|
||||
ports=port_names, if_exists=True)
|
||||
info_by_port = {
|
||||
x['name']: {
|
||||
'tag': x['tag'],
|
||||
'other_config': x['other_config'] or {}
|
||||
}
|
||||
for x in port_info
|
||||
}
|
||||
for port_detail in need_binding_ports:
|
||||
try:
|
||||
lvm = self.vlan_manager.get(port_detail['network_id'])
|
||||
except vlanmanager.MappingNotFound:
|
||||
continue
|
||||
port = port_detail['vif_port']
|
||||
try:
|
||||
cur_info = info_by_port[port.port_name]
|
||||
except KeyError:
|
||||
continue
|
||||
str_vlan = str(lvm.vlan)
|
||||
other_config = cur_info['other_config']
|
||||
if (cur_info['tag'] != lvm.vlan or
|
||||
other_config.get('tag') != str_vlan):
|
||||
other_config['tag'] = str_vlan
|
||||
self.int_br.set_db_attribute(
|
||||
"Port", port.port_name, "other_config", other_config)
|
||||
# Uninitialized port has tag set to []
|
||||
if cur_info['tag']:
|
||||
LOG.warning("Uninstall flows of ofport %s due to "
|
||||
"local vlan change.", port.ofport)
|
||||
self.int_br.uninstall_flows(in_port=port.ofport)
|
||||
|
||||
def _bind_devices(self, need_binding_ports):
|
||||
devices_up = []
|
||||
devices_down = []
|
||||
@ -2193,7 +2158,6 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
|
||||
# unnecessarily, (eg: when there are no IP address changes)
|
||||
added_ports = (port_info.get('added', set()) - skipped_devices -
|
||||
binding_no_activated_devices - migrating_devices)
|
||||
self._add_port_tag_info(need_binding_devices)
|
||||
self.process_install_ports_egress_flows(need_binding_devices)
|
||||
added_to_datapath = added_ports - devices_not_in_datapath
|
||||
self.sg_agent.setup_port_filters(added_to_datapath,
|
||||
|
@ -691,82 +691,6 @@ class TestOvsNeutronAgent(object):
|
||||
expected_failed_devices_retries_map,
|
||||
new_failed_devices_retries_map)
|
||||
|
||||
def test_add_port_tag_info(self):
|
||||
lvm = mock.Mock()
|
||||
lvm.vlan = 1
|
||||
self.agent.vlan_manager.mapping["net1"] = lvm
|
||||
ovs_db_list = [{'name': 'tap1',
|
||||
'tag': [],
|
||||
'other_config': {'segmentation_id': '1'}},
|
||||
{'name': 'tap2',
|
||||
'tag': [],
|
||||
'other_config': {}},
|
||||
{'name': 'tap3',
|
||||
'tag': [],
|
||||
'other_config': None}]
|
||||
vif_port1 = mock.Mock()
|
||||
vif_port1.port_name = 'tap1'
|
||||
vif_port2 = mock.Mock()
|
||||
vif_port2.port_name = 'tap2'
|
||||
vif_port3 = mock.Mock()
|
||||
vif_port3.port_name = 'tap3'
|
||||
port_details = [
|
||||
{'network_id': 'net1', 'vif_port': vif_port1},
|
||||
{'network_id': 'net1', 'vif_port': vif_port2},
|
||||
{'network_id': 'net1', 'vif_port': vif_port3}]
|
||||
with mock.patch.object(self.agent, 'int_br') as int_br:
|
||||
int_br.get_ports_attributes.return_value = ovs_db_list
|
||||
self.agent._add_port_tag_info(port_details)
|
||||
set_db_attribute_calls = \
|
||||
[mock.call.set_db_attribute("Port", "tap1",
|
||||
"other_config", {"segmentation_id": "1", "tag": "1"}),
|
||||
mock.call.set_db_attribute("Port", "tap2",
|
||||
"other_config", {"tag": "1"}),
|
||||
mock.call.set_db_attribute("Port", "tap3",
|
||||
"other_config", {"tag": "1"})]
|
||||
int_br.assert_has_calls(set_db_attribute_calls, any_order=True)
|
||||
|
||||
def test_add_port_tag_info_with_tagged_ports(self):
|
||||
lvm = mock.Mock()
|
||||
lvm.vlan = 1
|
||||
self.agent.vlan_manager.mapping["net1"] = lvm
|
||||
ovs_db_list1 = [{'name': 'tap1',
|
||||
'tag': 1,
|
||||
'other_config': {'segmentation_id': '1', 'tag': '1'}}]
|
||||
ovs_db_list2 = [{'name': 'tap2',
|
||||
'tag': 2,
|
||||
'other_config': {'segmentation_id': '1', 'tag': '1'}},
|
||||
{'name': 'tap3',
|
||||
'tag': 1,
|
||||
'other_config': {'segmentation_id': '2', 'tag': '2'}}]
|
||||
vif_port1 = mock.Mock()
|
||||
vif_port1.port_name = 'tap1'
|
||||
vif_port2 = mock.Mock()
|
||||
vif_port2.port_name = 'tap2'
|
||||
vif_port2.ofport = 7
|
||||
vif_port3 = mock.Mock()
|
||||
vif_port3.port_name = 'tap3'
|
||||
vif_port3.ofport = 8
|
||||
port_details1 = [{'network_id': 'net1', 'vif_port': vif_port1}]
|
||||
port_details2 = [{'network_id': 'net1', 'vif_port': vif_port2},
|
||||
{'network_id': 'net1', 'vif_port': vif_port3}]
|
||||
with mock.patch.object(self.agent, 'int_br') as int_br:
|
||||
int_br.get_ports_attributes.return_value = ovs_db_list1
|
||||
self.agent._add_port_tag_info(port_details1)
|
||||
int_br.set_db_attribute.assert_not_called()
|
||||
# Reset mock to check port with changed tag
|
||||
int_br.reset_mock()
|
||||
int_br.get_ports_attributes.return_value = ovs_db_list2
|
||||
self.agent._add_port_tag_info(port_details2)
|
||||
expected_calls = \
|
||||
[mock.call.set_db_attribute("Port", "tap2",
|
||||
"other_config", {'segmentation_id': '1', 'tag': '1'}),
|
||||
mock.call.uninstall_flows(in_port=7),
|
||||
mock.call.set_db_attribute("Port", "tap3",
|
||||
"other_config", {'segmentation_id': '2', 'tag': '1'}),
|
||||
mock.call.uninstall_flows(in_port=8)]
|
||||
int_br.assert_has_calls(expected_calls)
|
||||
|
||||
def test_bind_devices(self):
|
||||
devices_up = ['tap1']
|
||||
devices_down = ['tap2']
|
||||
|
Loading…
x
Reference in New Issue
Block a user