Skip to main content
Resource Manager automatically allocates resources from defined pools, ensuring no conflicts or duplicates. Use it for IP addresses, prefixes, VLANs, ASNs, and any numeric resource.

Resource Pool Types

Infrahub provides three types of resource pools:
Pool TypeUse CaseExample
Number PoolSequential numbers (VLANs, ASNs, IDs)VLAN 100-200, ASN 65000-65535
IP Prefix PoolSubnet allocation from parent prefixes/24 subnets from 10.0.0.0/16
IP Address PoolIndividual IP allocation from prefixesIPs from 10.0.1.0/24

Number Pools

Number pools allocate sequential numbers from a defined range.

Creating a Number Pool

  1. Navigate to Resource ManagerNumber Pools
  2. Click Add Number Pool
  3. Set the pool properties:
    • Name: Descriptive name (e.g., “VLAN Pool”)
    • Node: Object kind using this pool (e.g., InfraVLAN)
    • Node Attribute: Attribute to populate (e.g., vlan_id)
    • Start Range: Beginning of range (e.g., 100)
    • End Range: End of range (e.g., 200)
  4. Click Save

Allocating from Number Pools

Once a pool is defined and associated with a schema attribute (via NumberPool parameters), Infrahub automatically allocates values when creating objects.

Schema Configuration

In your schema, define the attribute with NumberPool parameters:
attributes:
  - name: vlan_id
    kind: Number
    optional: false
    unique: true
    parameters:
      NumberPool:
        pool: "<number-pool-uuid>"
Now when creating a VLAN without specifying vlan_id, Infrahub allocates the next available number:
mutation {
  InfraVLANCreate(
    data: {
      name: { value: "Production VLAN" }
      # vlan_id automatically allocated from pool
    }
  ) {
    ok
    object {
      id
      vlan_id { value }  # Returns the allocated number
    }
  }
}

Excluded Values

Exclude specific numbers or ranges from allocation:
parameters:
  NumberPool:
    pool: "<pool-uuid>"
    excluded_values: [110, 120, 130]  # Skip these
    excluded_ranges:
      - [150, 159]  # Skip 150-159

Min/Max Constraints

Restrict allocation to a subset of the pool:
parameters:
  NumberPool:
    pool: "<pool-uuid>"
    min_value: 120  # Allocate from 120 onwards
    max_value: 180  # Don't allocate above 180

IP Prefix Pools

IP Prefix Pools allocate subnets from parent prefixes.

Creating an IP Prefix Pool

  1. Navigate to Resource ManagerIP Prefix Pools
  2. Click Add IP Prefix Pool
  3. Set the pool properties:
    • Name: Pool name (e.g., “Site Subnets”)
    • IP Namespace: Namespace for the pool
    • Default Prefix Length: Default size for allocations (e.g., 24)
    • Default Prefix Type: Object kind (e.g., IpamIPPrefix)
    • Default Member Type: Prefix usage (e.g., prefix)
    • Resources: Parent prefixes to allocate from
  4. Click Save

Allocating Prefixes from Pools

Use the pool’s get_resource method to allocate the next available prefix:
from infrahub_sdk import InfrahubClient

client = InfrahubClient()

# Get the pool
pool = await client.get(
    kind="CoreIPPrefixPool",
    name__value="Site Subnets"
)

# Allocate a /24 prefix
prefix = await pool.get_resource(
    db=db,
    branch=branch,
    identifier="site-atl1",  # Unique identifier for tracking
    prefixlen=24,
    prefix_type="IpamIPPrefix",
    member_type="prefix",
    data={
        "description": "Atlanta site subnet",
        "status": "active"
    }
)

print(f"Allocated prefix: {prefix.prefix.value}")
The allocator finds the next available subnet using the IPAM reconciler:
  1. Queries all existing child prefixes
  2. Calculates gaps in the address space
  3. Returns the first available prefix of the requested length
  4. Creates the prefix object and reconciles the IPAM hierarchy

Allocation Weighting

When a pool has multiple parent prefixes, use allocation_weight to prioritize them:
mutation {
  CoreIPPrefixPoolUpdate(
    data: {
      id: "<pool-uuid>"
      resources: [
        { id: "<prefix-1-uuid>", allocation_weight: 100 },  # Prefer this
        { id: "<prefix-2-uuid>", allocation_weight: 50 }   # Fallback
      ]
    }
  ) {
    ok
  }
}
The allocator tries higher-weighted prefixes first.

IP Address Pools

IP Address Pools allocate individual IP addresses from prefixes.

Creating an IP Address Pool

  1. Navigate to Resource ManagerIP Address Pools
  2. Click Add IP Address Pool
  3. Configure:
    • Name: Pool name (e.g., “Server IPs”)
    • IP Namespace: Namespace
    • Default Address Type: Object kind (e.g., IpamIPAddress)
    • Resources: Parent prefixes to allocate from
  4. Click Save

Allocating IP Addresses

from infrahub_sdk import InfrahubClient

client = InfrahubClient()

pool = await client.get(
    kind="CoreIPAddressPool",
    name__value="Server IPs"
)

# Allocate next available IP
ip_address = await pool.get_resource(
    db=db,
    branch=branch,
    identifier="server-01",
    data={
        "description": "Web server IP",
        "status": "active"
    }
)

print(f"Allocated IP: {ip_address.address.value}")
The allocator skips:
  • Network address (first IP)
  • Broadcast address (last IP)
  • Already allocated IPs
For address pools (where network/broadcast are usable), set is_pool=True:
allocator = IPAMResourceAllocator(db=db, namespace=namespace)
ip = await allocator.get_next_address(
    ip_prefix=prefix,
    is_pool=True  # Allow network and broadcast addresses
)

Pool Utilization

Track pool usage to monitor capacity:
from infrahub.pools.number import NumberUtilizationGetter

# Get number pool utilization
pool = await client.get(kind="CoreNumberPool", id="<pool-uuid>")
utilization = NumberUtilizationGetter(
    db=db,
    pool=pool,
    branch=branch
)
await utilization.load_data()

print(f"Total utilization: {utilization.utilization:.1f}%")
print(f"Main branch: {utilization.utilization_default_branch:.1f}%")
print(f"Other branches: {utilization.utilization_branches:.1f}%")
print(f"Total size: {utilization.total_pool_size}")
For IP prefix pools, query the IPAM utilization API (see IPAM guide).

Reservations and Identifiers

Resource Manager uses identifiers to track allocations:
  • Identifier: Unique key for the allocation (e.g., node ID, HFID)
  • Reservation: Database record linking identifier to allocated resource
When you request a resource with the same identifier, Resource Manager returns the existing allocation:
# First call allocates
prefix1 = await pool.get_resource(identifier="site-atl1", prefixlen=24)
# Returns: 10.0.1.0/24

# Second call returns the same prefix
prefix2 = await pool.get_resource(identifier="site-atl1", prefixlen=24)
# Returns: 10.0.1.0/24 (same as prefix1)
This ensures idempotent allocations.

Best Practices

  1. Use descriptive identifiers: Help track what the resource is for
  2. Set allocation weights: Guide allocation order for multiple parent resources
  3. Monitor utilization: Set alerts when pools reach 80% capacity
  4. Exclude reserved values: Use excluded_values for reserved numbers
  5. Use namespaces: Isolate IP allocations by environment or tenant
  6. Plan pool sizes: Ensure pools are large enough for growth

Next Steps

  • Learn about IPAM for IP address management
  • Use Profiles to set default pool configurations
  • Explore Object Management for creating pool resources

Build docs developers (and LLMs) love