GNS3util Educational Scripts
This directory contains educational bash scripts for automating GNS3 lab management and exercise deployment with advanced template-based functionality.
🎯 Template-Based Exercise System
The scripts demonstrate a powerful template system that allows instructors to: - Use existing projects as templates for consistent lab environments - Import template files for sharing lab configurations - Automatically duplicate templates for each student group - Manage access control so students only see their assigned projects
Scripts Overview
🚀 Template-Based Exercise Scripts
deploy-template-exercise.sh
Deploy an exercise using an existing project as a template. This is the recommended approach for most use cases.
Usage:
Example:
What it does: 1. Uses an existing project on the server as a template 2. Creates exercise projects for each student group 3. Duplicates the template for each group with proper naming 4. Sets up access control for students
create-exercise-interactive.sh
Create an exercise with interactive template selection using fuzzy finder. Perfect for when you want to choose from available templates.
Usage:
Example:
What it does: 1. Shows a fuzzy-finder interface to select from available projects 2. Uses the selected project as a template 3. Creates exercise projects for each student group 4. Provides interactive feedback during selection
import-template-and-create-exercise.sh
Create an exercise using a template file (.gns3project). Useful for sharing templates or when templates aren't on the server.
Usage:
Example:
./import-template-and-create-exercise.sh http://gns3-server:3080 CS101 Lab1 /path/to/template.gns3project
What it does: 1. Imports a .gns3project file to the server 2. Uses the imported project as a template 3. Creates exercise projects for each student group 4. Cleans up the temporary imported template
Lab Management Scripts
setup-class-lab.sh
Create individual lab projects for students with basic network topology.
Usage:
Example:
cleanup-class.sh
Clean up projects with a specific prefix.
Usage:
Example:
Testing Scripts
test-all-scripts.sh
Test all example scripts with comprehensive reporting.
Usage:
Example:
Prerequisites
- GNS3util CLI: Ensure
gns3util
is built and available in the project root - GNS3 Server: Access to a running GNS3v3 server
- Authentication: Valid credentials for the GNS3 server
- Dependencies:
jq
for JSON processing (for cleanup script)bash
shell
Quick Start
-
Make scripts executable:
-
Test all scripts:
-
Create a class and exercise:
Features
Template Support
- Server-based templates: Use existing projects as templates
- File-based templates: Import .gns3project files
- Interactive selection: Fuzzy finder for template selection
- Automatic cleanup: Template projects are cleaned up after duplication
Class Management
- JSON-based class creation: Structured class definition
- Multiple groups: Support for multiple student groups
- User management: Automatic student account creation
- Permission isolation: Students can only access their assigned projects
Lab Automation
- Bulk operations: Create multiple projects/nodes at once
- Template duplication: Identical lab setups for all students
- Resource management: Proper cleanup and resource allocation
- Error handling: Robust error checking and user feedback
Educational Use Cases
For Instructors
- Quick lab setup: Deploy identical labs for entire class
- Template management: Create reusable lab configurations
- Class organization: Manage multiple classes and exercises
- Resource cleanup: Automated cleanup after classes
For Students
- Isolated environments: Each student gets their own lab instance
- Consistent setup: All students work with identical configurations
- Self-service: Students can start/stop their own labs
- Progress tracking: Individual project management
Troubleshooting
Common Issues
- Command not found: Ensure
gns3util
is in the project root - Authentication failed: Check server URL and credentials
- Template not found: Verify template project exists on server
- Permission denied: Ensure proper ACLs are set up
Debug Commands
# Check authentication
gns3util -s http://server:3080 auth status
# List available projects
gns3util -s http://server:3080 project ls
# Check server version
gns3util -s http://server:3080 system version
Contributing
When adding new scripts:
- Use
#!/usr/bin/env bash
shebang for compatibility - Include proper usage instructions and examples
- Add error checking and user feedback
- Follow the existing naming convention
- Test scripts thoroughly before committing
License
These scripts are part of the gns3util project and follow the same license terms.