def _get_partition(self, data):
        try:
            if six.PY3 and data is not None:
                data = data.encode('utf-8')
            key_hash = hashlib.md5(data)
            hashed_key = self._hash2int(key_hash)
            position = bisect.bisect(self._partitions, hashed_key)
            return position if position < len(self._partitions) else 0
        except __HOLE__:
            raise exception.Invalid(
                _("Invalid data supplied to HashRing.get_hosts."))
dataset/ETHPy150Open openstack/ironic/ironic/common/hash_ring.py/HashRing._get_partition