Description
Here’s a high-level tour of the repository and how its pieces fit together:
1. Top-level scripts
-
main.py
- Entry point for VXLAN-Fabric creation.
- Prompts for NetBox URL/token, number of buildings, and device-type slugs.
- Validates input, connects to NetBox, builds a
FabricConfig, and invokesVXLANFabricCreator.create_fabric(). - Logs out the new site, spines, leaves and access switches.
-
add_customers.py
- Entry point for “customer” provisioning under an existing Fabric.
- Prompts for NetBox URL/token and customer details (name, VLAN/VNI, locations).
- Creates a tenant, assigns selected locations, allocates a /24 prefix, configures VLAN/L2VPN/VXLAN, and tags client interfaces on leaf switches.
2. Configuration & constants
- config.py
- Dataclasses and Enums defining:
- Interface types (QSFP, SFP, virtual…)
- Device roles (spine/leaf/access)
- IP-prefix roles (underlay, loopback)
- Default ASNs
FabricConfigdataclass holds all parameters for fabric build.
- Dataclasses and Enums defining:
3. Exceptions
- exceptions.py
- Custom exception hierarchy:
FabricErrorbase classDeviceCreationError,IPAllocationError,CablingErrorfor granular error handling.
- Custom exception hierarchy:
4. NetBox API backend
- helpers/netbox_backend.py
NetBoxBackendwrapspynetboxand exposes:- Tenant, Site, Device, VLAN, L2VPN, VXLAN-termination CRUD
- Interface management and cabling
- Prefix allocation and IP assignment
- Custom-fields saving and cleanup routines
- Uniform error-handler decorator logs errors and returns
None.
5. Fabric-creator core
- fabric_creator.py
VXLANFabricCreatororchestrates the fabric build:validate_prerequisites(): Check roles, IP-roles, and device types exist in NetBoxget_or_create_site(): List or create a sitecreate_spines(): Always create two spine switchescreate_building_pair(): For each building, create a leaf + access switch under a new Locationsetup_cabling(): Cable leaf↔spines and leaf↔access portssetup_ip_addressing(): Carve /31 underlay links and /32 loopbacks, assign to interfacesassign_asns(): Stamp ASN custom-fields on spines and leavescreate_fabric(): Glue it all together, capture and return the site/devices created
6. How to use
- Ensure you have Python 3 and install
pynetbox. - Export or enter your NetBox URL and API token.
- Run
main.pyto spin up a new VXLAN fabric. - Run
add_customers.pyto onboard new tenants into an existing fabric.
This codebase gives you a higher-level, interactive automation layer atop NetBox, so you can script consistent VXLAN fabrics and customer provisioning without hand-crafting each object in the UI.