You can run this demo on your PC using docker, or using Github Codespaces.
If you are not using Devcontainer or Github Codespaces, you will need to do the following steps. Otherwise jump to the step Demo.
Export those variables:
export INFRAHUB_ADDRESS="http://localhost:8000"
export INFRAHUB_API_TOKEN="06438eb2-8019-4776-878c-0941b1f1d1ec"
export CEOS_DOCKER_IMAGE="9r2s1098.c1.gra9.container-registry.ovh.net/external/ceos-image:4.29.0.2F"
export LINUX_HOST_DOCKER_IMAGE="9r2s1098.c1.gra9.container-registry.ovh.net/external/alpine-host:v3.1.1"
poetry install --no-interaction --no-ansi --no-root
poetry run inv start
This will create :
- Basics data (Account, organization, ASN, Device Type, and Tags)
- Locations data (Locations, VLANs, and Prefixes)
- Topology data (Topology, Topology Elements)
- Security data (Policies, rules, objects)
poetry run inv load-schema load-data
Note
Reference the Infrahub documentation for the multiple ways this can be done.
mutation AddCredential {
CorePasswordCredentialCreate(
data: {
name: {value: "my-git-credential"},
username: {value: "<GITHUB_USERNAME>"},
password: {value: "<GITHUB_TOKEN>"}
}
) {
ok
object {
hfid
}
}
}
mutation AddRepository{
CoreRepositoryCreate(
data: {
name: { value: "INPG_demo" }
location: { value: "https://github.com/marcom4rtinez/INPG_demo.git" }
# The HFID return from the previous mutation. Will be the name of the credentials
credential: { hfid: "my-git-credential" }
}
) {
ok
object {
id
}
}
}
Note
The example below creates the topology fra05-pod1
poetry run infrahubctl run generators/generate_topology.py topology=fra05-pod1
Note
The example below creates the Layer2 network service and a another Layer3 on topology fra05-pod1
poetry run infrahubctl run generators/generate_network-services.py topology=fra05-pod1 type=layer2
poetry run infrahubctl run generators/generate_network-services.py topology=fra05-pod1 type=layer3 vrf=production
Artifact Generation is not currently present in the UI but it's possible to try it out locally :
Note
This command will render the artifact define with device_arista
Transformation, for fra05-pod1-leaf1
device
poetry run infrahubctl render device_arista device=fra05-pod1-leaf1
The containerlab generator automatically generates a containerlab topology artifact for every topology. Every device has its startup config as an artifact.
# Download all artifacts automatically to ./generated-configs/
# poetry run python3 scripts/get_configs.py --help for all options
poetry run python3 scripts/get_configs.py -n -c -d
# Start the containerlab
sudo -E containerlab deploy -t ./generated-configs/clab/fra05-pod1.yml --reconfigure
NUTS can be run independently, however if visualization is desired it can be run with the --metrics
flag and it will be sent to grafana.
cd nuts
docker compose up -d
cd -
The NUTS test client in the containerlab is set up to be ready for test execution. Tests where pulled in step 12. with get_config.py
.
# Set the variables if you want to change the target, set by default
export PROMETHEUS_PUSHGATEWAY_URL="http://prom-pushgateway:9091"
export PROMETHEUS_PUSHGATEWAY_JOB="nuts"
# Enter the container
docker exec -it clab-avdasymirb-nuts bash
# Execute all generated tests for fra05-pod1
pytest tests/test_fra05-pod1-* --metrics
Go to grafana and see the dashboard on http://localhost:3000 (admin:infrahub). After login go to the Infrahub NUTS Dashboard
# Do it continously to generate visibility in grafana
count=1; while [ $count -le 100 ]; do pytest tests/test_fra05-pod1-* --metrics; ((count++)); done