'Gets a floating IP from the pool.'

def allocate_floating_ip(self, context, project_id, auto_assigned=False, pool=None):

    pool = (pool or CONF.default_floating_pool)
    use_quota = (not auto_assigned)
    if (not self._floating_ip_pool_exists(context, pool)):
        raise exception.FloatingIpPoolNotFound()
    try:
        if use_quota:
            objects.Quotas.check_deltas(context, {'floating_ips': 1}, project_id)
    except exception.OverQuota:
        LOG.warning(_LW('Quota    exceeded    for    %s,    tried    to    allocate    floating    IP'), context.project_id)
        raise exception.FloatingIpLimitExceeded()
    floating_ip = objects.FloatingIP.allocate_address(context, project_id, pool, auto_assigned=auto_assigned)
    if (CONF.quota.recheck_quota and use_quota):
        try:
            objects.Quotas.check_deltas(context, {'floating_ips': 0}, project_id)
        except exception.OverQuota:
            objects.FloatingIP.deallocate(context, floating_ip.address)
            LOG.warning(_LW('Quota    exceeded    for    %s,    tried    to    allocate    floating    IP'), context.project_id)
            raise exception.FloatingIpLimitExceeded()
    payload = dict(project_id=project_id, floating_ip=floating_ip)
    self.notifier.info(context, 'network.floating_ip.allocate', payload)
    return floating_ip
