Scripts Overview
Thescripts/examples/ directory contains ready-to-use bash scripts for automating common GNS3util workflows.
Available Scripts
deploy-template-exercise.sh
Deploys an exercise using an existing project as a template. Usage:create-exercise-interactive.sh
Creates an exercise with interactive template selection. Usage:import-template-and-create-exercise.sh
Creates an exercise using a template file. Usage:setup-class-lab.sh
Creates individual lab projects for students with basic topology. Usage:cleanup-class.sh
Cleans up projects with a specified prefix. Usage:test-all-scripts.sh
Comprehensive validation script that runs all example scripts. Usage:Script Features
Common Features
- All scripts use
#!/usr/bin/env bashfor better compatibility - Server URL is passed as a command-line argument
- Authentication is expected to be pre-configured
- Error handling and validation included
- Colored output for better readability
Error Handling
- Input validation
- Server connectivity checks
- Command execution verification
- Graceful error messages
Output Formatting
- Colored success/error messages
- Progress indicators
- Detailed logging
- JSON output support
Prerequisites
Authentication
Before running scripts, ensure you’re authenticated:Dependencies
gns3utilbinary in PATH or current directoryjqfor JSON processinggrep,awk,trfor text processingcurlfor HTTP requests (if needed)
Server Requirements
- GNS3v3 server running
- Network connectivity
- Appropriate permissions for operations
Usage Patterns
Educational Workflow
Template Management
Validation and Verification
Customization
Modifying Scripts
- Edit script parameters
- Add custom validation
- Extend functionality
- Add logging
Creating New Scripts
- Follow existing patterns
- Include error handling
- Add help text
- Validate thoroughly
Integration
- Use in CI/CD pipelines
- Integrate with monitoring
- Add to automation workflows
- Extend with additional tools
Troubleshooting
Common Issues
Script Not Found
Permission Denied
Authentication Failed
Server Connection Failed
Debug Mode
Logging
Best Practices
Script Development
- Use descriptive variable names
- Include comprehensive error handling
- Add input validation
- Document script purpose and usage
Validation
- Validate with different server configurations
- Check error conditions
- Verify edge cases
- Confirm output accuracy
Maintenance
- Keep scripts up to date
- Monitor for deprecations
- Update documentation
- Version control changes