Skip to main content

Scripts Overview

The scripts/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:
Example:

create-exercise-interactive.sh

Creates an exercise with interactive template selection. Usage:
Example:

import-template-and-create-exercise.sh

Creates an exercise using a template file. Usage:
Example:

setup-class-lab.sh

Creates individual lab projects for students with basic topology. Usage:
Example:

cleanup-class.sh

Cleans up projects with a specified prefix. Usage:
Example:

test-all-scripts.sh

Comprehensive validation script that runs all example scripts. Usage:
Example:

Script Features

Common Features

  • All scripts use #!/usr/bin/env bash for 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

  • gns3util binary in PATH or current directory
  • jq for JSON processing
  • grep, awk, tr for text processing
  • curl for 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

Examples

Complete Workflow

Template Management