Cisco Modeling Labs Example¶
This guide shows how to export a topology from NetBox in Cisco Modeling Labs (CML) format and import it.
Prerequisites¶
- Cisco Modeling Labs v2.5 or later
- NetBox API access with a valid token
- nrx installed and configured
Step 1: Export from NetBox¶
Run nrx --output cml to export a topology graph from NetBox in CML format.
Example: Using NetBox Demo¶
Here's an example exporting the "DM-Akron" site from NetBox Demo:
export NB_API_TOKEN='replace_with_valid_API_token'
nrx --api https://demo.netbox.dev \
--templates templates \
--output cml \
--dir demo \
--site DM-Akron
This will create:
demo/DM-Akron.cml.yaml- CML topology filedemo/DM-Akron.cyjs- Cytoscape JSON graph data- Configuration files for each device (if available)
Command Options Explained¶
--api- NetBox API URL--templates- Path to template directory--output cml- Export in CML format--dir demo- Save output todemodirectory--site DM-Akron- Export devices from DM-Akron site
Step 2: Import into CML¶
Via Web Interface¶
- Open your CML Dashboard in a browser
- Choose IMPORT
- Select
DM-Akron.cml.yamlas the file to import - Verify the import status shows "Imported"
- Choose GO TO LAB
Via API (Optional)¶
You can also import programmatically using the CML API:
# Example using curl
curl -X POST https://your-cml-server/api/v0/import \
-H "Authorization: Bearer $CML_TOKEN" \
-F "file=@demo/DM-Akron.cml.yaml"
Step 3: Start the Lab¶
- In the CML interface, navigate to SIMULATE menu
- Choose START LAB
- Use the NODES menu to monitor the status of each node
- Wait for all nodes to reach "ACTIVE" state
Step 4: Access Devices¶
Once the lab is running, you can access devices via:
- Console - Click on a node and select "Console"
- SSH - If external connectivity is configured
- Telnet - Via the CML console server
Alternative: Export via CYJS¶
You can also export in two steps using CYJS as an intermediate format.
Step 1: Export to CYJS¶
Without --output cml argument, nrx will save data from NetBox as a CYJS file:
export NB_API_TOKEN='replace_with_valid_API_token'
nrx --api https://demo.netbox.dev \
--site DM-Akron \
--dir demo
This creates demo/DM-Akron.cyjs.
Step 2: Convert CYJS to CML¶
Convert the CYJS file to CML format:
Stopping the Lab¶
To stop the lab:
- In the CML interface, go to SIMULATE menu
- Choose STOP LAB
- Wait for all nodes to reach "STOPPED" state
Advanced Usage¶
Export Multiple Sites¶
Filter by Tags¶
Export devices with specific tags:
Without Device Configurations¶
If you don't want to export device configurations:
Configuration Files¶
When device configurations are available in NetBox, nrx will export them as startup configurations. In CML:
- Configurations are applied when the node boots
- They appear in the node's configuration editor
- You can modify them before starting the lab
Troubleshooting¶
Node Definition Issues¶
If you see errors about unsupported node types:
- Check your platform_map.yaml
- Ensure the platform slug in NetBox maps to a CML node definition
- Verify the node definition exists in your CML installation
Image Availability¶
Make sure the required VM images are available in your CML server:
- Go to TOOLS → Node Definitions
- Check that images for your node types are present
- Upload missing images if needed
Debug Mode¶
Enable debug output for detailed troubleshooting:
Next Steps¶
- Containerlab Example - Export for Containerlab
- NVIDIA Air Example - Export for Air
- Platform Map - Configure platform mappings
- Graphite Visualization - Visualize your topology