Resource Pools & Allocators
Relevant source files
The following files were used as context for generating this wiki page:
Resource pools manage the automated selection and assignment of available infrastructure assets, such as IP addresses, prefixes, and numeric identifiers. The system provides a centralized mechanism to allocate these resources to objects, ensuring uniqueness and tracking utilization across the infrastructure graph.
Allocators execute the logic required to determine the next available resource within a defined pool. These components integrate with the core schema to support both attribute-level allocations (e.g., VLAN IDs) and relationship-level allocations (e.g., IP addresses for a device interface).
Sources: [specs/2026-01-templates-with-resource-pools.md:14-16](https://github.com/opsmill/infrahub/blob/3da56b38eb13857ddacf8fe5d90fc40821626908/specs/2026-01-templates-with-resource-pools.md#L14-L16), [backend/infrahub/pools/allocator.py:1-5](https://github.com/opsmill/infrahub/blob/3da56b38eb13857ddacf8fe5d90fc40821626908/backend/infrahub/pools/allocator.py#L1-L5)
Resource Allocators
The backend implements specialized allocator classes to handle different resource types. These allocators calculate pool utilization and determine if a resource pool is exhausted.
Allocator Types
Infrahub supports three primary allocator types defined in the backend:
- NumberPoolAllocator: Manages numeric resources defined at the attribute level.
- IPAddressPoolAllocator: Manages individual IP addresses, typically defined at the relationship level.
- IPPrefixPoolAllocator: Manages IP prefixes (subnets), also defined at the relationship level.
Sources: [backend/infrahub/pools/allocator.py:12-68](https://github.com/opsmill/infrahub/blob/3da56b38eb13857ddacf8fe5d90fc40821626908/backend/infrahub/pools/allocator.py#L12-L68), [specs/2026-01-templates-with-resource-pools.md:23-28](https://github.com/opsmill/infrahub/blob/3da56b38eb13857ddacf8fe5d90fc40821626908/specs/2026-01-templates-with-resource-pools.md#L23-L28)
Utilization Tracking
Allocators track how much of a pool is currently in use. The get_resource_pool_utilization function calculates this as a percentage, which the frontend displays to users.
This diagram shows the flow from a resource pool to the utilization percentage displayed in the user interface.
Sources: [backend/infrahub/pools/allocator.py:112-114](https://github.com/opsmill/infrahub/blob/3da56b38eb13857ddacf8fe5d90fc40821626908/backend/infrahub/pools/allocator.py#L112-L114), [frontend/app/src/entities/resource-manager/ui/ResourcePoolUtilization.tsx:12-16](https://github.com/opsmill/infrahub/blob/3da56b38eb13857ddacf8fe5d90fc40821626908/frontend/app/src/entities/resource-manager/ui/ResourcePoolUtilization.tsx#L12-L16)
Resource Pools in Object Templates
Infrahub integrates resource pools with Object Templates to automate asset assignment during bulk object creation. When you create an object from a template, the system assigns resources from the linked pool to the target object rather than the template itself.
Integration Logic
The system distinguishes between direct resource assignment and pool-based assignment using specific schema naming conventions. For relationships, a generated relationship with the suffix _from_resource_pool stores the link to the resource pool.
| Resource Type | Schema Level | Implementation Detail |
|---|---|---|
| Number Pool | Attribute | Uses from_pool indicator in the backend to source numbers. |
| IP Address Pool | Relationship | Uses a generated [name]_from_resource_pool relationship to a CoreIPAddressPool. |
| IP Prefix Pool | Relationship | Uses a generated [name]_from_resource_pool relationship to a CoreIPPrefixPool. |
Sources: [specs/2026-01-templates-with-resource-pools.md:33-72](https://github.com/opsmill/infrahub/blob/3da56b38eb13857ddacf8fe5d90fc40821626908/specs/2026-01-templates-with-resource-pools.md#L33-L72), [specs/2026-05-schema-doc-migration.md:65-67](https://github.com/opsmill/infrahub/blob/3da56b38eb13857ddacf8fe5d90fc40821626908/specs/2026-05-schema-doc-migration.md#L65-L67)
Template Allocation Flow
When you process a template, the backend evaluates whether to use a static value or a pool-sourced value.
The sequence diagram illustrates the decision logic when the template engine encounters a relationship that can be sourced from a pool.
Sources: [specs/2026-01-templates-with-resource-pools.md:85-92](https://github.com/opsmill/infrahub/blob/3da56b38eb13857ddacf8fe5d90fc40821626908/specs/2026-01-templates-with-resource-pools.md#L85-L92)
Relationship Constraints
To maintain data integrity, Infrahub prevents users from populating both a static relationship and its pool-based counterpart simultaneously. For example, a template cannot have both a static primary_address and a primary_address_from_resource_pool defined.
Sources: [specs/2026-01-templates-with-resource-pools.md:81-83](https://github.com/opsmill/infrahub/blob/3da56b38eb13857ddacf8fe5d90fc40821626908/specs/2026-01-templates-with-resource-pools.md#L81-L83)
User Interface and Utilization
The frontend provides visibility into resource pool consumption through the ResourcePoolUtilization component. This component renders a progress bar or percentage indicator based on the utilization data provided by the backend allocators.
Data Representation
The UI component uses a specific color coding scheme to alert users of potential resource exhaustion:
- Standard: Displays utilization as a percentage.
- Exhausted: Highlights pools that have reached 100% capacity.
Sources: [frontend/app/src/entities/resource-manager/ui/ResourcePoolUtilization.tsx:18-35](https://github.com/opsmill/infrahub/blob/3da56b38eb13857ddacf8fe5d90fc40821626908/frontend/app/src/entities/resource-manager/ui/ResourcePoolUtilization.tsx#L18-L35), [backend/infrahub/pools/allocator.py:102-110](https://github.com/opsmill/infrahub/blob/3da56b38eb13857ddacf8fe5d90fc40821626908/backend/infrahub/pools/allocator.py#L102-L110)
Summary
Resource Pools and Allocators provide the automated logic for infrastructure asset management in Infrahub. By separating the definition of a pool from the allocation logic, the system supports complex workflows including template-based object generation and real-time utilization tracking. This architecture ensures that resources like IP addresses and VLAN IDs are assigned efficiently and uniquely across the entire infrastructure graph.