Allocate an ID value and return it.

        Raises:
            ValueError: Out of capacity in ID pool.
487134
def alloc(self):
        
        if not self._free:
            self._expand()
        id = self._free.pop()
        self._used.add(id)
        return id
1131467
def get_id(self):
        """"""
        if self._id_attr is None or not hasattr(self, self._id_attr):
            return None
        return getattr(self, self._id_attr)
280450
def usable_id(cls, id):
        
        try:
            qry_id = int(id)
        except Exception:
            qry_id = None

        if not qry_id:
            msg = 'unknown identifier %s' % id
            cls.error(msg)

        return qry_id
557918
private int allocateNode(int d) {
        int id = 1;
        int initial = - (1 << d); // has last d bits = 0 and rest all = 1
        byte val = value(id);
        if (val > d) { // unusable
            return -1;
        }
        while (val < d || (id & initial) == 0) { // id & initial == 1 << d for all ids at depth d, for < d it is 0
            id <<= 1;
            val = value(id);
            if (val > d) {
                id ^= 1;
                val = value(id);
            }
        }
        byte value = value(id);
        assert value == d && (id & initial) == 1 << d : String.format("val = %d, id & initial = %d, d = %d",
                value, id & initial, d);
        setValue(id, unusable); // mark as unusable
        updateParentsAlloc(id);
        return id;
    }
25852
def get(id)
      return unless id
      with_redis { |redis| redis.get(redis_key_for(id)).try { |data| load(data) } }
    end
613952
def random_id_generator(self, size=6, chars=string.ascii_uppercase +
                            string.digits):
        '''  '''
        return ''.join(random.choice(chars) for x in range(size))
593477
def id(self, id):
        
        if id is None:
            raise ValueError("Invalid value for `id`, must not be `None`")
        if id is not None and not re.search('^[A-Za-z0-9]{32}', id):
            raise ValueError("Invalid value for `id`, must be a follow pattern or equal to `/^[A-Za-z0-9]{32}/`")

        self._id = id
566012
def value(self):
    
    if not self.filled:
      raise SlotNotFilledError('Slot with name "%s", key "%s" not yet filled.'
                               % (self.name, self.key))
    return self._value
363145
def _getNextId(self):
        
        if not self._uuids:
            for _ in range(self.UUID_POOL_GEN_SIZE):
                self._uuids.append(uuid.uuid4().bytes)
        return self._uuids.pop()
470210
def allocate_subnet(self, subnet_lst, net_id=None):
        

        session = db.get_session()
        query_str = None
        for sub in subnet_lst:
            sub_que = (self.model.subnet_address != sub)
            if query_str is not None:
                query_str = query_str & sub_que
            else:
                query_str = sub_que
        with session.begin(subtransactions=True):
            select = (session.query(self.model).filter(
                (self.model.allocated == 0) & query_str))

            # Selected segment can be allocated before update by someone else,
            # We retry until update success or DB_MAX_RETRIES retries
            for attempt in range(DB_MAX_RETRIES + 1):
                alloc = select.first()
                if not alloc:
                    LOG.info("No subnet resource available")
                    return
                count = (session.query(self.model).
                         filter_by(subnet_address=alloc.subnet_address,
                         allocated=False).update({"allocated": True,
                                                  "network_id": net_id}))
                if count:
                    return alloc.subnet_address

        LOG.error("ERROR: Failed to allocate subnet for net %(net)s",
                  {'net': net_id})
        return None
1050769
def request(self, id, **kwargs):
        
        data = self.get('requests', id, **kwargs)
        return data
1171988
def t_ID(self, t):
        '
        t.type = self.reserved_words.get(t.value, 'ID')
        return t
505910
def _idForObject(self, defaultObject):
        
        identifier = self._allocateID()
        self._idsToObjects[identifier] = defaultObject
        return identifier
839894
def integer_id(self):
    
    id = self.id()
    if not isinstance(id, (int, long)):
      id = None
    return id
100817
def get(cls, id):
        

        # cached?
        if CACHE:
            if id in _cache['Pool']:
                log.debug('cache hit for pool %d' % id)
                return _cache['Pool'][id]
            log.debug('cache miss for pool %d' % id)

        try:
            pool = Pool.list({'id': id})[0]
        except (IndexError, KeyError):
            raise NipapNonExistentError('no pool with ID ' + str(id) + ' found')

        _cache['Pool'][id] = pool
        return pool
1193331
def id=(id)

      if !id.nil? && id.to_s.length > 255
        fail ArgumentError, "invalid value for 'id', the character length must be smaller than or equal to 255."
      end

      @id = id
    end
1319543
def get_item_with_id(self, uid):
        
        for item in self.get_items():
            if item.id == uid:
                return item

        return None