Slurp'it Adapter
Relevant source files
The following files were used as context for generating this wiki page:
The Slurp'it Adapter enables infrahub-sync to ingest network discovery data from Slurp'it into Infrahub. It functions as a source adapter, populating Infrahub with information about deployed equipment including devices, interfaces, VLANs, and hardware details. This adapter helps teams build an authoritative inventory from the actual state of the network rather than relying on manual curation.
Sources: README.md:20-22, README.md:104
Architecture and Role
The Slurp'it adapter follows the standard Sync Architecture by implementing the DiffSyncMixin and DiffSyncModelMixin contracts. It acts as a bridge between the Slurp'it API and the internal DiffSync store, allowing the Potenda engine to perform data reconciliation.
Component Relationship
The following diagram illustrates how the Slurp'it adapter interacts with the core sync engine and external systems.
The Slurp'it Adapter fetches data from the Slurp'it API, transforms it into DiffSync models, and loads it into a store for comparison by the Potenda engine.
Sources: dev/knowledge/sync-architecture.md, infrahub_sync/adapters/slurpitsync.py
Configuration
The adapter requires a config.yml file to define connection settings and the mapping between Slurp'it resources and Infrahub models.
Connection Settings
| Parameter | Type | Description |
|---|---|---|
url | string | The base URL of the Slurp'it instance. |
api_key | string | The API token used for authentication. |
Sources: examples/slurpit_to_infrahub/config.yml:4-7
Implementation Example
source:
name: slurpitsync
settings:
url: "<URL>"
api_key: "<TOKEN>"
Sources: examples/slurpit_to_infrahub/config.yml:2-7
Data Mapping and Models
The adapter maps Slurp'it data structures to Infrahub node kinds. It supports various infrastructure components through the schema_mapping configuration.
Supported Resource Mappings
| Destination Model | Slurp'it Source Mapping | Description |
|---|---|---|
OrganizationGeneric | unique_vendors | Maps brands to vendors. |
LocationGeneric | site.get_sites | Maps Slurp'it sites to Infrahub locations. |
InfraDevice | device.get_devices | Maps discovered devices using hostnames as identifiers. |
InfraHardwareInfo | planning_results.hardware-info | Maps serial numbers and hardware details. |
InfraInterface | planning_results.interfaces | Maps network interfaces and MAC addresses. |
InfraVLAN | planning_results.vlans | Maps VLAN IDs and names. |
Sources: examples/slurpit_to_infrahub/config.yml:33-108
Reference Resolution
The adapter resolves relationships between objects using reference fields. For example, an InfraDevice references a LocationGeneric by mapping the site field from Slurp'it.
The diagram shows the logical relationships established by the Slurp'it adapter during the sync process.
Sources: examples/slurpit_to_infrahub/config.yml:68-125
Transformation Logic
The adapter uses Jinja2 expressions to normalize Slurp'it data before loading it into Infrahub. This ensures that identifiers and attributes match the destination schema requirements.
Common Transforms
- Interface Description: Ensures descriptions are cast to strings.
expression: "{{Description | string}}" - IP Address Keys: Combines hostname and interface to create a unique reference.
expression: "{{hostname}}__{{Interface}}" - VRF Prefix: Handles conditional logic for VRF-aware prefixes.
expression: "{% if prefix %}{{ vrf if vrf else 'None' }}__{{ prefix }}{% endif %}"
Sources: examples/slurpit_to_infrahub/config.yml:122-143
Summary
The Slurp'it adapter serves as a critical component for network discovery ingestion within the Infrahub ecosystem. By mapping Slurp'it's planning_results and device inventories to Infrahub's schema-driven models, it automates the creation of a reflected infrastructure state. It utilizes the standard DiffSyncMixin for efficient loading and supports complex data transformations through declarative YAML configuration.
Sources: README.md:104, dev/knowledge/adapter-anatomy.md, examples/slurpit_to_infrahub/config.yml