self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context,
- self.sg_plugin_rpc)
+ self.sg_plugin_rpc, defer_refresh_firewall=True)
self.setup_rpc(self.interface_mappings.values())
self.daemon_loop()
resync_a = False
resync_b = False
- self.sg_agent.prepare_devices_filter(device_info.get('added'))
-
- if device_info.get('updated'):
- self.sg_agent.refresh_firewall()
-
+ self.sg_agent.setup_port_filters(device_info.get('added'),
+ device_info.get('updated'))
# Updated devices are processed the same as new ones, as their
# admin_state_up may have changed. The set union prevents duplicating
# work when a device is new and updated in the same polling iteration.
LOG.info(_LI("Agent out of sync with plugin!"))
sync = False
- if self._device_info_has_changes(device_info):
+ if (self._device_info_has_changes(device_info)
+ or self.sg_agent.firewall_refresh_needed()):
LOG.debug("Agent loop found changes! %s", device_info)
try:
sync = self.process_network_devices(device_info)
'added': set(['tap3', 'tap4']),
'updated': set(['tap2', 'tap3']),
'removed': set(['tap1'])}
- agent.sg_agent.prepare_devices_filter = mock.Mock()
- agent.sg_agent.refresh_firewall = mock.Mock()
+ agent.sg_agent.setup_port_filters = mock.Mock()
agent.treat_devices_added_updated = mock.Mock(return_value=False)
agent.treat_devices_removed = mock.Mock(return_value=False)
agent.process_network_devices(device_info)
- agent.sg_agent.prepare_devices_filter.assert_called_with(
- set(['tap3', 'tap4']))
- self.assertTrue(agent.sg_agent.refresh_firewall.called)
+ agent.sg_agent.setup_port_filters.assert_called_with(
+ device_info['added'],
+ device_info['updated'])
agent.treat_devices_added_updated.assert_called_with(set(['tap2',
'tap3',
'tap4']))