GNS3util Automation Walkthrough
This comprehensive walkthrough demonstrates how to automate GNS3 lab management using the gns3util tool and example scripts.Table of Contents
- Prerequisites
- Quick Start
- Template-Based Exercise Creation
- Class Management Automation
- Advanced Automation Scenarios
- Troubleshooting
- Best Practices
Prerequisites
System Requirements
- GNS3v3 Server: Running GNS3v3 server with API access
- GNS3util CLI: Built and available in your PATH
- Dependencies:
jqfor JSON processing,bashshell - Authentication: Valid credentials for the GNS3 server
Initial Setup
Quick Start
1. Authentication
2. Test All Scripts
3. Create Your First Exercise
Template-Based Exercise Creation
Understanding Templates
Templates are the foundation of automated lab deployment. They allow you to:- Standardize lab environments across all student groups
- Reuse configurations for multiple exercises
- Ensure consistency in network topologies and device configurations
Template Types
1. Server-Based Templates (Recommended)
Use existing projects already on the server as templates. Advantages:- Fastest deployment
- No file upload required
- Easy to manage and update
- Interactive selection available
2. File-Based Templates
Import.gns3project files as templates.
Advantages:
- Easy to share and version control
- Can be stored in repositories
- Useful for backup and restore
3. Interactive Template Selection
Use fuzzy finder to select from available templates. Advantages:- User-friendly interface
- No need to remember exact names
- Shows all available options
Creating Templates
Method 1: Manual Template Creation
Method 2: Export Existing Project
Class Management Automation
Creating Classes Programmatically
Using JSON Files
Create a class definition file:Using Interactive Mode
Managing Multiple Classes
List All Classes
Delete Classes
Bulk Class Creation
Create a script to manage multiple classes:Advanced Automation Scenarios
Scenario 1: Semester Setup
Automate the entire semester setup process:Scenario 2: Weekly Lab Rotation
Automate weekly lab rotations:Scenario 3: Individual Student Labs
Create individual lab environments for each student:Scenario 4: Template Management
Automate template creation and management:Troubleshooting
Common Issues
1. Authentication Problems
2. Template Not Found
3. Class Creation Failed
4. Node Creation Issues
Debug Commands
Best Practices
1. Template Management
- Use descriptive names:
NetworkLabTemplate,SecurityLabTemplate - Version control: Keep template files in git repositories
- Documentation: Document what each template contains
- Regular updates: Keep templates up-to-date with course requirements
2. Class Organization
- Consistent naming: Use consistent naming conventions for classes
- Group management: Organize students into logical groups
- Access control: Ensure proper ACLs are set up
- Cleanup: Regular cleanup of old projects and classes
3. Automation Scripts
- Error handling: Always include error checking
- Logging: Log important operations
- Idempotency: Scripts should be safe to run multiple times
- Documentation: Document script parameters and usage
4. Security
- Authentication: Use secure authentication methods
- Access control: Limit student access to their assigned projects
- Resource limits: Set appropriate resource limits
- Regular audits: Regularly audit access and permissions
5. Performance
- Batch operations: Use batch operations when possible
- Resource monitoring: Monitor server resources
- Cleanup: Regular cleanup of unused resources
- Optimization: Optimize scripts for performance