'Deallocate set of ips over IPAM.
If any single ip deallocation fails, tries to allocate deallocated
ip addresses with fixed ip request'

def _ipam_deallocate_ips(self, context, ipam_driver, port, ips, revert_on_fail=True):

    deallocated = []
    try:
        for ip in ips:
            try:
                ipam_subnet = ipam_driver.get_subnet(ip['subnet_id'])
                ipam_subnet.deallocate(ip['ip_address'])
                deallocated.append(ip)
            except n_exc.SubnetNotFound:
                LOG.debug('Subnet    was    not    found    on    ip    deallocation:    %s', ip)
    except Exception:
        with excutils.save_and_reraise_exception():
            if (not ipam_driver.needs_rollback()):
                return
            LOG.debug('An    exception    occurred    during    IP    deallocation.')
            if (revert_on_fail and deallocated):
                LOG.debug('Reverting    deallocation')
                self._safe_rollback(self._ipam_allocate_ips, context, ipam_driver, port, deallocated, revert_on_fail=False)
            elif ((not revert_on_fail) and ips):
                addresses = ',    '.join(self._get_failed_ips(ips, deallocated))
                LOG.error(_LE('IP    deallocation    failed    on    external    system    for    %s'), addresses)
    return deallocated
