Skip to main content

Demo-dc-fabric

This repository demos key Infrahub features using an example data center running VxLAN / EVPN and firewalls. It demonstrates the capabilities to use Infrahub with Arista AVD and Containerlab. Infrahub generates configurations that AVD deploys to a Containerlab topology.

infrahub-demo-dc-fabric drawing

Running the demo​

Clone the repository​

Clone the GitHub repository to the server you will run this demo on:

git clone https://github.com/opsmill/infrahub-demo-dc-fabric.git

Prerequisites​

Before you get started, make sure the following tools are installed:

Set environmental variables​

export INFRAHUB_ADDRESS="http://localhost:8000"
export INFRAHUB_API_TOKEN="06438eb2-8019-4776-878c-0941b1f1d1ec"
export CEOS_DOCKER_IMAGE="registry.opsmill.io/external/ceos-image:4.29.0.2F"
export LINUX_HOST_DOCKER_IMAGE="registry.opsmill.io/external/alpine-host:v3.1.1"

Install the Infrahub SDK​

Our demos use poetry to manage the Python environment.

poetry install --no-interaction --no-ansi --no-root

Start Infrahub​

poetry run invoke start

Load schema and data into Infrahub​

The invoke command will create:

  • Basic data (Account, organization, ASN, Device Type, and Tags)
  • Location data (Locations, VLANs, and Prefixes)
  • Topology data (Topology, Topology Elements)
  • Security data (Policies, rules, objects)
poetry run invoke load-schema load-data

Demo flow​

1. Add the repository into Infrahub via GraphQL​

note

Reference the Infrahub documentation for the multiple ways this can be done.

mutation AddRepository{
CoreReadOnlyRepositoryCreate(
data: {
name: { value: "infrahub-demo-dc-fabric" }
location: { value: "https://github.com/opsmill/infrahub-demo-dc-fabric.git" }
}
) {
ok
object {
id
}
}
}

2. Generate a topology (devices, interfaces, cabling, BGP sessions, ...)​

note

The example below creates the topology fra05-pod1

poetry run infrahubctl run bootstrap/generate_topology.py topology=fra05-pod1

3. Create a branch​

Via the UI​

branch

4. Create a new l2 or l3 service​

http://localhost:8000/objects/TopologyNetworkService

service

note

The example below creates the Layer2 network service and a another Layer3 on topology fra05-pod1

5. Create a proposed change​

proposed change

note

This command will run the generator and render the artifacts

diff artifact

6. Try out our pytest plugin​

note

The command will use our Infrahub pytest plugin. It will run the different test in the tests folder. These tests include:

  • Syntax checks for all the GraphQL Queries
  • Syntax checks for the Checks
  • Syntax checks for all the jinja files used in templates
  • will use the input/output file to try out the rendering and confirm there is no unexpected missing piece
pytest -v ./tests

7. Create a new Branch​

Create a new branch test2 in the UI, or if you prefer to use our SDK in CLI:

poetry run infrahubctl branch create test2

9. Try out the topology check​

  • Modify an Element in a Topology (example: increase or decrease the quantity of leaf switches in fra05-pod1)

  • The checks will run in the Proposed Change -> check_device_topology will fail.

10. Deploy your environment to ContainerLabs​

Infrahub automatically generates a Containerlab topology for each defined topology. This topology is attached as an artifact to the corresponding topology object. Each device also includes its own startup configuration, stored as a separate artifact.

Using the Containerlab CLI, we can deploy the labβ€”this spins up all devices as Docker containers and loads their respective startup configurations.

# Download all artifacts automatically to ./generated-configs/
poetry run python3 scripts/get_configs.py

# Start the Containerlab
sudo -E containerlab deploy -t ./generated-configs/clab/fra05-pod1.yml --reconfigure

Now you can log in from any device with your SSH client!

important

username: admin - password: admin

DNS entries follow this pattern: clab-demo-dc-fabric-$nodeName

ssh admin@clab-demo-dc-fabric-fra05-pod1-spine1
(admin@clab-demo-dc-fabric-fra05-pod1-spine1) Password:

fra05-pod1-spine1>