def allocate(self, page_size, pages_available):
        """Allocate component's pages of size page_size.

        page_size: size of pages to allocate (in KiBs)
        pages_available: avalible pages of this size on numa node

        Return count of pages that was really allocated.
        """
        pages = self._pages

        if page_size not in pages:
            return 0

        required = pages[page_size]
        limit = min(required, pages_available)
        pages[page_size] -= limit

        if pages[page_size] == 0:
            pages.pop(page_size)

        return limit
dataset/ETHPy150Open openstack/fuel-web/nailgun/nailgun/policy/hugepages_distribution.py/Component.allocate/original