Skip to main content

GNS3util Automation Walkthrough

This comprehensive walkthrough demonstrates how to automate GNS3 lab management using the gns3util tool and example scripts.

Table of Contents

  1. Prerequisites
  2. Quick Start
  3. Template-Based Exercise Creation
  4. Class Management Automation
  5. Advanced Automation Scenarios
  6. Troubleshooting
  7. Best Practices

Prerequisites

System Requirements

  • GNS3v3 Server: Running GNS3v3 server with API access
  • GNS3util CLI: Built and available in your PATH
  • Dependencies: jq for JSON processing, bash shell
  • 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

Use existing projects already on the server as templates. Advantages:
  • Fastest deployment
  • No file upload required
  • Easy to manage and update
  • Interactive selection available
Example:

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
Example:

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
Example:

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:
Then create the class:

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

Example Workflows

Complete Semester Setup

Daily Lab Management

This walkthrough provides a comprehensive guide to automating GNS3 lab management using the gns3util tool and example scripts. The examples can be adapted to fit your specific educational environment and requirements.