Skip to main content

A cli util based arround the GN3v3 api

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

GNS3 API Util

surely a temporary logo

PyPI Version Python Version GitHub Issues or Pull Requests by label language count repo size GitHub License

A command-line utility for interacting with the GNS3 API, designed especially for setting up educational environments. This tool streamlines common API operations—such as authentication, GET, POST, and DELETE requests—against a GNS3 server, making it easier to automate and manage classes, exercises, users, groups, and more in your network emulation labs.

Table of Contents

Features

  • Educational Environment Setup: Easily create and manage classes and exercises for students.
  • Interactive CLI: Use fuzzy search and interactive prompts for selecting users, groups, and more.
  • Automation: Scriptable for bulk operations and integration into CI/CD or lab provisioning.
  • Web-based Class Generator: Launch a local web UI to generate class JSON for bulk student creation.
  • Comprehensive API Coverage: Supports most GNS3 v3 API endpoints for GET, POST, DELETE.

Installation

Using uv (Recommended)

uv is a fast Python package manager and virtual environment tool.

  1. Install uv (if not already installed):

    pip install uv
    
  2. Create a virtual environment and install gns3util:

    uv venv venv
    source venv/bin/activate
    uv pip install gns3util
    

    Or, for user installs (no root required):

    uv pip install --user gns3util
    

From PyPI

Install the latest release directly from PyPI:

pip install gns3util

Or, for user installs (no root required):

pip install --user gns3util

From Source

  1. Clone the Repository

    git clone https://github.com/Stefanistkuhl/gns3-api-util.git
    cd gns3-api-util
    
  2. (Optional) Create a Virtual Environment

    Using uv:

    uv venv venv
    source venv/bin/activate
    

    Or with standard venv:

    python -m venv venv
    source venv/bin/activate
    
  3. Install the Project

    pip install -e .
    

Dependencies

The following Python packages are required and will be installed automatically:

For enhanced interactive selection, you can also install fzf (optional):

# On Ubuntu/Debian
sudo apt install fzf

# Or via Homebrew (macOS/Linux)
brew install fzf

# Or via winget (Windows)
winget install --id=junegunn.fzf

Usage

After installing, the utility can be executed directly from the command line using the entry point gns3util.

Authentication

You can authenticate to the GNS3 server using several methods:

  • Flags:
    Use --username and --password (or -u and -p) to provide credentials directly.
    gns3util --server http://localhost:3080 --username admin --password secret ...
    
  • Environment Variables:
    Set GNS3_USERNAME and GNS3_PASSWORD in your environment.
    export GNS3_USERNAME=admin
    export GNS3_PASSWORD=secret
    gns3util --server http://localhost:3080 ...
    
  • Standard Input:
    If you omit the password, you will be prompted securely for it via stdin.

Running the CLI

At a minimum, provide the --server (or -s) option with the URL of your GNS3 server:

gns3util --server http://<GNS3_SERVER_ADDRESS>

Main Commands

The CLI supports several subcommands to interact with the GNS3 API:

  • auth: Manage authentication (login, status).
  • get: Perform GET requests (list users, groups, projects, etc).
  • post: Perform POST requests (create resources, run actions).
  • delete: Perform DELETE requests (remove users, groups, projects, etc).
  • create: High-level creation commands for classes, exercises, and more.
  • add: Add members/resources to groups or pools.
  • update: Update resources with new data.
  • fuzzy: Interactive fuzzy-finder commands for selecting users/groups.
  • stream: Stream notifications from the GNS3 server.

Educational Workflow

1. Create a Class (with Students)

You can launch a local web UI to generate a class JSON and bulk-create students:

gns3util --server http://localhost:3080 create class --create

Or use an existing JSON file:

gns3util --server http://localhost:3080 create class path/to/class.json

2. Exercise Management

Create an exercise for a class:

gns3util --server http://localhost:3080 create exercise <class_name> <exercise_name>

Delete an exercise interactively:

gns3util --server http://localhost:3080 delete exercise

Non-interactive deletion for exercises:
Use the correct flags as defined in the CLI:

  • -n, --non_interactive <value>: Run the command non-interactively.
  • -c, --set_class <class>: Set the class from which to delete the exercise.
  • -g, --set_group <group>: Set the group from which to delete the exercise.
  • -a, --delete_all: Delete all exercises.

Example:

gns3util --server http://localhost:3080 delete exercise --non_interactive yes --set_class MyClass --set_group MyGroup

Delete all exercises in a class:

gns3util --server http://localhost:3080 delete exercise --set_class MyClass --set_group MyGroup --delete_all

3. Delete a Class or Exercise

Delete a class and all its students interactively:

gns3util --server http://localhost:3080 delete class

Non-interactive deletion:
You can delete a class directly by specifying its name with the --non_interactive flag:

gns3util --server http://localhost:3080 delete class --non_interactive MyClass

Delete all classes:
To delete all classes non-interactively, use the --delete_all flag:

gns3util --server http://localhost:3080 delete class --delete_all

Delete all exercises of a class:
To delete all exercises of a class when deleting the class, use the --delete_exercises flag:

gns3util --server http://localhost:3080 delete class --non_interactive MyClass --delete_exercises

4. Interactive Fuzzy Search

Find users or groups with fuzzy search:

gns3util --server http://localhost:3080 fuzzy user-info
gns3util --server http://localhost:3080 fuzzy group-info

Help

You can view the help text by using the --help option:

gns3util --help

Or for any subcommand:

gns3util <subcommand> --help

This will display usage information and options for each command.


Command Reference

Below is a list of all subcommands grouped by their command groups:

auth (Authentication)
  • login
  • status
get (GET API endpoints)
  • version
  • iou-license
  • statistics
  • me
  • users
  • projects
  • groups
  • roles
  • privileges
  • acl-endpoints
  • acl
  • templates
  • symbols
  • images
  • default-symbols
  • computes
  • appliances
  • pools
  • user
  • user-groups
  • project
  • project-stats
  • project-locked
  • group
  • group-members
  • role
  • role-privileges
  • template
  • compute
  • docker-images
  • virtualbox-vms
  • vmware-vms
  • images_by_path
  • snapshots
  • appliance
  • pool
  • pool-resources
  • drawings
  • symbol
  • acl-rule
  • links
  • nodes
  • node
  • node-links
  • link
  • link-filters
  • drawing
  • usernames-and-ids
  • uai
post (POST API endpoints)
  • controller reload
  • controller shutdown
  • image install_img
  • project duplicate_template
  • project project_close
  • project project_open
  • project project_lock
  • project project_unlock
  • node start_nodes
  • node stop_nodes
  • node suspend_nodes
  • node reload_nodes
  • node nodes_console_reset
  • compute connect_compute
  • image upload_img
  • project project_import
  • project project_write_file
  • node node_isolate
  • node node_unisolate
  • node node_console_reset
  • link reset_link
  • link stop_link_capture
  • snapshot snapshot_restore
  • image add_applience_version
  • node duplicate_node
  • link start_link_capture
  • class
  • exercise
  • check_version
  • user_authenticate
delete (DELETE API endpoints)
  • prune_images
  • user
  • compute
  • project
  • template
  • image
  • acl
  • role
  • group
  • pool
  • pool_resource
  • link
  • node
  • drawing
  • role_priv
  • user_from_group
  • snapshot
  • class
  • exercise
create (High-level creation commands)
  • user
  • group
  • role
  • acl
  • template
  • project
  • project_load
  • add_pool
  • create_compute
  • qemu_img
  • node
  • link_create
  • drawing_create
  • snapshot_create
  • add_applience_version
  • create
  • project_node_from_template
  • disk_img
  • node_file
  • class
  • exercise
add (Add resources/members)
  • group_member
  • ressouce_to_pool
update (Update resources)
  • iou_license
  • me
  • user
  • group
  • acl
  • template
  • project
  • compute
  • pool
  • role
  • role_privs
  • node
  • drawing
  • link
  • disk_image
fuzzy (Interactive fuzzy-finder commands)
  • user-info
  • ui
  • group-info
  • gi
  • group-info-with-usernames
  • gim
  • user-info-and-group-membership
  • uig
  • chpw
  • change-password
stream (Notification streaming)
  • notifications
  • project-id

For more details, see the PyPI page or the GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gns3util-0.6.6.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gns3util-0.6.6-py3-none-any.whl (29.9 kB view details)

Uploaded Python 3

File details

Details for the file gns3util-0.6.6.tar.gz.

File metadata

  • Download URL: gns3util-0.6.6.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.8

File hashes

Hashes for gns3util-0.6.6.tar.gz
Algorithm Hash digest
SHA256 4a02e97a80479b3ee5030b06df05568ef592593b14d6142517ae0bf7f4926c4b
MD5 283220000120bf94d05ef53b54885817
BLAKE2b-256 ce8add33e2ed1fce089109f92dc9fc410c515d630ae1b5b4e876655ec54d6d2e

See more details on using hashes here.

File details

Details for the file gns3util-0.6.6-py3-none-any.whl.

File metadata

  • Download URL: gns3util-0.6.6-py3-none-any.whl
  • Upload date:
  • Size: 29.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.8

File hashes

Hashes for gns3util-0.6.6-py3-none-any.whl
Algorithm Hash digest
SHA256 92e28f26d3a5ad36d2f884da7334ebb25a77afaf1257cf2003c22be46b99a38a
MD5 ece0405c95c474f2778b845dfa12fdcc
BLAKE2b-256 fd1b93de2cb337ad66356ff9e13b38da69545bf14d637feddb8f9c2881d4e5ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page