# Cisco Gns3

> Generate Python scripts for managing GNS3 lab topologies and automating Cisco lab environments. Use when the user wants to build, manage, or automate GNS3 labs for testing Cisco configurations.

- Skill: `bradmccloskey/cisco-gns3` (Agent Skill)
- Install (CLI): `npx skillmds@latest add bradmccloskey/cisco-gns3`
- Raw SKILL.md: https://api.skillmd.com/api/skills/bradmccloskey/cisco-gns3/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: bradmccloskey (https://skillmd.com/u/bradmccloskey)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/bradmccloskey/cisco-gns3

---


## GNS3 Lab Automation Scripts

Write Python scripts for managing GNS3 Cisco lab environments. Follow these standards:

### Capabilities

#### Topology Management via GNS3 REST API
- Create/delete projects
- Add/remove nodes (routers, switches, firewalls)
- Create/delete links between nodes
- Start/stop/suspend nodes
- Export and import topologies

#### Lab Provisioning
- Bootstrap device configs via console (telnetlib or netmiko to console port)
- Push initial configs to all devices in a topology
- Reset lab to known-good baseline state
- Clone topologies for parallel testing

#### Lab Testing Workflows
- Build topology → push configs → run tests → collect results → tear down
- Compare behavior across different IOS versions
- Pre/post change validation in lab before production

### GNS3 API Basics
```python
# GNS3 server API (default: http://localhost:3080)
# GET  /v2/projects                  - list projects
# POST /v2/projects                  - create project
# GET  /v2/projects/{id}/nodes       - list nodes
# POST /v2/projects/{id}/nodes       - create node
# POST /v2/projects/{id}/links       - create link
# POST /v2/projects/{id}/nodes/{id}/start  - start node
```

### Libraries to Use
- `requests` for GNS3 REST API
- `telnetlib` or `netmiko` for console access to devices
- `time` / `asyncio` for boot wait and polling
- `yaml` for topology definitions
- `jinja2` for config templates

### Topology Definition Format (YAML)
```yaml
project_name: ospf-lab
nodes:
  - name: R1
    template: "Cisco IOSv"
    console_port: 5001
    config: configs/r1.cfg
  - name: R2
    template: "Cisco IOSv"
    console_port: 5002
    config: configs/r2.cfg
links:
  - endpoints: ["R1:Gi0/1", "R2:Gi0/1"]
    subnet: 10.0.12.0/30
```

### Output Requirements
- Report node status (started/stopped)
- Show console port mappings for manual access
- Log all API calls for debugging
- Support idempotent operations (re-run safely)

