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
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, PUT, 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, PUT, DELETE.
Installation
From PyPI (Recommended)
Install the latest release directly from PyPI:
pip install gns3util
Or, for user installs (no root required):
pip install --user gns3util
From Source
-
Clone the Repository
git clone https://github.com/Stefanistkuhl/gns3-api-util.git cd gns3-api-util
-
(Optional) Create a Virtual Environment
python -m venv venv source venv/bin/activate
-
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--usernameand--password(or-uand-p) to provide credentials directly.gns3util --server http://localhost:3080 --username admin --password secret ...
- Environment Variables:
SetGNS3_USERNAMEandGNS3_PASSWORDin 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).
- put: Perform PUT requests (update resources).
- 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. Create an Exercise for a Class
gns3util --server http://localhost:3080 create exercise <class_name> <exercise_name>
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 --name flag:
gns3util --server http://localhost:3080 delete class --name <class_name>
Delete all classes:
To delete all classes non-interactively, use the --all flag:
gns3util --server http://localhost:3080 delete class --all
Delete an exercise (interactive):
gns3util --server http://localhost:3080 delete exercise
Non-interactive deletion for exercises:
gns3util --server http://localhost:3080 delete exercise --name <exercise_name>
gns3util --server http://localhost:3080 delete exercise --all
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)
loginstatus
get (GET API endpoints)
versioniou-licensestatisticsmeusersprojectsgroupsrolesprivilegesacl-endpointsacltemplatessymbolsimagesdefault-symbolscomputesappliancespoolsuseruser-groupsprojectproject-statsproject-lockedgroupgroup-membersrolerole-privilegestemplatecomputedocker-imagesvirtualbox-vmsvmware-vmsimages_by_pathsnapshotsappliancepoolpool-resourcesdrawingssymbolacl-rulelinksnodesnodenode-linkslinklink-filtersdrawingusernames-and-idsuai
post (POST API endpoints)
controller reloadcontroller shutdownimage install_imgproject duplicate_templateproject project_closeproject project_openproject project_lockproject project_unlocknode start_nodesnode stop_nodesnode suspend_nodesnode reload_nodesnode nodes_console_resetcompute connect_computeimage upload_imgproject project_importproject project_write_filenode node_isolatenode node_unisolatenode node_console_resetlink reset_linklink stop_link_capturesnapshot snapshot_restoreimage add_applience_versionnode duplicate_nodelink start_link_captureclassexercisecheck_versionuser_authenticate
put (PUT/UPDATE API endpoints)
iou_licensemeusergroupacltemplateprojectcomputepoolrolerole_privsnodedrawinglinkdisk_image
delete (DELETE API endpoints)
prune_imagesusercomputeprojecttemplateimageaclrolegrouppoolpool_resourcelinknodedrawingrole_privuser_from_groupsnapshotclassexercise
create (High-level creation commands)
usergrouproleacltemplateprojectproject_loadadd_poolcreate_computeqemu_imgnodelink_createdrawing_createsnapshot_createadd_applience_versioncreateproject_node_from_templatedisk_imgnode_fileclassexercise
add (Add resources/members)
group_memberressouce_to_pool
update (Update resources)
iou_licensemeusergroupacltemplateprojectcomputepoolrolerole_privsnodedrawinglinkdisk_image
fuzzy (Interactive fuzzy-finder commands)
user-infouigroup-infogigroup-info-with-usernamesgimuser-info-and-group-membershipuigchpwchange-password
stream (Notification streaming)
notificationsproject-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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gns3util-0.6.5.tar.gz.
File metadata
- Download URL: gns3util-0.6.5.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd5e4daa0bd7d3c5f47ec629d73f83074f33aa71f6db9494c1553ef1edbd07d3
|
|
| MD5 |
c1748009ad4dc16786a678fb5d7bc0f1
|
|
| BLAKE2b-256 |
2f0c31a6560eb01cbc260c0d96119d542858b27f5928ebc427bbeaf36d15eb96
|
File details
Details for the file gns3util-0.6.5-py3-none-any.whl.
File metadata
- Download URL: gns3util-0.6.5-py3-none-any.whl
- Upload date:
- Size: 29.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3204ce85e49198ecc92e66ba7d8886e0e5d3fabb23769da0f086bb84bbbdd727
|
|
| MD5 |
3f37bc0db3b5d6d4abfc695dd767f8aa
|
|
| BLAKE2b-256 |
215dda399c2a26c5dc8cba78ccefc43537a6b21cbcab3037f66f6378bb397b06
|