IP Address Management (IPAM)
Relevant source files
The following files were used as context for generating this wiki page:
- backend/infrahub/core/ipam/model.py
- frontend/app/src/entities/ipam/ip-prefixes/ui/ip-prefix-manager.tsx
- frontend/app/src/entities/ipam/ip-addresses/api/get-ip-address-list-from-api.ts
- frontend/app/src/entities/ipam/ip-prefixes/domain/use-cases/get-ip-prefix-list.ts
- specs/002-header-sort-menu/tasks.md
- backend/AGENTS.md
IP Address Management (IPAM) in Infrahub manages IPv4 and IPv6 network resources through a hierarchical graph-based model. The system tracks IP prefixes and addresses, ensuring data integrity across branches while providing automated allocation and validation. IPAM integrates with the overall Schema-Driven Integrity of the project to enforce network constraints.
Sources: AGENTS.md:1, backend/infrahub/core/ipam/model.py
Core Data Models
The IPAM system relies on specific backend models that define how IP resources are structured and identified within the Neo4j graph.
IP Prefix and Address Representation
IPAM resources are represented as specialized nodes in the graph. These nodes store network-specific attributes such as the prefix length, address family, and the network address itself.
The diagram shows the hierarchical relationship where prefixes can contain both smaller sub-prefixes and individual IP addresses.
Sources: backend/infrahub/core/ipam/model.py, frontend/app/src/entities/ipam/ip-prefixes/ui/ip-prefix-manager.tsx
Frontend Architecture
The frontend follows a layered architecture to manage IPAM data, separating API communication from UI components and domain logic.
API Integration
IPAM data is fetched through GraphQL queries. The frontend uses utility functions to append ordering and filtering parameters to these requests.
| Function | Purpose | Location |
|---|---|---|
getIPAddressListFromAPI | Fetches a list of IP addresses from the backend. | ip-addresses/api/get-ip-address-list-from-api.ts |
getIPPrefixList | Use-case that coordinates prefix fetching. | ip-prefixes/domain/use-cases/get-ip-prefix-list.ts |
addOrderByToRequest | Appends sort parameters to GraphQL __args. | shared/api/graphql/utils.ts |
Sources: frontend/app/src/entities/ipam/ip-addresses/api/get-ip-address-list-from-api.ts:1-10, specs/002-header-sort-menu/tasks.md:70-75
UI Components and Management
The IPPrefixManager is the primary interface for managing network hierarchies. It allows users to visualize prefix nesting and manage resource allocation.
- Sorting and Filtering: IPAM tables (addresses and prefixes) support server-side sorting via the
useSorthook and?sort=URL parameters. - Table Headers: IPAM tables use a shared
TableColumnHeadercomponent that provides sorting and filtering menus.
The flow demonstrates how a user request in the UI triggers a coordinated fetch involving domain use-cases and API utilities.
Sources: frontend/app/src/entities/ipam/ip-prefixes/ui/ip-prefix-manager.tsx:1-20, specs/002-header-sort-menu/tasks.md:78-85
Feature Implementation: Header Sorting
A specific implementation refactor added column-header sorting to IPAM tables to improve usability.
- API Support: The
get-ip-address-list-from-api.tsand prefix equivalent were updated to accept asort: Sort[]parameter. - Domain Threading: The
sortparameter is threaded through the domain use-cases to the query hooks. - UI Wiring:
ip-address-table.tsxandip-prefix-table.tsxcall theuseSorthook to manage the state of the active sort.
Sources: specs/002-header-sort-menu/tasks.md:68-88
Summary
IPAM provides the structural foundation for network resource management in Infrahub. By utilizing a hierarchical model in the backend and a layered architecture in the frontend, it ensures that IP prefixes and addresses are managed with high integrity and performance. The system supports advanced UI features like server-side sorting and filtering, directly integrated into the project's standardized table components.