Merge "Skip setup_port_filters for skipped_devices"
This commit is contained in:
commit
2f52d15d8e
|
@ -1626,6 +1626,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
|
|||
port_info.get('updated', set()))
|
||||
need_binding_devices = []
|
||||
security_disabled_ports = []
|
||||
skipped_devices = set()
|
||||
if devices_added_updated:
|
||||
start = time.time()
|
||||
(skipped_devices, need_binding_devices,
|
||||
|
@ -1643,12 +1644,12 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
|
|||
'elapsed': time.time() - start})
|
||||
# Update the list of current ports storing only those which
|
||||
# have been actually processed.
|
||||
port_info['current'] = (port_info['current'] -
|
||||
set(skipped_devices))
|
||||
skipped_devices = set(skipped_devices)
|
||||
port_info['current'] = (port_info['current'] - skipped_devices)
|
||||
|
||||
# TODO(salv-orlando): Optimize avoiding applying filters
|
||||
# unnecessarily, (eg: when there are no IP address changes)
|
||||
added_ports = port_info.get('added', set())
|
||||
added_ports = port_info.get('added', set()) - skipped_devices
|
||||
self._add_port_tag_info(need_binding_devices)
|
||||
if security_disabled_ports:
|
||||
added_ports -= set(security_disabled_ports)
|
||||
|
|
|
@ -947,14 +947,16 @@ class TestOvsNeutronAgent(object):
|
|||
self.agent._bind_devices([{'network_id': 'non-existent',
|
||||
'vif_port': vif_port}])
|
||||
|
||||
def _test_process_network_ports(self, port_info):
|
||||
def _test_process_network_ports(self, port_info, skipped_devices=None):
|
||||
failed_devices = {'added': set(), 'removed': set()}
|
||||
skipped_devices = skipped_devices or []
|
||||
added_devices = port_info.get('added', set())
|
||||
with mock.patch.object(self.agent.sg_agent,
|
||||
"setup_port_filters") as setup_port_filters,\
|
||||
mock.patch.object(
|
||||
self.agent, "treat_devices_added_or_updated",
|
||||
return_value=(
|
||||
[], [], [],
|
||||
skipped_devices, [], [],
|
||||
failed_devices['added'])) as device_added_updated,\
|
||||
mock.patch.object(self.agent.int_br, "get_ports_attributes",
|
||||
return_value=[]),\
|
||||
|
@ -967,9 +969,9 @@ class TestOvsNeutronAgent(object):
|
|||
failed_devices,
|
||||
self.agent.process_network_ports(port_info, False))
|
||||
setup_port_filters.assert_called_once_with(
|
||||
port_info.get('added', set()),
|
||||
added_devices - set(skipped_devices),
|
||||
port_info.get('updated', set()))
|
||||
devices_added_updated = (port_info.get('added', set()) |
|
||||
devices_added_updated = (added_devices |
|
||||
port_info.get('updated', set()))
|
||||
if devices_added_updated:
|
||||
device_added_updated.assert_called_once_with(
|
||||
|
@ -990,6 +992,12 @@ class TestOvsNeutronAgent(object):
|
|||
'removed': set(['eth0']),
|
||||
'added': set(['eth1'])})
|
||||
|
||||
def test_process_network_port_with_skipped_ports(self):
|
||||
port_info = {'current': set(['tap0', 'tap1']),
|
||||
'removed': set(['eth0']),
|
||||
'added': set(['eth1', 'eth2'])}
|
||||
self._test_process_network_ports(port_info, skipped_devices=['eth1'])
|
||||
|
||||
def test_process_network_port_with_empty_port(self):
|
||||
self._test_process_network_ports({})
|
||||
|
||||
|
|
Loading…
Reference in New Issue