---
title: Slurp’it adapter
---
import ReferenceLink from "../../src/components/Card";

<!-- vale off -->
## What is Slurp’it?
<!-- vale on -->

Slurp’it lets you easily retrieve and store any data you want from your network in an offline, structured database. Out of the box, all major vendors and templates are already pre-configured.
Run the installation wizard and Slurp’it will start mining your network. You can add as many templates as you want.

## Requirements

This Adapter uses [Slurp’it SDK](https://pypi.org/project/slurpit_sk).
You will need to install it beforehand.

## Sync directions supported

- Slurp’it → Infrahub

:::info

Currently, the Slurp’it adapter supports only **one-way synchronization** from Slurp’it to Infrahub.
Syncing data back into Slurp’it is not yet supported.

:::

## Schema

Our `infrahub` repository contains an **example schema** that serves as a starting point for syncing Slurp’it data into Infrahub.
This schema follows best practices for Infrahub, **but it does not map the Slurp’it data model one-to-one** since Infrahub may have additional use cases and Slurp’it can be customizable.

<ReferenceLink title="Schema" url="https://github.com/opsmill/infrahub/blob/stable/models/examples/slurpit/slurpit.yml" openInNewTab />

### Installing the example schema

To install the example schema into Infrahub, follow these steps:

```bash
mkdir slurpit-sync
cd slurpit-sync
curl -o schema.yml https://raw.githubusercontent.com/opsmill/infrahub/refs/heads/stable/models/examples/slurpit/slurpit.yml
infrahubctl schema load schema.yml
```

## Configuration

`infrahub-sync` allows defining what gets synchronized from a source to a destination. Included in the examples is a `config.yml` file that matches the example schema.

<ReferenceLink title="config.yml" url="https://github.com/opsmill/infrahub-sync/blob/main/examples/slurpit_to_infrahub/config.yml" openInNewTab />

To download the example `config.yml`

```bash
curl https://raw.githubusercontent.com/opsmill/infrahub-sync/refs/heads/main/examples/slurpit_to_infrahub/config.yml > config.yml
```

### Configuration parameters

The `source.name` is set to `slurpitsync`, instructing `infrahub-sync` to use the Slurp’it adapter.

The settings dictionary is passed directly to the Slurp’it Python SDK for authentication and connection details.
Some of these parameters may be found in the [Slurp’it SDK Repository](https://gitlab.com/slurpit.io/slurpit_sdk).

Below is a snippet from the example config.yml file:

```yaml
---
name: from-slurpit
source:
  name: slurpitsync
  settings:
    url: "<URL>"
    api_key: "<TOKEN>"
    verify_ssl: true # Default value
```

### Schema mapping

The configuration file allows mapping Slurp’it data to the Infrahub schema, which has been designed to loosely align with the Slurp’it data model.
Below is an example showing how to:

- Set the destination Infrahub model (`OrganizationGeneric`)
- Map source data from Slurp’it and run a custom function `unique_vendors`
- Specify field mappings between Slurp’it and Infrahub models

```yaml
schema_mapping:
  - name: OrganizationGeneric
    mapping: unique_vendors
    fields:
      - name: name
        mapping: brand
      - name: type
        static: "Vendor"
```

Schema mapping connects Slurp’it fields to Infrahub's Node attributes and relationships.

Each field can either map directly to a Slurp’it field or be statically defined.
This table highlights the available `mappings` the adapter has to gather and normalize data from Slurp’it

| Name | Description |
| --- | --- |
| `unique_vendors` | The `unique_vendors` function retrieves a list of devices asynchronously, extracts the unique brands (vendors) from the device list, and returns a list of dictionaries, each containing a distinct brand. This ensures that only unique vendor names are included in the output. |
| `unique_device_type` | The `unique_device_type` function retrieves a list of devices asynchronously, then extracts unique combinations of brand, `device_type`, and `device_os`. It returns a list of dictionaries where each dictionary contains these three distinct attributes, ensuring only unique device types are included in the output. |
| `model`.`function` | This mapping directly relates to the SDK. For example once the SDK client is initiated you can get devices by using `device.get_devices` this will execute the query to gather all the devices.   |
| `planning_results`.`<planning_slug>` | If the mapping starts with `planning_result` a call will be made to the Slurp’it planning API to gather the data for the data that matches the slug. For example: `planning_results.routing-table` will query the routing-table plannings for all the data it has and return it to be used in the mapping.  |
| `filter_networks` | The `filter_networks` function processes a list of network entries, normalizing the network and mask fields, and filters out unwanted networks based on predefined "ignore" prefixes (such as 0.0.0.0/0 and 127.0.0.0/8). It returns a list of filtered, normalized networks, excluding those with prefixes deemed unnecessary or invalid. |
| `filter_interfaces` | The `filter_interfaces` function normalizes IP addresses in a list of interfaces and matches them against precomputed network prefixes from `filtered_networks`. It uses asynchronous tasks to process entries concurrently. Each entry's IP is normalized, and if it matches a known network, additional data (like VRF) is added. The function returns a list of interfaces with normalized addresses, excluding invalid or unmatched entries. |
