'Configure port filters for devices.
This routine applies filters for new devices and refreshes firewall
rules when devices have been updated, or when there are changes in
security group membership or rules.
:param new_devices: set containing identifiers for new devices
:param updated_devices: set containing identifiers for
updated devices'

def setup_port_filters(self, new_devices, updated_devices):

    devices_to_refilter = self.devices_to_refilter
    global_refresh_firewall = self.global_refresh_firewall
    self.devices_to_refilter = set()
    self.global_refresh_firewall = False
    if new_devices:
        LOG.debug('Preparing    device    filters    for    %d    new    devices', len(new_devices))
        self.prepare_devices_filter(new_devices)
    if global_refresh_firewall:
        LOG.debug('Refreshing    firewall    for    all    filtered    devices')
        self.refresh_firewall()
    else:
        if (self.use_enhanced_rpc and updated_devices):
            self.firewall.security_group_updated('sg_member', [], updated_devices)
        updated_devices = ((updated_devices | devices_to_refilter) - new_devices)
        if updated_devices:
            LOG.debug('Refreshing    firewall    for    %d    devices', len(updated_devices))
            self.refresh_firewall(updated_devices)
